IdAssignmentPolicy::SYSTEM_IDをPOAに設定すれば,オブジェクトIDの指定をしないでオブジェクトを明示的に活性化できます。サーバはオブジェクトのオブジェクトIDの活性化,割り当て,リターンを行うPOAのactivate_objectを呼び出します。このタイプの活性化はトランジェントオブジェクトでは最もよく使用されます。オブジェクトもサーバントもあまり長期間は必要ではないので,サーバントマネージャは不要です。
オブジェクトIDを使用してオブジェクトを明示的に活性化することもできます。一般的なシナリオは,サーバが管理するすべてのオブジェクトを活性化するためにユーザがactivate_object_with_idを呼び出すサーバ初期化中です。すべてのオブジェクトは活性化済みなので,サーバントマネージャは不要です。存在しないオブジェクトに対するリクエストを受信すると,OBJECT_NOT_EXIST例外が発生します。サーバが多数のオブジェクトを管理している場合,お勧めできません。
// Create the servant
AccountManagerImpl managerServant;
// Decide on the ID for the servant
PortableServer::ObjectId_var managerId =
PortableServer::string_to_ObjectId("BankManager");
// Activate the servant with the ID on myPOA
myPOA->activate_object_with_id(managerId,&managerServant);
// Activate the POA Manager
PortableServer::POAManager_var rootManager =
rootPOA->the_POAManager();
rootManager->activate();
// Create the account manager servant.
Servant managerServant = new AccountManagerImpl(rootPoa);
// Activate the newly created servant.
testPoa.activate_object_with_id(
"BankManager".getBytes(), managerServant);
// Activate the POAs
testPoa.the_POAManager().activate();