2 //=============================================================================
3 // File : SALOME_Container.cxx
4 // Created : jeu jui 12 08:04:40 CEST 2001
5 // Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA
7 // Copyright : EDF 2001 - CEA 2001
9 //=============================================================================
13 # include "Utils_ORB_INIT.hxx"
14 # include "Utils_SINGLETON.hxx"
16 #include "SALOME_Container_i.hxx"
19 #include "utilities.h"
23 static PyMethodDef MethodPyVoidMethod[] = {
27 int main(int argc, char* argv[])
33 PySys_SetArgv( argc , argv ) ;
34 Py_InitModule( "InitPyRunMethod" , MethodPyVoidMethod ) ;
38 // Initialise the ORB.
39 // CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
40 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
41 ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
42 CORBA::ORB_var &orb = init( argc , argv ) ;
44 // Obtain a reference to the root POA.
45 CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
46 PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
48 // obtain the root poa manager
49 PortableServer::POAManager_var pman = root_poa->the_POAManager();
51 // define policy objects
52 PortableServer::ImplicitActivationPolicy_var implicitActivation =
53 root_poa->create_implicit_activation_policy(PortableServer::NO_IMPLICIT_ACTIVATION) ;
55 // default = NO_IMPLICIT_ACTIVATION
56 PortableServer::ThreadPolicy_var threadPolicy =
57 root_poa->create_thread_policy(PortableServer::ORB_CTRL_MODEL) ;
58 // default = ORB_CTRL_MODEL, other choice SINGLE_THREAD_MODEL
61 CORBA::PolicyList policyList;
63 policyList[0] = PortableServer::ImplicitActivationPolicy::_duplicate(implicitActivation) ;
64 policyList[1] = PortableServer::ThreadPolicy::_duplicate(threadPolicy) ;
66 // create the child POA
67 PortableServer::POAManager_var nil_mgr = PortableServer::POAManager::_nil() ;
68 PortableServer::POA_var factory_poa =
69 root_poa->create_POA("factory_poa", pman, policyList) ;
70 //with nil_mgr instead of pman, a new POA manager is created with the new POA
72 // destroy policy objects
73 implicitActivation->destroy() ;
74 threadPolicy->destroy() ;
76 char *containerName = "";
79 containerName = argv[1] ;
82 Engines_Container_i * myContainer
83 = new Engines_Container_i(orb, factory_poa, containerName , argc , argv );
85 // Engines_Container_i * myContainer
86 // = new Engines_Container_i(string(argv[1]),string(argv[2]), orb, factory_poa);
89 // myContainer->_NS.init_orb(orb);
90 // Engines::Container_ptr pCont = Engines::Container::_narrow(myContainer->_this());
91 // myContainer->_NS.Register(pCont, argv[2]);
99 catch(CORBA::SystemException&)
101 INFOS("Caught CORBA::SystemException.")
103 catch(PortableServer::POA::WrongPolicy&)
105 INFOS("Caught CORBA::WrongPolicyException.")
107 catch(PortableServer::POA::ServantAlreadyActive&)
109 INFOS("Caught CORBA::ServantAlreadyActiveException")
111 catch(CORBA::Exception&)
113 INFOS("Caught CORBA::Exception.")
117 INFOS("Caught unknown exception.")