diff options
author | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-04-06 10:18:42 +0000 |
---|---|---|
committer | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-04-06 10:18:42 +0000 |
commit | 0eba5bcfd80728d74c5bc9c0c7c99c86983f58dd (patch) | |
tree | fbe2bd13cb702c9fc7d9efe5ccfda57b4690d3ea /TAO/examples/POA/Explicit_Activation/server.cpp | |
parent | 3ba06db921b12860cd7865fa695e9a5ca47314ed (diff) | |
download | ATCD-0eba5bcfd80728d74c5bc9c0c7c99c86983f58dd.tar.gz |
*** empty log message ***
Diffstat (limited to 'TAO/examples/POA/Explicit_Activation/server.cpp')
-rw-r--r-- | TAO/examples/POA/Explicit_Activation/server.cpp | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/TAO/examples/POA/Explicit_Activation/server.cpp b/TAO/examples/POA/Explicit_Activation/server.cpp index 4b18703c7c9..79d3d96ecb8 100644 --- a/TAO/examples/POA/Explicit_Activation/server.cpp +++ b/TAO/examples/POA/Explicit_Activation/server.cpp @@ -10,7 +10,7 @@ // // = DESCRIPTION // In this example, -// - A new POA ( firstPOA) is created, and the different functions +// - A new POA (firstPOA) is created, and the different functions // for the explicit activation of objects are demonstrated. // - The Foo application class objects (defined in // ./../Generic_Servant/MyFooServant) are used as sample objects. @@ -128,30 +128,30 @@ write_iors_to_file (const char *first_ior, int main (int argc, char **argv) { - // CORBA::Environment env; - ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY { - // Initialize the ORB first. - CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, 0, ACE_TRY_ENV); + CORBA::ORB_var orb = CORBA::ORB_init (argc, + argv, + 0, + ACE_TRY_ENV); ACE_TRY_CHECK; - int result = parse_args (argc, argv); if (result != 0) return result; - + // Obtain the RootPOA. CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA"); // Get the POA_var object from Object_var. PortableServer::POA_var root_poa = - PortableServer::POA::_narrow (obj.in (), ACE_TRY_ENV); + PortableServer::POA::_narrow (obj.in (), + ACE_TRY_ENV); ACE_TRY_CHECK; - + // Get the POAManager of the RootPOA. PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (ACE_TRY_ENV); @@ -163,12 +163,14 @@ main (int argc, char **argv) // Id Assignment Policy policies[0] = - root_poa->create_id_assignment_policy (PortableServer::USER_ID, ACE_TRY_ENV); + root_poa->create_id_assignment_policy (PortableServer::USER_ID, + ACE_TRY_ENV); ACE_TRY_CHECK; // Lifespan policy policies[1] = - root_poa->create_lifespan_policy (PortableServer::PERSISTENT, ACE_TRY_ENV); + root_poa->create_lifespan_policy (PortableServer::PERSISTENT, + ACE_TRY_ENV); ACE_TRY_CHECK; // Create the firstPOA under the RootPOA. @@ -179,7 +181,7 @@ main (int argc, char **argv) policies, ACE_TRY_ENV); ACE_TRY_CHECK; - + // Create the secondPOA under the firstPOA. name = "secondPOA"; PortableServer::POA_var second_poa = @@ -187,45 +189,48 @@ main (int argc, char **argv) poa_manager.in (), policies, ACE_TRY_ENV); - + ACE_TRY_CHECK; + // Creation of POAs is over. Destroy the Policy objects. for (CORBA::ULong i = 0; - i < policies.length () && ACE_TRY_ENV.exception () == 0; + i < policies.length (); ++i) { - CORBA::Policy_ptr policy = policies[i]; - policy->destroy (ACE_TRY_ENV); + policies[i]->destroy (ACE_TRY_ENV); + ACE_TRY_CHECK; } - // Create two Objects of Class MyFooServant (defined in // ./../GenericServant/MyFooServant.h) Create one object at RootPOA // and the other at firstPOA. - MyFooServant first_foo_impl (orb.in (), root_poa.in (), 27); - MyFooServant second_foo_impl (orb.in (), first_poa.in (), 28); - + MyFooServant first_foo_impl (orb.in (), + root_poa.in (), + 27); + MyFooServant second_foo_impl (orb.in (), + first_poa.in (), + 28); + // Do "activate_object" to activate the first_foo_impl object. It // returns ObjectId for that object. Operation Used : - // ObjectId activate_object( in Servant p_servant) + // ObjectId activate_object(in Servant p_servant) // raises (ServantAlreadyActive, WrongPolicy); PortableServer::ObjectId_var first_oid = - root_poa->activate_object (&first_foo_impl, ACE_TRY_ENV); + root_poa->activate_object (&first_foo_impl, + ACE_TRY_ENV); ACE_TRY_CHECK; - - + // Get Object Reference for the first_foo_impl object. Foo_var first_foo = first_foo_impl._this (ACE_TRY_ENV); ACE_TRY_CHECK; - - + // Get ObjectId for object secondFoo and use that ObjectId to // activate the second_foo_impl object. // Operation Used : - // void activate_object_with_id( in ObjectId oid, in Servant p_servant) + // void activate_object_with_id(in ObjectId oid, in Servant p_servant) // raises (ObjectAlreadyActive, ServantAlreadyActive, WrongPolicy); PortableServer::ObjectId_var second_oid = PortableServer::string_to_ObjectId ("secondFoo"); - + first_poa->activate_object_with_id (second_oid.in (), &second_foo_impl, ACE_TRY_ENV); @@ -235,7 +240,6 @@ main (int argc, char **argv) Foo_var second_foo = second_foo_impl._this (ACE_TRY_ENV); ACE_TRY_CHECK; - // Get ObjectId for the string thirdPOA Create the object reference // for thirdPOA using that ObjectId. Operation Used : // Object create_reference_with_id (in ObjectId oid, in CORBA::RepositoryId intf ); @@ -245,62 +249,58 @@ main (int argc, char **argv) PortableServer::ObjectId_var third_oid = PortableServer::string_to_ObjectId ("thirdFoo"); */ - + // This will test how the POA handles a user given ID PortableServer::ObjectId_var third_oid = PortableServer::string_to_ObjectId ("third Foo"); third_oid[5] = (CORBA::Octet) '\0'; - + CORBA::Object_var third_foo = second_poa->create_reference_with_id (third_oid.in (), - "IDL:Foo:1.0", ACE_TRY_ENV); + "IDL:Foo:1.0", + ACE_TRY_ENV); ACE_TRY_CHECK; - // Stringyfy all the object references and print them out. CORBA::String_var first_ior = orb->object_to_string (first_foo.in (), ACE_TRY_ENV); ACE_TRY_CHECK; - CORBA::String_var second_ior = orb->object_to_string (second_foo.in (), ACE_TRY_ENV); ACE_TRY_CHECK; - - + CORBA::String_var third_ior = orb->object_to_string (third_foo.in (), ACE_TRY_ENV); ACE_TRY_CHECK; - ACE_DEBUG ((LM_DEBUG, "%s\n%s\n%s\n", first_ior.in (), second_ior.in (), third_ior.in ())); - + int write_result = write_iors_to_file (first_ior.in (), - second_ior.in (), - third_ior.in ()); + second_ior.in (), + third_ior.in ()); if (write_result != 0) return write_result; - // Activate thirdPOA using its ObjectID. + // Activate third servant using its ObjectID. MyFooServant third_foo_impl (orb.in (), second_poa.in (), 29); second_poa->activate_object_with_id (third_oid.in (), &third_foo_impl, ACE_TRY_ENV); ACE_TRY_CHECK; - + poa_manager->activate (ACE_TRY_ENV); ACE_TRY_CHECK; - if (orb->run () == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "CORBA::ORB::run"), -1); - // Destroy RootPOA. ( Also destroys firstPOA) + // Destroy RootPOA (also destroys all child POAs). root_poa->destroy (1, 1, ACE_TRY_ENV); @@ -316,6 +316,6 @@ main (int argc, char **argv) } ACE_ENDTRY; ACE_CHECK_RETURN (-1); - + return 0; } |