Recommended: Sing it, brah! 5 fabulous songs for developers
JW's Top 5
Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
Page 6 of 7
_accNum), the accountNumber() method creates a new account number based on the object ID. It retrieves this ID with the public _object_id() method that is part of the org.omg.PortableServer.Servant class—one of AccountPOA's base classes (automatically generated by idlj). The _object_id is actually a shortcut for calling PortableServer::Current::get_object_id. The Current interface provides methods for retrieving the current request's context. All ORBs provide an implementation of the Current interface that can be retrieved by calling the resolve_initial_references() method on the ORB with the parameter POACurrent. Since the default servant will be used for many (or all) requests, being able to retrieve the context information, such
as the object ID, proves important.
_accNum) now use the accountNumber()method.
Now that we have implemented the bank and account servants, we must code a server process that will create the necessary POA hierarchy with the correct policies installed in each POA. Follow four main steps to create this process:
BankPOA: Regardless of the solution used for the implementations' Account piece, this step remains the same: // Create the BankPOA
Policy[] policies = new Policy[3];
policies[0] = rootPOA.create_lifespan_policy(LifespanPolicyValue.PERSISTENT);
policies[1] =
rootPOA.create_request_processing_policy(RequestProcessingPolicyValue.
USE_ACTIVE_OBJECT_MAP_ONLY );
policies[2] = rootPOA.create_servant_retention_policy(ServantRetentionPolicyValue.
RETAIN);
POA bankPOA = rootPOA.create_POA("BankPOA",null,policies);
The BankPOA creates persistent object references and uses the active object map only with the default RETAIN policy.
AccountPOA: The AccountPOA policies vary depending on which of the three solutions you use.Here is the code for creating AccountPOA if a servant activator is used:
// Create the AccountPOA and set its ServantActivator
policies[0] = rootPOA.create_lifespan_policy(LifespanPolicyValue.PERSISTENT);
policies[1] =
rootPOA.create_request_processing_policy(RequestProcessingPolicyValue.
USE_SERVANT_MANAGER);
policies[2] = rootPOA.create_servant_retention_policy(ServantRetentionPolicyValue.
RETAIN);
POA accountPOA = rootPOA.create_POA("AccountPOA",null,policies);
AccountServerActivatorImpl asa = new bank.AccountServerActivatorImpl();
rootPOA.activate_object(asa);
accountPOA.set_servant_manager(asa._this(orb));
Here is the code for creating AccountPOA if you choose the servant locator solution:
// Create the AccountPOA and set its ServantLocator (NON_RETAIN
Policy)
policies[0] = rootPOA.create_lifespan_policy(LifespanPolicyValue.PERSISTENT);
policies[1] =
rootPOA.create_request_processing_policy(RequestProcessingPolicyValue.
USE_SERVANT_MANAGER);
policies[2] = rootPOA.create_servant_retention_policy(ServantRetentionPolicyValue.
NON_RETAIN);
POA accountPOA = rootPOA.create_POA("AccountPOA",null,policies);
AccountServerLocatorImpl asl = new bank.AccountServerLocatorImpl();
rootPOA.activate_object(asl);
accountPOA.set_servant_manager(asl._this(orb));
And here is the code for creating AccountPOA if you use a default servant: