OpenCloud's Echo service echoes the messages received by the Telnet RA, on the telnet channel that the RA is listening on. The different between the Echo Service is that the Count Echo Service counts the number of echos and stores it in a CMP.
and a 'do-it-yourself' (DIY) section of console commands you can use to check out the service in action.
This page assumes... ...an understand of the functionality of Telnet Resource Adaptor and how activities and events interact with the SLEE. And, an understand of the functionality of the Echo Service, how receives messages and how sends the response.
This service consists of an SBB that handles the event MessageEvent of the Telnet RA, and replies with a counter and the same message on the current telnet channel. The counter is stored in a CMP field. A CMP is one of the options to persist state of an SBB entity.
Deploy the Telnet RA and the Echo service and telnet to port 9999. The Echo service will echo all the written messages and prefix them with a counter.
The Sbb abstract class has to include an abstract getter and a setter for the CMP. The SLEE will implement these methods.
* Getter for CMP field counting number of messages received by this SBB Entity
* Setter for CMP field counting number of messages received by this SBB Entity
publicabstract void setCount(int count);
The sbb-jar.xml deployment descriptor has to define the CMP field name
The project uses the Maven JAIN SLEE Plugin to manage dependencies and package the service. The files provided are the descriptors (service, sbb and library), the SBB class and a unit test example.
Below are excerpts from the JAIN SLEE specification relevant to the service:
JAIN SLEE Specification
6.5 Container Managed Persistence (CMP)
An SBB entity defines its persistent state as a set of CMP fields.
6.5.1 CMP field rules
The SBB Developer must observe the following rules when defining the CMP fields of an SBB:
From the perspective of the SBB Developer, the CMP fields are virtual fields only, and are accessed through get and set accessor methods. The SLEE supplies the implementation of the CMP fields. The CMP fields must not be defined in the SBB abstract class (i.e. as an instance variable in the class.)
The CMP fields must be specified in the SBB's deployment descriptor using the cmp-field elements respectively. The names of these fields must be valid Java identifiers and must begin with a lowercase letter, as determined by java.lang.Character.isLowerCase.
The SBB Developer must declare the accessor methods for the CMP fields as get and set methods, using the JavaBeans conventions. The SLEE supplies the implementation of the accessor methods.
The accessor methods must be public, must be abstract, and must bear the name of the CMP field that is specified in the cmp-field deployment descriptor element, and in which the first letter of the name of the CMP field has been uppercased and prefixed by "get" or "set".
The Java types of the CMP fields are restricted to Java primitive types, Java serializable types, SBB local interfaces (i.e., SbbLocalObject and the types derived from SbbLocalObject), Activity Context Interface interfaces (i.e., ActivityContextInterface and the types derived from ActivityContextInterface), Event Context interfaces (i.e., EventContext), and Profile Local interfaces (i.e. ProfileLocalObject and the types derived from ProfileLocalObject).
Since the SLEE specification does not require the SBB local interfaces, Activity Context Interface interfaces, Event Context interfaces, and Profile Local interfaces to be serializable, non-primitive CMP field types cannot contain these types. For example, neither a composite object that contains one or more SBB local interface member types nor an SBB local interface array are valid CMP field types.
The CMP field accessor methods are mandatory transactional methods (see Section 9.6.1). They throw a javax.slee.TransactionRequiredLocalException if they are invoked without a valid transaction context.
These methods may also throw a javax.slee.SLEEException if the operation cannot be completed due to a system-level failure.
Neither the get accessor method nor the set accessor method can include a throws clause.
Do it yourself
Below are some console commands you can try, to observe what is happening in the Rhino SLEE container when the Echo service is running. After you deploy the resource adaptor and the service, start the Rhino command-line console and try the following, to: