Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #include "ApplicationServer.hpp"
00040 #include "../../Logger.hpp"
00041
00042 #if defined( CORBA_IS_TAO ) && defined( CORBA_TAO_HAS_MESSAGING )
00043 #include <tao/TimeBaseC.h>
00044 #include <tao/Messaging/Messaging.h>
00045 #endif
00046
00047 namespace RTT
00048 {namespace corba
00049 {
00050
00051 CORBA::ORB_var ApplicationServer::orb;
00052
00053 PortableServer::POA_var ApplicationServer::rootPOA;
00054
00055 RTT_CORBA_API bool ApplicationServer::InitOrb(int argc, char* argv[], Seconds timeout ) {
00056 if ( !CORBA::is_nil(orb) )
00057 return false;
00058
00059 try {
00060
00061 orb =
00062 CORBA::ORB_init (argc, const_cast<char**>(argv),
00063 "omniORB4");
00064 if(timeout >= 0.1e-7)
00065 {
00066 #if defined( CORBA_IS_TAO ) && defined( CORBA_TAO_HAS_MESSAGING )
00067
00068
00069 TimeBase::TimeT relative_rt_timeout = timeout * 1.0e7;
00070 CORBA::Any relative_rt_timeout_as_any;
00071 relative_rt_timeout_as_any <<= relative_rt_timeout;
00072
00073
00074 CORBA::PolicyList policies;
00075 policies.length(1);
00076 policies[0] =
00077 orb->create_policy (Messaging::RELATIVE_RT_TIMEOUT_POLICY_TYPE,
00078 relative_rt_timeout_as_any);
00079
00080
00081 CORBA::Object_var obj = orb->resolve_initial_references ("ORBPolicyManager");
00082 CORBA::PolicyManager_var policy_manager = CORBA::PolicyManager::_narrow (obj.in());
00083 policy_manager->set_policy_overrides (policies, CORBA::SET_OVERRIDE);
00084 #else
00085 log(Error) << "Ignoring ORB timeout setting in non-TAO/Messaging build." <<endlog();
00086 #endif // CORBA_IS_TAO
00087 }
00088
00089 CORBA::Object_var poa_object =
00090 orb->resolve_initial_references ("RootPOA");
00091 rootPOA =
00092 PortableServer::POA::_narrow (poa_object.in ());
00093 PortableServer::POAManager_var poa_manager =
00094 rootPOA->the_POAManager ();
00095 poa_manager->activate ();
00096
00097 return true;
00098 }
00099 catch (CORBA::Exception &e) {
00100 log(Error) << "Orb Init : CORBA exception raised!" << Logger::nl;
00101 Logger::log() << CORBA_EXCEPTION_INFO(e) << endlog();
00102 }
00103 return false;
00104 }
00105
00106 }}