]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
PR : Embedded C++ Container in Session Server (Engines and Clients in a single proces...
authorprascle <prascle>
Mon, 15 Sep 2003 09:12:08 +0000 (09:12 +0000)
committerprascle <prascle>
Mon, 15 Sep 2003 09:12:08 +0000 (09:12 +0000)
bin/runSalome
bin/runSalome.py
src/Session/Makefile.in
src/Session/SALOME_Session_Server.cxx

index 0c88c8c98572c3e96da42930faf2c0c589462ca5..a41903406ca310a80493fa64ee40c404444b2cb0 100755 (executable)
@@ -8,7 +8,7 @@ export SMESH_ROOT_DIR=/Salome2/SMESH_install
 export SUPERV_ROOT_DIR=/Salome2/SUPERV_install
 export VISU_ROOT_DIR=/Salome2/VISU_install
 
-python -i runSalome.py --gui --modules=GEOM,SMESH,VISU,SUPERV,MED --xterm --containers=cpp,python --killall
+python -i runSalome.py --gui --modules=GEOM,SMESH,VISU,SUPERV,MED --xterm --containers=python --killall
 #python -i runSalome.py --gui --modules=GEOM,SMESH,VISU,SUPERV,MED --logger --xterm
 #python -i runSalome.py --modules=GEOM,SMESH,VISU,SUPERV,MED
 #python -i runSalome.py --help
index cc3a72b16cf2ef65ba86d4a0296ed9d9f207e1bf..67cacf59d6836751391cf0d5bf4e7061087c65ec 100755 (executable)
@@ -203,7 +203,7 @@ class SessionLoader(Server):
        CMD=CMD+['GUI']
 
 class SessionServer(Server):
-   CMD=['SALOME_Session_Server']
+   CMD=['SALOME_Session_Server','FactoryServer','-ORBInitRef','NameService=corbaname::localhost']
 
 class NotifyServer(Server):
    CMD=['notifd','-c','${KERNEL_ROOT_DIR}/share/salome/resources/channel.cfg -DFactoryIORFileName=/tmp/${LOGNAME}_rdifact.ior -DChannelIORFileName=/tmp/${LOGNAME}_rdichan.ior']
@@ -374,6 +374,10 @@ def startSalome():
 
   import SALOME
   session=clt.waitNS("/Kernel/Session",SALOME.Session)
+  
+  theComputer = os.getenv("HOSTNAME")
+  computerSplitName = theComputer.split('.')
+  theComputer = computerSplitName[0]
 
   #
   # Lancement Container C++ local
@@ -385,10 +389,6 @@ def startSalome():
          # Attente de la disponibilité du Container C++ local dans le Naming Service
          #
 
-         theComputer = os.getenv("HOSTNAME")
-         computerSplitName = theComputer.split('.')
-         theComputer = computerSplitName[0]
-
          clt.waitNS("/Containers/" + theComputer + "/FactoryServer")
 
   #
@@ -404,12 +404,11 @@ def startSalome():
        
          clt.waitNS("/Containers/" + theComputer + "/FactoryServerPy")
 
-  if with_container_superv:
-
-       #
-       # Lancement Container Supervision local
-       #
+  #
+  # Lancement Container Supervision local
+  #
 
+  if with_container_superv:
        ContainerSUPERVServer().run()
 
        #
@@ -426,7 +425,7 @@ def startSalome():
   #session.GetInterface()
 
   end_time = os.times()
-  print
+
   print "Start SALOME, elpased time : %5.1f seconds"% (end_time[4] - init_time[4])
 
   return clt
index cfeaf594583ea06da9d33dc00adff7f31d4078c1..a9f96cf638ccfe0cf70a703d97a14229f01c7f9c 100644 (file)
@@ -46,12 +46,12 @@ LIB_SRC=\
 # Executables targets
 BIN = SALOME_Session_Server
 BIN_SRC = 
-BIN_SERVER_IDL = SALOME_Session.idl
-BIN_CLIENT_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Component.idl SALOME_Registry.idl SALOME_ModuleCatalog.idl SALOME_Exception.idl
+BIN_SERVER_IDL = SALOME_Session.idl SALOME_Component.idl
+BIN_CLIENT_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Registry.idl SALOME_ModuleCatalog.idl SALOME_Exception.idl
 
 CPPFLAGS+=$(QT_MT_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES)
 CXXFLAGS+=$(OCC_CXXFLAGS)
-LDFLAGS+=$(QT_MT_LIBS) $(OCC_KERNEL_LIBS) $(OCC_OCAF_LIBS) $(OCC_VIEWER_LIBS) $(OCC_MODELER_LIBS) -lSalomeNS -lSalomeGUI -lSalomeObject -lSalomeLifeCycleCORBA -lqsplitterP -lOpUtil -lSalomeLoggerServer -lPlot2d
+LDFLAGS+=$(QT_MT_LIBS) $(OCC_KERNEL_LIBS) $(OCC_OCAF_LIBS) $(OCC_VIEWER_LIBS) $(OCC_MODELER_LIBS) -lSalomeContainer -lSalomeNS -lSalomeGUI -lSalomeObject -lSalomeLifeCycleCORBA -lqsplitterP -lRegistry -lSalomeNotification -lOpUtil -lSalomeLoggerServer -lPlot2d
 
 
 @CONCLUDE@
index a53193848d0b6819bb914a69d7a34ffc3debb0ca..36af98b6489b9e5277466debdc5dcd59b65ee9cb 100644 (file)
@@ -29,6 +29,7 @@
 # include "Utils_ORB_INIT.hxx"
 # include "Utils_SINGLETON.hxx"
 
+#include "SALOME_Container_i.hxx"
 #include <iostream>
 #include <unistd.h>
 using namespace std;
@@ -40,6 +41,12 @@ using namespace std;
 
 #include "SALOME_Session_i.hxx"
 
+#include <Python.h>
+static PyMethodDef MethodPyVoidMethod[] = {
+  { NULL,        NULL }
+};
+
+
 //! CORBA server for SALOME Session
 /*!
  *  SALOME_Session Server launches a SALOME session servant.
@@ -55,45 +62,114 @@ using namespace std;
 int main(int argc, char **argv)
 {
 
+  Py_Initialize() ;
+  PySys_SetArgv( argc , argv ) ;
+  Py_InitModule( "InitPyRunMethod" , MethodPyVoidMethod ) ;
+
+
   try
     {
+    // Initialise the ORB.
     ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
     ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
     CORBA::ORB_var &orb = init( argc , argv ) ;
 
+    // Obtain a reference to the root POA.
     CORBA::Object_var obj =orb->resolve_initial_references("RootPOA") ;
-    PortableServer::POA_var poa = PortableServer::POA::_narrow(obj) ;
+    PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj) ;
+
+    // -------------------------------------------------------------------------------
+    // ---- container
+
+    // define policy objects     
+    PortableServer::ImplicitActivationPolicy_var implicitActivation =
+      root_poa->create_implicit_activation_policy(PortableServer::NO_IMPLICIT_ACTIVATION) ;
+
+      // default = NO_IMPLICIT_ACTIVATION
+    PortableServer::ThreadPolicy_var threadPolicy =
+      root_poa->create_thread_policy(PortableServer::ORB_CTRL_MODEL) ;
+      // default = ORB_CTRL_MODEL, other choice SINGLE_THREAD_MODEL
+
+    // create policy list
+    CORBA::PolicyList policyList;
+    policyList.length(2);
+    policyList[0] = PortableServer::ImplicitActivationPolicy::_duplicate(implicitActivation) ;
+    policyList[1] = PortableServer::ThreadPolicy::_duplicate(threadPolicy) ;
+
+    // create the child POA
+    PortableServer::POAManager_var nil_mgr = PortableServer::POAManager::_nil() ;
+    // PortableServer::POA_var factory_poa =
+    //   root_poa->create_POA("factory_poa", pman, policyList) ;
+    PortableServer::POA_var factory_poa =
+      root_poa->create_POA("factory_poa", nil_mgr, policyList) ;
+    //with nil_mgr instead of pman, a new POA manager is created with the new POA
+    
+    // destroy policy objects
+    implicitActivation->destroy() ;
+    threadPolicy->destroy() ;
+
+    // servant : container
+
+    char *containerName = "";
+    if (argc >1) 
+    {
+       containerName = argv[1] ;
+    }
 
-    // servant
-    SALOME_Session_i * mySALOME_Session = new SALOME_Session_i(argc, argv, orb, poa) ;
-    PortableServer::ObjectId_var mySALOME_Sessionid = poa->activate_object(mySALOME_Session) ;
-    MESSAGE("poa->activate_object(mySALOME_Session)")
+    Engines_Container_i * myContainer 
+     = new Engines_Container_i(orb, factory_poa, containerName , argc , argv );
+
+    //PortableServer::ObjectId_var mySALOME_Containerid = factory_poa->activate_object(myContainer) ;
+    //MESSAGE("poa->activate_object(myContainer)");
+
+    // obtain the factory poa manager
+    PortableServer::POAManager_var pmanfac = factory_poa->the_POAManager();
+    pmanfac->activate() ;
+    MESSAGE("pmanfac->activate()")
+
+
+    // -------------------------------------------------------------------------------
+    // servant : session
+
+    //SALOME_Session_i * mySALOME_Session = new SALOME_Session_i(argc, argv, orb, factory_poa) ;
+    //PortableServer::ObjectId_var mySALOME_Sessionid = factory_poa->activate_object(mySALOME_Session) ;
+
+    SALOME_Session_i * mySALOME_Session = new SALOME_Session_i(argc, argv, orb, root_poa) ;
+    PortableServer::ObjectId_var mySALOME_Sessionid = root_poa->activate_object(mySALOME_Session) ;
+    MESSAGE("poa->activate_object(mySALOME_Session)");
 
     obj = mySALOME_Session->_this() ;
     CORBA::String_var sior(orb->object_to_string(obj)) ;
-
     mySALOME_Session->NSregister();
-
     mySALOME_Session->_remove_ref() ;
 
-    PortableServer::POAManager_var pman = poa->the_POAManager() ;
+    // obtain the root poa manager
+    PortableServer::POAManager_var pman = root_poa->the_POAManager();
     pman->activate() ;
     MESSAGE("pman->activate()")
 
     orb->run() ;
     orb->destroy() ;
     }
-    catch (CORBA::SystemException&)
+  catch (CORBA::SystemException&)
+    {
+      INFOS("Caught CORBA::SystemException.");
+    }
+  catch(PortableServer::POA::WrongPolicy&)
+    {
+      INFOS("Caught CORBA::WrongPolicyException.");
+    }
+  catch(PortableServer::POA::ServantAlreadyActive&)
     {
-      INFOS("Caught CORBA::SystemException.")
+      INFOS("Caught CORBA::ServantAlreadyActiveException");
     }
-    catch (CORBA::Exception&)
+  catch (CORBA::Exception&)
     {
-      INFOS("Caught CORBA::Exception.")
+      INFOS("Caught CORBA::Exception.");
     }
     catch (...)
     {
-      INFOS("Caught unknown exception.")
+      INFOS("Caught unknown exception.");
     }
   return 0 ;
 }