27 #ifdef HAVE_SYS_TYPES_H
28 # include <sys/types.h>
33 #elif defined(HAVE_PROCESS_H)
44 # include <iostream.h>
47 #ifdef HAVE_STD_IOSTREAM
55 PortableServer::POA_ptr poa,
56 const char* repositoryId
61 PortableServer::ObjectId_var oid =
62 PortableServer::string_to_ObjectId(oidStr.in());
64 CORBA::Object_var obj =
65 poa->create_reference_with_id(oid.in(),repositoryId);
67 assert(!CORBA::is_nil(obj));
74 static omni_mutex
mutex;
76 unsigned long sec,nsec;
77 omni_thread::get_time(&sec,&nsec);
80 omni_mutex_lock l(
mutex);
81 sprintf(buf,
"%lx.%d.%lx",++count,mypid,sec);
83 return CORBA::string_dup(buf);
92 #if OMNIEVENTS__DEBUG_SERVANT
93 # define OMNIEVENTS__ADDR "["<<long(this)<<"] "
94 int Servant::_objectCount =0;
96 # define OMNIEVENTS__ADDR
100 Servant::Servant(PortableServer::POA_ptr poa)
101 : _poa(PortableServer::POA::_duplicate(poa))
103 #if OMNIEVENTS__DEBUG_SERVANT
112 #if OMNIEVENTS__DEBUG_SERVANT
121 return PortableServer::POA::_duplicate(
_poa.in());
127 using namespace PortableServer;
128 CORBA::String_var poaName =
_poa->the_name();
132 ObjectId_var oid =string_to_ObjectId(oidStr);
133 _poa->activate_object_with_id(oid.in(),
this);
135 catch(CORBA::BAD_PARAM& ex)
137 DB(0,
"Can't activate "<<oidStr<<
": "
141 catch(POA::ServantAlreadyActive& ex)
143 DB(0,
"Can't activate "<<oidStr<<
": Servant is already active.")
146 catch(POA::ObjectAlreadyActive& ex)
148 DB(0,
"Can't activate "<<oidStr<<
": Object is already active.")
151 catch(POA::WrongPolicy& ex)
153 DB(0,
"Can't activate "<<oidStr<<
": POA '"<<poaName.in()
154 <<
"' has wrong policy for activate_object_with_id().")
162 using namespace PortableServer;
163 CORBA::String_var poaName =
_poa->the_name();
168 oid=
_poa->servant_to_id(
this);
170 catch(POA::ServantNotActive& ex)
172 DB(0,
"Can't deactivate servant: POA '"<<poaName.in()
173 <<
"' says it is not active.")
176 catch(POA::WrongPolicy& ex)
178 DB(0,
"Can't deactivate servant: POA '"<<poaName.in()
179 <<
"' has wrong policy for servant_to_id().")
183 CORBA::String_var oidStr;
186 oidStr=ObjectId_to_string(oid.in());
188 catch(CORBA::BAD_PARAM& ex)
190 DB(0,
"Can't deactivate servant. ObjectId looks bad: "
198 _poa->deactivate_object(oid.in());
200 catch(POA::ObjectNotActive& ex)
202 DB(0,
"Can't deactivate "<<oidStr<<
": Object is not active.")
205 catch(POA::WrongPolicy& ex)
207 DB(0,
"Can't deactivate "<<oidStr<<
": POA '"<<poaName.in()
208 <<
"' has wrong policy for deactivate_object().")
#define IF_OMNIORB4(omniORB4_code)
#define NP_MINORSTRING(systemException)
CORBA::Object_ptr createReference(PortableServer::POA_ptr poa, const char *repositoryId)
Helper method called by createNarrowedReference().
char * newUniqueId()
Generates a unique object ID string, based upon the current PID and time.
virtual PortableServer::POA_ptr _default_POA()
PortableServer::POA_var _poa
void activateObjectWithId(const char *oidStr)
Calls activate_object_with_id() to activate this servant in its POA.
void deactivateObject()
Calls deactivate_object() to deactivate this servant in its POA.