1 // SALOME Container : implementation of container and engine for Kernel
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SALOME_Container.cxx
25 // Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA
33 # include "Utils_ORB_INIT.hxx"
34 # include "Utils_SINGLETON.hxx"
36 #include "SALOME_Container_i.hxx"
39 #include "utilities.h"
43 #include <Utils_Timer.hxx>
48 static PyMethodDef MethodPyVoidMethod[] = {
52 int main(int argc, char* argv[])
58 PySys_SetArgv( argc , argv ) ;
59 Py_InitModule( "InitPyRunMethod" , MethodPyVoidMethod ) ;
63 // Initialise the ORB.
64 // CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
65 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
66 ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
67 CORBA::ORB_var &orb = init( argc , argv ) ;
69 // Obtain a reference to the root POA.
70 CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
71 PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
73 // obtain the root poa manager
74 PortableServer::POAManager_var pman = root_poa->the_POAManager();
76 // define policy objects
77 PortableServer::ImplicitActivationPolicy_var implicitActivation =
78 root_poa->create_implicit_activation_policy(PortableServer::NO_IMPLICIT_ACTIVATION) ;
80 // default = NO_IMPLICIT_ACTIVATION
81 PortableServer::ThreadPolicy_var threadPolicy =
82 root_poa->create_thread_policy(PortableServer::ORB_CTRL_MODEL) ;
83 // default = ORB_CTRL_MODEL, other choice SINGLE_THREAD_MODEL
86 CORBA::PolicyList policyList;
88 policyList[0] = PortableServer::ImplicitActivationPolicy::_duplicate(implicitActivation) ;
89 policyList[1] = PortableServer::ThreadPolicy::_duplicate(threadPolicy) ;
91 // create the child POA
92 PortableServer::POAManager_var nil_mgr = PortableServer::POAManager::_nil() ;
93 PortableServer::POA_var factory_poa =
94 root_poa->create_POA("factory_poa", pman, policyList) ;
95 //with nil_mgr instead of pman, a new POA manager is created with the new POA
97 // destroy policy objects
98 implicitActivation->destroy() ;
99 threadPolicy->destroy() ;
101 char *containerName = "";
104 containerName = argv[1] ;
107 Engines_Container_i * myContainer
108 = new Engines_Container_i(orb, factory_poa, containerName , argc , argv );
110 // Engines_Container_i * myContainer
111 // = new Engines_Container_i(string(argv[1]),string(argv[2]), orb, factory_poa);
113 // use naming service
114 // myContainer->_NS.init_orb(orb);
115 // Engines::Container_ptr pCont = Engines::Container::_narrow(myContainer->_this());
116 // myContainer->_NS.Register(pCont, argv[2]);
124 MESSAGE("SALOME_Registry_Server.cxx - orb->run()");
125 timer.ShowAbsolute();
131 catch(CORBA::SystemException&)
133 INFOS("Caught CORBA::SystemException.")
135 catch(PortableServer::POA::WrongPolicy&)
137 INFOS("Caught CORBA::WrongPolicyException.")
139 catch(PortableServer::POA::ServantAlreadyActive&)
141 INFOS("Caught CORBA::ServantAlreadyActiveException")
143 catch(CORBA::Exception&)
145 INFOS("Caught CORBA::Exception.")
149 INFOS("Caught unknown exception.")