=default for generated implementation copy ctor
[ACE_TAO.git] / TAO / tao / CSD_Framework / CSD_Strategy_Base.cpp
blobc3e72d3ea5749301a1ecee0ba61712aaf1ba994e
1 // -*- C++ -*-
2 #include "tao/CSD_Framework/CSD_Strategy_Base.h"
3 #include "tao/CSD_Framework/CSD_POA.h"
4 #include "tao/CSD_Framework/CSD_Strategy_Proxy.h"
5 #include "tao/PortableServer/Root_POA.h"
6 #include "tao/PortableServer/POAManager.h"
7 #include "tao/PortableServer/Servant_Base.h"
8 #include "tao/TAO_Server_Request.h"
10 #if !defined (__ACE_INLINE__)
11 # include "tao/CSD_Framework/CSD_Strategy_Base.inl"
12 #endif /* ! __ACE_INLINE__ */
14 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
16 TAO::CSD::Strategy_Base::~Strategy_Base()
20 CORBA::Boolean
21 TAO::CSD::Strategy_Base::apply_to (PortableServer::POA_ptr poa)
23 if (CORBA::is_nil(poa))
25 if (TAO_debug_level > 0)
26 TAOLIB_ERROR((LM_ERROR,
27 ACE_TEXT("(%P|%t) CSD Strategy cannot ")
28 ACE_TEXT("be applied to a nil POA.\n")));
29 return false;
32 if (!CORBA::is_nil(this->poa_.in()))
34 if (TAO_debug_level > 0)
35 TAOLIB_ERROR((LM_ERROR,
36 ACE_TEXT("(%P|%t) CSD Strategy already ")
37 ACE_TEXT("applied to a POA.\n")));
38 return false;
41 // The POA is a local interface (IDL terminology), and thus we know that
42 // we can downcast the POA_ptr to its (TAO) implementation type.
43 TAO_CSD_POA* poa_impl = dynamic_cast<TAO_CSD_POA*>(poa);
45 if (poa_impl == 0)
47 if (TAO_debug_level > 0)
48 TAOLIB_ERROR((LM_ERROR,
49 ACE_TEXT("(%P|%t) CSD Strategy cannot ")
50 ACE_TEXT("be applied to a non CSD POA.\n")));
51 return false;
54 // We need to check to see if the POA is already "active". If this is
55 // the case, then we need to handle the poa_activated_event() right now.
56 // If the POA is not already "active", then we can just wait until it
57 // does get activated, and we (the strategy) will be informed of the
58 // poa_activated_event() at that time.
59 if (poa_impl->tao_poa_manager().get_state() ==
60 PortableServer::POAManager::ACTIVE)
62 // The POA is already "active" (since its POAManager is active).
63 // We need to "raise" the poa_activated_event() now. Otherwise,
64 // the event will be raised when the POAManager does become active.
65 if (!this->poa_activated_event( poa_impl->orb_core() ))
67 // An error has been already been reported to the log with
68 // the detailed reason for the failure to handle the event.
69 return false;
73 // Set the CSD Strategy_Base on the strategy proxy object owned by the POA.
74 bool strategy_set = false;
75 try
77 poa_impl->set_csd_strategy (this);
78 strategy_set = true;
80 catch (const ::CORBA::Exception&)
84 if (! strategy_set)
86 // We need to make sure that we raise a poa_deactivated_event() if
87 // we earlier raised a poa_activated_event().
88 this->poa_deactivated_event();
90 // An error has been already been reported to the log with
91 // the detailed reason why the proxy will not accept the
92 // custom strategy.
93 return false;
96 // Save a duplicate of the poa into our data member.
97 this->poa_ = PortableServer::POA::_duplicate (poa);
99 // Success
100 return true;
104 void
105 TAO::CSD::Strategy_Base::servant_activated_event_i
106 (PortableServer::Servant ,
107 const PortableServer::ObjectId&)
109 // do nothing.
113 void
114 TAO::CSD::Strategy_Base::servant_deactivated_event_i
115 (PortableServer::Servant,
116 const PortableServer::ObjectId&)
118 // do nothing.
121 TAO_END_VERSIONED_NAMESPACE_DECL