29 # include <iostream.h>
49 CORBA::release(curr->first);
57 assert(!CORBA::is_nil(
_orb));
59 const char* action=
"";
62 CORBA::Object_var obj;
64 action=
"resolve initial reference 'RootPOA'";
65 obj=
_orb->resolve_initial_references(
"RootPOA");
66 _RootPOA=PortableServer::POA::_narrow(obj);
68 throw CORBA::OBJECT_NOT_EXIST();
70 action=
"resolve initial reference 'omniINSPOA'";
71 obj=
_orb->resolve_initial_references(
"omniINSPOA");
74 throw CORBA::OBJECT_NOT_EXIST();
79 action=
"resolve initial reference 'NameService'";
80 obj=
_orb->resolve_initial_references(
"NameService");
83 catch(CORBA::Exception& ex)
85 DB(1,
"Warning - failed to "<<action<<
90 action=
"resolve initial reference 'POACurrent'";
91 obj=
_orb->resolve_initial_references(
"POACurrent");
92 _POACurrent=PortableServer::Current::_narrow(obj);
93 if(CORBA::is_nil(_POACurrent))
94 throw CORBA::OBJECT_NOT_EXIST();
99 catch(CORBA::ORB::InvalidName& ex)
101 DB(0,
"Failed to "<<action<<
". InvalidName")
103 catch(CORBA::TRANSIENT& ex)
105 DB(0,
"Failed to "<<action<<
". TRANSIENT")
107 catch(CORBA::OBJECT_NOT_EXIST& ex)
109 DB(0,
"Failed to "<<action<<
". OBJECT_NOT_EXIST")
111 catch(CORBA::SystemException& ex)
113 DB(0,
"Failed to "<<action<<
"."
116 catch(CORBA::Exception& ex)
118 DB(0,
"Failed to "<<action<<
"." IF_OMNIORB4(
" "<<ex._name()) )
128 omni_thread::sleep(5);
130 list<Callback*> usedCallbacks;
138 if(curr->first->poll_response())
140 CORBA::Environment_ptr env=curr->first->env();
141 if(!CORBA::is_nil(env) && env->exception())
143 CORBA::Exception* ex =env->exception();
144 DB(10,
"Deferred call to "<<curr->first->operation()
145 <<
"() got exception" IF_OMNIORB4(<<
": "<<ex->_name()))
147 else if(curr->second)
149 DB(15,
"Deferred call to "<<curr->first->operation()<<
"() returned.")
150 curr->second->callback(curr->first);
154 DB(15,
"Orphan call to "<<curr->first->operation()<<
"() returned.")
156 CORBA::release(curr->first);
158 usedCallbacks.push_back( curr->second );
167 while(!usedCallbacks.empty())
169 usedCallbacks.front()->_remove_ref();
170 usedCallbacks.pop_front();
198 callback->_add_ref();
206 CORBA::Object_ptr obj,
210 assert(!CORBA::is_nil(obj));
215 omniORB::logger log(
"omniEvents! Object failure: ");
216 omniIOR* ior =obj->_PR_getobj()->_getIOR();
218 log<<ior->repositoryID();
220 for(CORBA::ULong i=0; i<ior->iopProfiles().length(); i++)
222 if (ior->iopProfiles()[i].tag == IOP::TAG_INTERNET_IOP)
224 IIOP::ProfileBody pBody;
225 IIOP::unmarshalProfile(ior->iopProfiles()[i],pBody);
227 for(CORBA::ULong j=0; j<pBody.object_key.length(); ++j)
229 char c=(char)pBody.object_key[j];
230 log<<( (c>=
' '&&c<=
'~')? c:
'.' );
232 log<<
"\" at "<<(
const char*)pBody.address.host<<
":"<<pBody.address.port;
239 log<<
" threw unknown exception\n";
243 log<<
" threw "<<ex->_name();
244 CORBA::SystemException* sysex =CORBA::SystemException::_downcast(ex);
252 omniORB::logger log(
"omniEvents! Object failure detail: ");
253 CORBA::String_var sior(
Orb::inst().
_orb->object_to_string(obj) );
254 log<<sior<<
" at "<<here<<
"\n";
#define IFELSE_OMNIORB4(omniORB4_code, default_code)
#define IF_OMNIORB4(omniORB4_code)
#define NP_MINORSTRING(systemException)
Interface for classes that wish to receive callbacks from deferred requests.
PortableServer::POA_var _RootPOA
pair< CORBA::Request_ptr, Callback * > RequestCallback_t
~Orb()
Destructor needs to be public to keep MS VC++6 happy.
list< RequestCallback_t > _deferredRequests
CosNaming::NamingContext_var _NameService
void deferredRequest(CORBA::Request_ptr req, Callback *callback=NULL)
Adopts the request and then stores it in _deferredRequests.
void reportObjectFailure(const char *here, CORBA::Object_ptr obj, CORBA::Exception *ex)
Called by omniEvents when an object has failed (fatal exception).
void resolveInitialReferences()
_orb must already have been initialized before this method is called.
omni_mutex _deferredRequestsLock
void run()
Parks the main thread, but also picks up (and ignores) responses from orphan requests.
PortableServer::POA_var _omniINSPOA