Portable Object Adapters replace Basic Object Adapters; they provide portability on the server side.Users familiar with versions of VisiBroker prior to 6.0 should note the change in inheritance hierarchy to support CORBA Specification 3.0, which requires local interfaces. For example, a ServantLocator implementation would now extend from org.omg.PortableServer._ServantLocatorLocalBase instead of org.omg.PortableServer.ServantLocatorPOA.
Figure 5
• Thread policy The thread policy specifies the threading model to be used by the POA.
• ORB_CTRL_MODEL: (Default) The POA is responsible for assigning requests to threads. In a multi-threaded environment, concurrent requests may be delivered using multiple threads. Note that VisiBroker uses multi-threading model.
• SINGLE_THREAD_MODEL: The POA processes requests sequentially. In a multi-threaded environment, all calls made by the POA to servants and servant managers are thread-safe.
• MAIN_THREAD_MODEL: Calls are processed on a distinguished “main” thread. Requests for all main-thread POAs are processed sequentially. In a multi-threaded environment, all calls processed by all POAs with this policy are thread-safe. The application programmer designates the main thread by calling ORB::run() or ORB::perform_work(). For more information about these methods, see “Activating objects”.
• Lifespan policy The lifespan policy specifies the lifespan of the objects implemented in the POA.
• TRANSIENT: (Default) A transient object activated by a POA cannot outlive the POA that created it. Once the POA is deactivated, an OBJECT_NOT_EXIST exception occurs if an attempt is made to use any object references generated by the POA.
• PERSISTENT: A persistent object activated by a POA can outlive the process in which it was first created. Requests invoked on a persistent object may result in the implicit activation of a process, a POA and the servant that implements the object.
• Object ID Uniqueness policy The Object ID Uniqueness policy allows a single servant to be shared by many abstract objects.
• UNIQUE_ID: (Default) Activated servants support only one Object ID.
• MULTIPLE_ID: Activated servants can have one or more Object IDs. The Object ID must be determined within the method being invoked at run time.
• ID Assignment policy The ID assignment policy specifies whether object IDs are generated by server applications or by the POA.
• USER_ID: Objects are assigned object IDs by the application.
• SYSTEM_ID: (Default) Objects are assigned object IDs by the POA. If the PERSISTENT policy is also set, object IDs must be unique across all instantiations of the same POA.
• Servant Retention policy The Servant Retention policy specifies whether the POA retains active servants in the Active Object Map.
• RETAIN: (Default) The POA tracks object activations in the Active Object Map. RETAIN is usually used with ServantActivators or explicit activation methods on POA.
• NON_RETAIN: The POA does not retain active servants in the Active Object Map. NON_RETAIN must be used with ServantLocators.ServantActivators and ServantLocators are types of servant managers. For more information on servant managers, see “Using servants and servant managers”.
• Request Processing policy The Request Processing policy specifies how requests are processed by the POA.
• USE_ACTIVE_OBJECT_MAP_ONLY: (Default) If the Object ID is not listed in the Active Object Map, an OBJECT_NOT _EXIST exception is returned. The POA must also use the RETAIN policy with this value.
• USE_DEFAULT_SERVANT: If the Object ID is not listed in the Active Object Map or the NON_RETAIN policy is set, the request is dispatched to the default servant. If no default servant has been registered, an OBJ_ADAPTER exception is returned. The POA must also use the MULTIPLE_ID policy with this value.
• USE_SERVANT_MANAGER: If the Object ID is not listed in the Active Object Map or the NON_RETAIN policy is set, the servant manager is used to obtain a servant.
• Implicit Activation policy The Implicit Activation policy specifies whether the POA supports implicit activation of servants.
• IMPLICIT_ACTIVATION: The POA supports implicit activation of servants. There are two ways to activate the servants as follows:
• Converting them to an object reference with org.omg.PortableServer.POA.servant_to_reference() .
• Invoking _this() on the servant.
• NO_IMPLICIT_ACTIVATION: (Default) The POA does not support implicit activation of servants.
• Bind Support policy The Bind Support policy (a VisiBroker-specific policy) controls the registration of POAs and active objects with the VisiBroker osagent. If you have several thousand objects, it is not feasible to register all of them with the osagent. Instead, you can register the POA with the osagent. When a client request is made, the POA name and the object ID is included in the bind request so that the osagent can correctly forward the request.
• BY_INSTANCE: All active objects are registered with the osagent. The POA must also use the PERSISTENT and RETAIN policy with this value.
• BY_POA: (Default) Only POAs are registered with the osagent. The POA must also use the PERSISTENT policy with this value.
• NONE: Neither POAs nor active objects are registered with the smart agent.The rootPoa is created with NONE activation policy.Each POA keeps track of its name and its full POA name (the full hierarchical path name.) The hierarchy is indicated by a slash (/). For example, /A/B/C means that POA C is a child of POA B, which in turn is a child of POA A. The first slash (see the previous example) indicates the rootPoa. If the BindSupport:BY_POA policy is set on POA C, then /A/B/C is registered with the osagent and the client binds with /A/B/C.The resolve_initial_references method returns a value of type org.omg.CORBA.Object . You are responsible for narrowing the returned object reference to the desired type, which is org.omg.PortableServer.POA in the previous example.Policies are not inherited from the parent POA. If you want a POA to have a specific characteristic, you must identify all the policies that are different from the default value. For more information about POA policies, see “POA policies”.org.omg.CORBA.Policy[] policies = {
rootPoa.create_lifespan_policy(LifespanPolicyValue.PERSISTENT)
};A POA is created using create_POA on its parent POA. You can name the POA anything you like; however, the name must be unique with respect to all other POAs with the same parent. If you attempt to give two POAs the same name, a CORBA exception (AdapterAlreadyExists) is raised.To create a new POA, use create_POA as follows:The POA manager controls the state of the POA (for example, whether it is processing requests). If null is passed to create_POA as the POA manager name, a new POA manager object is created and associated with the POA. Typically, you will want to have the same POA manager for all POAs. For more information about the POA manager, see “Managing POAs with the POA manager”.POA managers (and POAs) are not automatically activated once created. Use activate() to activate the POA manager associated with your POA. The following code sample is an example of creating a POA.
The server application itself explicitly activates objects by calling activate_object or activate_object_with_id. By setting IdAssignmentPolicy::SYSTEM_ID on a POA, objects can be explicitly activated without having to specify an object ID. The server invokes activate_object on the POA which activates, assigns and returns an object ID for the object. This type of activation is most common for transient objects. No servant manager is required since neither the object nor the servant is needed for very long.Objects can also be explicitly activated using object IDs. A common scenario is during server initialization where the user invokes activate_object_with_id to activate all the objects managed by the server. No servant manager is required since all the objects are already activated. If a request for a non-existent object is received, an OBJECT_NOT_EXIST exception is raised. This has obvious negative effects if your server manages large numbers of objects.This code sample is an example of explicit activation using activate_object_with_id.On-demand activation occurs when a client requests an object that does not have an associated servant. After receiving the request, the POA searches the Active Object Map for an active servant associated with the object ID. If none is found, the POA invokes incarnate on the servant manager which passes the object ID value to the servant manager. The servant manager can do one of three things:
• Raise an OBJECT_NOT_EXIST exception that is returned to the client.The POA policies determine any additional steps that may occur. For example, if RequestProcessingPolicy.USE_SERVANT_MANAGER and ServantRetentionPolicy.RETAIN are enabled, the Active Object Map is updated with the servant and object ID association.A servant can be implicitly activated by certain operations if the POA has been created with ImplicitActivationPolicy.IMPLICIT_ACTIVATION, IdAssignmentPolicy.SYSTEM_ID, and ServantRetentionPolicy.RETAIN. Implicit activation can occur with:
• POA.servant_to_reference method
• POA.servant_to_id method
• _this() servant methodIf the POA has IdUniquenessPolicy.UNIQUE_ID set, implicit activation can occur when any of the above operations are performed on an inactive servant.If the POA has IdUniquenessPolicy.MULTIPLE_ID set, servant_to_reference and servant_to_id operations always perform implicit activation, even if the servant is already active.Use the RequestProcessing.USE_DEFAULT_SERVANT policy to have the POA invoke the same servant no matter what the object ID is. This is useful when little data is associated with each object.A POA can remove a servant from its Active Object Map. This may occur, for example, as a form of garbage-collection scheme. When the servant is removed from the map, it is deactivated. You can deactivate an object using deactivate_object(). When an object is deactivated, it doesn't mean this object is lost forever. It can always be reactivated at a later time.
Figure 6 There are two types of servant managers: ServantActivator and ServantLocator. The type of policy already in place determines which type of servant manager is used. For more information on POA policy, see “POA policies”. Typically, a Servant Activator activates persistent objects and a Servant Locator activates transient objects.To use servant managers, RequestProcessingPolicy.USE_SERVANT_MANAGER must be set as well as the policy which defines the type of servant manager (ServantRetentionPolicy.RETAIN for Servant Activator orServantRetentionPolicy.NON_RETAIN for Servant Locator.)ServantActivators are used when ServantRetentionPolicy.RETAIN and RequestProcessingPolicy.USE_SERVANT_MANAGER are set.
3 If the object ID is not found in the active object map, the POA invokes incarnate on a servant manager. incarnate passes the object ID and the POA in which the object is being activated.At a later date, the servant can be deactivated. This may occur from several sources, including the deactivate_object operation, deactivation of the POA manager associated with that POA, and so forth. More information on deactivating objects is described in “Deactivating objects”.In many situations, the POA's Active Object Map could become quite large and consume memory. To reduce memory consumption, a POA can be created with RequestProcessingPolicy.USE_SERVANT_MANAGER and ServantRetentionPolicy.NON_RETAIN, meaning that the servant-to-object association is not stored in the active object map. Since no association is stored, ServantLocator servant managers are invoked for each request.
2 Since ServantRetentionPolicy.NON_RETAIN is used, the POA does not search the active object map for the object ID.
3 The POA invokes preinvoke on a servant manager. preinvoke passes the object ID, the POA in which the object is being activated, and a few other parameters.
6 The POA invokes postinvoke on the servant manager.A POA manager is associated with a POA when the POA is created. You can specify the POA manager to use, or specify null to have a new POA Manager created.
•
•
• wait_for_completion is Boolean. If FALSE, this operation returns immediately after changing the state to holding. If TRUE, this operation returns only when all requests started prior to the state change have completed or when the POA manager is changed to a state other than holding. AdapterInactive is the exception raised if the POA manager was in the inactive state prior to calling this operation.AdapterInactive is the exception raised if the POA manager was in the inactive state prior to calling this operation.The wait_for_completion option is Boolean. If FALSE, this operation returns immediately after changing the state to holding. If TRUE, this operation returns only when all requests started prior to the state change have completed or when the POA manager is changed to a state other than discarding. AdapterInactive is the exception raised if the POA manager was in the inactive state prior to calling this operation.After the state changes, if etherealize_objects is TRUE, then all associated POAs that have Servant RetentionPolicy.RETAIN and RequestProcessingPolicy.USE_SERVANT_MANAGER set call etherealize on the servant manager for all active objects. If etherealize_objects is FALSE, then etherealize is not called. The wait_for_completion option is Boolean. If FALSE, this operation returns immediately after changing the state to inactive. If TRUE, this operation returns only when all requests started prior to the state change have completed or etherealize has been called on all associated POAs (that have ServantRetentionPolicy.RETAIN and RequestProcessingPolicy.USE_SERVANT_MANAGER). AdapterInactive is the exception raised if the POA manager was in the inactive state prior to calling this operation.VisiBroker provides a very flexible mechanism to define and tune endpoints for VisiBroker servers. An endpoint in this context is a destination for a communication channel for clients to communicate with servers. A Server Engine is a virtual abstraction for connection endpoint provided as a configurable set of properties.
Figure 7 The default Server Engine associated with POA can be changed by using the property vbroker.se.default. For example, settingdefines a new server engine with the name MySE. Root POA and all child POAs created will be associated with this Server Engine by default.A POA can also be associated with a particular ServerEngine explicitly by using the SERVER_ENGINE_POLICY_TYPE POA policy. For example:If you don't specify a server engine policy, the POA assumes a server engine name of iiop_tp and uses the following default values:To change the default server engine policy, enter its name using the vbroker.se.default property and define the values for all the components of the new server engine. For example:
• vbroker.se.<se-name>.host=<host-URL>: vbroker.se.mySE.host=host.microfocus.com, for example.
• vbroker.se.<se-name>.proxyHost=<proxy-host-URL-or-IP-address>: vbroker.se.mySE.proxyHost=proxy.microfocus.com, for example.The proxyHost property can also take an IP address as its value. Doing so replaces the default hostname in the IOR with this IP address.
•
• VisiBroker for Java only supports the Socket type, and a variation of the Socket type, Socket_nio, that uses the Java NIO package. See section “High scalability configuration for VisiBroker for Java (using Java NIO)” for further details.You can specify the maximum number of concurrent connections acceptable to the server endpoint using the connectionMax property:Setting connectionMax to 0 (zero) indicates that there is no restriction on the number of connections, which is the default setting.You specify the maximum number of idle seconds using the connectionMaxIdle property:Setting connectionMaxIdle to 0 (zero) indicates that there is no timeout, which is the default setting.A value of 0 (zero) means that the connection will never be garbage collected.IIOP listners need to define a port and (if desired) a proxy port in conjunction with their hosts. These are set using the port and proxyPort properties, as follows:If you do not set the port property (or set it to 0 [zero]), a random port will be selected. A 0 value for the proxyPort property means that the IOR will contain the actual port (defined by the listener.port property or selected by the system randomly). If it is not required to advertise the actual port, set the proxy port to a non-zero (positive) value.The Dispatcher defines a set of properties that determine how the SCM dispatches requests to threads. Three types of dispatchers are provided: ThreadPool, ThreadSession, and MainThread. You set the dispatcher type with the type property:VisiBroker for Java supports the cooling time property when configured to use the Java NIO package. See the section “High scalability configuration for VisiBroker for Java (using Java NIO)” for more information.
• Changing the default listener.port propertyChanging the default listener.port property is the simplest method, but this affects all POAs that use the default server engine. This may or may not be what you want.Adapter activators are associated with POAs and provide the ability to create child POAs on-demand. This can be done during the find_POA operation, or when a request is received that names a specific child POA.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.For an example on using adapter activators, see the POA adaptor_activator example included with the product.Once the VisiBroker ORB has located the appropriate POA, it delivers the request to that POA. How the request is processed at that point depends on the policies of the POA and the object's activation state. For information about object activation states, see “Activating objects”.
• If the POA has ServantRetentionPolicy.RETAIN , the POA looks at the Active Object Map to locate a servant associated with the Object ID from the request. If a servant exists, the POA invokes the appropriate method on the servant.
• If the POA has ServantRetentionPolicy.NON_RETAIN or has ServantRetentionPolicy.RETAIN but did not find the appropriate servant, the following may take place:
• If the POA has RequestProcessingPolicy.USE_DEFAULT_SERVANT , the POA invokes the appropriate method on the default servant.
• If the POA has RequestProcessingPolicy.USE_SERVANT_MANAGER , the POA invokes incarnate or preinvoke on the servant manager.
• If the POA has RequestProcessingPolicy.USE_OBJECT_MAP_ONLY , an exception is raised.If a servant manager has been invoked but cannot incarnate the object, the servant manager can raise a ForwardRequest exception.