duke@1: duke@1: duke@1:
duke@1: duke@1: duke@1: duke@1: duke@1: Provides classes and interfaces for making the server side of your applications duke@1: portable across multivendor ORBs. duke@1: duke@1:In Java, Portable Object Adaptor (POA)-based Dynamic Skeleton Interface (DSI) duke@1: servants inherit from the standard DynamicImplementation class, which duke@1: inherits from the Servant class. The native Servant type is duke@1: defined by the PortableServer module for the POA. In Java, the duke@1: Servant type is mapped to the Java duke@1: org.omg.PortableServer.Servant class. duke@1: It serves as the base class for all POA servant duke@1: implementations and provides a number of methods that may duke@1: be invoked by the application programmer, as well as methods duke@1: which are invoked by the POA itself and may be overridden by duke@1: the user to control aspects of servant behavior. duke@1: duke@1:
For a precise list of supported sections of official OMG specifications with which duke@1: the Java[tm] Platform, Standard Edition 6 complies, see Official Specifications for CORBA duke@1: support in Java[tm] SE 6. duke@1:
duke@1: duke@1:
The PortableServer module defines the following POA-related interfaces: duke@1:
duke@1:
In addition, the POA defines the Servant native type. duke@1: duke@1:
Each of the interfaces listed above has an associated Operations
interface. The Operations
interface is generated by the idlj
compiler and contains the method signatures for methods defined in its associated interface. The Operations
interface can be accessed by both the client and the server, while its associated interface can only be called by the client.
duke@1:
duke@1:
PolicyValue
provide the values used for the create_POA
call, which sets the policy for the POA. See the sample code below for a demonstration. PolicyValue
files include the following:
duke@1: duke@1:
IdAssignmentPolicyValue
duke@1: IdUniquenessPolicyValue
duke@1: ImplicitActivationPolicyValue
duke@1: LifespanPolicyValue
duke@1: RequestProcessingPolicyValue
duke@1: ServantRetentionPolicyValue
duke@1: ThreadPolicyValue
duke@1: Helper classes, which are generated for all user-defined types in an OMG IDL
duke@1: interface, supply static methods needed to manipulate those types. There is only one method in a helper class that an application programmer uses: the narrow
method. Only Java interfaces mapped from IDL interfaces will have a helper class that includes a narrow
method, so in the PortableServer
package, only the following classes have a narrow
method:
duke@1:
duke@1:
ForwardRequestHelper
duke@1: ServantActivatorHelper
duke@1: ServantLocatorHelper
duke@1: POA classes are used to implement the ServantActivator
or ServantLocator
.
duke@1:
duke@1:
The ForwardRequest
exception indicates to the ORB
duke@1: that it is responsible for delivering the current request and subsequent ForwardRequest
requests to the object denoted in the
duke@1: forward_reference
member of the exception.
duke@1:
duke@1:
Most of what PortableServer
does is transparent to the user. The result is that programmers will use only a few of the interfaces mentioned above. The remaining interfaces will be provided by the ORB implementation. The interfaces of interest to application programmers are the following:
duke@1:
duke@1:
AdapterActivator
duke@1: Adapter activators are associated with POAs. An adapter activator supplies a POA with the ability to create child POAs on demand, as a side-effect of receiving a request that names the child POA (or one of its children), or when find_POA
is called with an activate parameter value of TRUE
. An application server that creates all its needed POAs at the beginning of execution does not need to use or provide an adapter activator; it is necessary only for the case in which POAs need to be created during request processing.
duke@1:
duke@1:
ServantLocator
duke@1: When the POA has the NON_RETAIN
policy, it uses servant managers that are ServantLocator
s.
duke@1:
duke@1:
ServantActivator
duke@1: When the POA has the RETAIN
policy, it uses servant managers that are ServantActivator
s.
duke@1:
This package supplies a CookieHolder class for passing
duke@1: the Cookie type as an out
parameter. The CookieHolder
class
duke@1: follows exactly the same pattern as the other holder classes for basic types.
duke@1:
duke@1:
For an overview of Java IDL, please see: duke@1:
duke@1:
duke@1:
duke@1: import javax.naming.InitialContext; duke@1: import javax.naming.Context; duke@1: import javax.rmi.PortableRemoteObject ; duke@1: import com.sun.corba.se.impl.poa.POAORB; duke@1: import org.omg.PortableServer.*; duke@1: import java.util.*; duke@1: import org.omg.CORBA.*; duke@1: import javax.rmi.CORBA.Stub; duke@1: import javax.rmi.CORBA.Util; duke@1: duke@1: duke@1: duke@1: public class HelloServer { duke@1: public HelloServer(String[] args) { duke@1: try { duke@1: Properties p = System.getProperties(); duke@1: // p.put("org.omg.CORBA.ORBClass", "com.sun.corba.ee.internal.POA.POAORB"); duke@1: ORB orb = ORB.init( args, p ); duke@1: duke@1: POA rootPOA = (POA)orb.resolve_initial_references("RootPOA"); duke@1: duke@1: Policy[] tpolicy = new Policy[3]; duke@1: tpolicy[0] = rootPOA.create_lifespan_policy( duke@1: LifespanPolicyValue.TRANSIENT ); duke@1: tpolicy[1] = rootPOA.create_request_processing_policy( duke@1: RequestProcessingPolicyValue.USE_ACTIVE_OBJECT_MAP_ONLY ); duke@1: tpolicy[2] = rootPOA.create_servant_retention_policy( duke@1: ServantRetentionPolicyValue.RETAIN); duke@1: POA tpoa = rootPOA.create_POA("MyTransientPOA", null, tpolicy); duke@1: duke@1: duke@1: String ObjectId = "MyObjectId"; duke@1: byte[] oid = ObjectId.getBytes(); duke@1: duke@1: org.omg.CORBA.Object obj = tpoa.create_reference_with_id(oid, duke@1: new _HelloImpl_Tie()._all_interfaces(tpoa, oid)[0]); duke@1: HelloInterface helloRef = (HelloInterface)PortableRemoteObject.narrow( duke@1: obj, HelloInterface.class ); duke@1: duke@1: Context initialNamingContext = new InitialContext(); duke@1: initialNamingContext.rebind("HelloService", helloRef); duke@1: System.out.println("Hello Server: Ready..."); duke@1: orb.run(); duke@1: } catch (Exception e) { duke@1: System.out.println("Trouble: " + e); duke@1: e.printStackTrace(); duke@1: } duke@1: } duke@1: duke@1: duke@1: public static void main(String args[]) { duke@1: new HelloServer( args ); duke@1: } duke@1: } duke@1: duke@1: duke@1:duke@1: duke@1: duke@1: duke@1:
duke@1:
duke@1:
duke@1: @since 1.4
duke@1:
duke@1: @serial exclude
duke@1:
duke@1: