Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved


Chapter 7 TIBCO ActiveEnterprise Operation Model : Implementing ActiveEnterprise Operations in Java

Implementing ActiveEnterprise Operations in Java
The remote operation paradigm in the Java SDK is similar to that in the C++ SDK, with two exceptions:
There are MClientRequest/MClientReply and MServerRequest/MServerReply classes (instead of just MOperationRequest and MOperationReply)
In addition to using any of the onInvoke() methods, Java programmers can take advantage of the Java introspection mechanism to use an adapter-defined method with a name of their choice.
This section gives an overview of ActiveEnterprise operation programming, which is also illustrated by the zapadapterRPC example program.
Defining ActiveEnterprise Operation Elements
Using TIBCO Designer, you define the clients, servers, and operations in two different locations:
See the TIBCO Designer Palette Reference available via Help > Designer Help from TIBCO Designer.
See the TIBCO Designer Palette Reference available via Help > Designer Help from TIBCO Designer. See also Defining Endpoints and Protocols.
The following example shows the information required to define an ActiveEnterprise operation.
Class Name = rfc-order
    Operation Name = rfc-get-order
Returns= string
        Parameter Name = inp1
Parameter Type = i4
        Direction = in
Default = 4
 
        Parameter Name = inoutp2
Parameter Type = i4
        Direction = inout
Default = 5
 
        Parameter Name = outp3
Parameter Type = i4
        Direction = out
        Raises Name = order-exception
        Type = string
Defining Endpoints and Protocols
The endpoint and protocol information is defined using TIBCO Designer. For example, the following information is required to define an endpoint named client1 and an endpoint named server1.
Endpoint Name = client1
     Type = RV RPC Client
Session = session1
Subject = OPERATION.HELLO
Invocation Timeout = 5000
 
Endpoint Name = server1
     Type = RV RPC Server
Session = session1
Subject = OPERATION.HELLO
Note the following points while defining endpoints:
There is no RvCmqClient in this example because certified remote operations are implemented with an RvCmClient.
Defining and Invoking the Methods
In the Java SDK, there are two ways to implement the method that is executed remotely.
Using the onInvoke() or onOnewayInvoke() Method
To use one of the SDK-supplied methods:
1.
Create a subclass of MOperationImpl.
2.
Create a method that you want to be invocable by a client through the remote operation service. Override either onInvoke() or onOnewayInvoke() to provide a meaningful implementation (depending on whether the operation is defined as one-way).
3.
If you choose to implement onInvoke(), an MServerReply object is passed to the callback method. The custom adapter is responsible for calling reply() on this object to send back the reply. The resulting behavior is that of an asynchronous server.
Using a Method of Your Choice to be Invoked Remotely
To allow for a more natural syntax, you can also use a method of your choice.
1.
Create an MOperationImpl subclass.
2.
You can also choose to have the returned value of the Java method be of type MServerReply. In that case, the MServerReply object can hold the returned value and/or the in and in-out parameter values. If you have in-out parameters in the operation description, return MServerReply from the operation method.
Exception of any type can be thrown whenever appropriate; however, only exceptions of type MOperationException are caught and forwarded back to the requestor. Other exceptions are just logged locally.
The resulting behavior is that of a synchronous server.
Whether a reply is sent back depends on the operation’s one-way property. Nevertheless, the custom adapter must not call reply() on the MServerReply object even if it uses it to pass back information to the client. The SDK sends back the reply if appropriate.
If a method as described above exists (determined by class introspection), it takes precedence over either onInvoke() or onOnewayInvoke().

Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved