Merge pull request #2303 from jwillemsen/jwi-803
[ACE_TAO.git] / TAO / orbsvcs / ImplRepo_Service / Adapter_Activator.cpp
blob92a7caac5ede410872b357e2daa3ce7fc206ed6c
1 // -*- C++ -*-
2 //=============================================================================
3 /**
4 * @file Adapter_Activator.cpp
6 * @author Darrell Brunsch <brunsch@cs.wustl.edu>
7 */
8 //=============================================================================
10 #include "Adapter_Activator.h"
12 #include "orbsvcs/Log_Macros.h"
13 #include "tao/PortableServer/Servant_Base.h"
15 ImR_Adapter::ImR_Adapter ()
16 : default_servant_ (0)
20 void
21 ImR_Adapter::init (TAO_ServantBase * servant)
23 default_servant_ = servant;
26 CORBA::Boolean
27 ImR_Adapter::unknown_adapter (PortableServer::POA_ptr parent,
28 const char *name)
30 ACE_ASSERT (! CORBA::is_nil(parent));
31 ACE_ASSERT (name != 0);
32 CORBA::PolicyList policies (3);
34 const char *exception_message = "Null Message";
35 policies.length (3);
36 try
38 // Servant Retention Policy
39 exception_message = "While PortableServer::POA::create_servant_retention_policy";
40 policies[0] =
41 parent->create_servant_retention_policy (PortableServer::NON_RETAIN);
43 // Request Processing Policy
44 exception_message = "While PortableServer::POA::create_request_processing_policy";
46 policies[1] =
47 parent->create_request_processing_policy (PortableServer::USE_DEFAULT_SERVANT);
48 policies[2] =
49 parent->create_id_uniqueness_policy (PortableServer::MULTIPLE_ID);
51 PortableServer::POAManager_var poa_manager =
52 parent->the_POAManager ();
54 exception_message = "While create_POA";
55 PortableServer::POA_var child =
56 parent->create_POA (name,
57 poa_manager.in (),
58 policies);
60 exception_message = "While policy->destroy";
61 for (CORBA::ULong i = 0; i < policies.length (); ++i)
63 CORBA::Policy_ptr policy = policies[i];
64 policy->destroy ();
67 exception_message = "While child->the_activator";
68 child->the_activator (this);
70 exception_message = "While set_servant";
71 child->set_servant (this->default_servant_);
73 catch (const CORBA::Exception& ex)
75 ORBSVCS_ERROR ((LM_ERROR,
76 "IMR_Adapter_Activator::unknown_adapter - %C\n",
77 exception_message));
78 ex._tao_print_exception ("System Exception");
79 return 0;
82 // Finally, now everything is fine
83 return 1;