2 #include "tao/PortableServer/LifespanStrategyPersistent.h"
3 #include "tao/PortableServer/Root_POA.h"
4 #include "tao/PortableServer/POAManager.h"
5 #include "tao/PortableServer/ImR_Client_Adapter.h"
6 #include "tao/ORB_Core.h"
7 #include "ace/OS_NS_sys_time.h"
8 #include "ace/Dynamic_Service.h"
9 #include "ace/Service_Config.h"
11 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
15 namespace Portable_Server
18 LifespanStrategyPersistent::strategy_init (TAO_Root_POA
*poa
)
20 LifespanStrategy::strategy_init (poa
);
22 this->use_imr_
= this->poa_
->orb_core ().use_implrepo ();
26 LifespanStrategyPersistent::validate (
27 CORBA::Boolean is_persistent
,
28 const TAO::Portable_Server::Temporary_Creation_Time
& /*creation_time*/) const
34 LifespanStrategyPersistent::key_type () const
40 LifespanStrategyPersistent::is_persistent () const
46 LifespanStrategyPersistent::create_key (
48 CORBA::ULong
& starting_at
)
50 // Copy the persistence byte.
51 buffer
[starting_at
] = static_cast<CORBA::Octet
> (this->key_type ());
52 starting_at
+= this->key_type_length ();
56 LifespanStrategyPersistent::key_length () const
58 return this->key_type_length ();
62 LifespanStrategyPersistent::notify_startup ()
66 // The user specified that the ImR should be used.
67 ImR_Client_Adapter
*adapter
=
68 ACE_Dynamic_Service
<ImR_Client_Adapter
>::instance (
69 TAO_Root_POA::imr_client_adapter_name ());
71 #if !defined (TAO_AS_STATIC_LIBS)
72 // In case we build shared, try to load the ImR Client library, in a
73 // static build we just can't do this, so don't try it, lower layers
74 // output an error then.
77 ACE_Service_Config::process_directive (
78 ACE_DYNAMIC_VERSIONED_SERVICE_DIRECTIVE(
79 "ImR_Client_Adapter", "TAO_ImR_Client", TAO_VERSION
,
80 "_make_ImR_Client_Adapter_Impl", ""));
83 ACE_Dynamic_Service
<ImR_Client_Adapter
>::instance (
84 TAO_Root_POA::imr_client_adapter_name ());
86 #endif /* !TAO_AS_STATIC_LIBS */
90 adapter
->imr_notify_startup (this->poa_
);
94 // When we don't have a ImR_Client adapter, but the user
95 // has specified that the ImR has to be used we have an
96 // error situation which has to be reported.
97 TAOLIB_ERROR ((LM_ERROR
,
98 ACE_TEXT ("(%P|%t) ERROR: No ImR_Client library ")
99 ACE_TEXT ("available but use IMR has been specified.\n")));
101 throw ::CORBA::INTERNAL ();
107 LifespanStrategyPersistent::notify_shutdown ()
109 ImR_Client_Adapter
*adapter
=
110 ACE_Dynamic_Service
<ImR_Client_Adapter
>::instance (
111 TAO_Root_POA::imr_client_adapter_name ());
115 adapter
->imr_notify_shutdown (this->poa_
);
119 LifespanStrategyPersistent::LifespanStrategyPersistent () :
125 LifespanStrategyPersistent::check_state ()
127 this->poa_
->tao_poa_manager().check_state ();
131 LifespanStrategyPersistent::use_imr () const
137 LifespanStrategyPersistent::imr_key_to_object (const TAO::ObjectKey
&key
,
138 const char *type_id
) const
143 return CORBA::Object::_nil ();
146 // The user specified that the ImR should be used.
147 ImR_Client_Adapter
*adapter
=
148 ACE_Dynamic_Service
<ImR_Client_Adapter
>::instance (
149 TAO_Root_POA::imr_client_adapter_name ());
152 // couldn't load adapter, already reported error
153 return CORBA::Object::_nil ();
156 return adapter
->imr_key_to_object (this->poa_
, key
, type_id
);
159 } /* namespace Portable_Server */
160 } /* namespace TAO */
163 TAO_END_VERSIONED_NAMESPACE_DECL