]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
LauncherServer hostes DataServerManager and default DataScopeServer.
authorAnthony Geay <anthony.geay@edf.fr>
Mon, 27 Oct 2014 14:14:45 +0000 (15:14 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Mon, 27 Oct 2014 14:14:45 +0000 (15:14 +0100)
14 files changed:
src/Launcher/CMakeLists.txt
src/Launcher/SALOME_LauncherServer.cxx
src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx
src/NamingService/SALOME_NamingService.hxx
src/NamingService/Test/NamingServiceTest.cxx
src/SALOMEDS/SALOMEDS_StudyManager.cxx
src/SALOMESDS/CMakeLists.txt
src/SALOMESDS/SALOMESDS_AnyDataServer.hxx
src/SALOMESDS/SALOMESDS_BasicDataServer.hxx
src/SALOMESDS/SALOMESDS_DataScopeServer.cxx
src/SALOMESDS/SALOMESDS_DataScopeServer.hxx
src/SALOMESDS/SALOMESDS_DataServerManager.cxx
src/SALOMESDS/SALOMESDS_DataServerManager.hxx
src/SALOMESDS/SALOMESDS_StringDataServer.hxx

index 4a14d049674c1517364dabcdea114709f13a49ee..9757df6b9fc27286140497cb1650554b416620d1 100755 (executable)
@@ -33,6 +33,7 @@ INCLUDE_DIRECTORIES(
   ${CMAKE_CURRENT_SOURCE_DIR}/../Notification
   ${CMAKE_CURRENT_SOURCE_DIR}/../Container
   ${CMAKE_CURRENT_SOURCE_DIR}/../ResourcesManager
+  ${CMAKE_CURRENT_SOURCE_DIR}/../SALOMESDS
   ${PROJECT_BINARY_DIR}/idl
 )
 
@@ -95,6 +96,7 @@ IF(NOT SALOME_LAUNCHER_ONLY)
   SET(SALOME_LauncherServer_LIBS
     Launcher
     SalomeLauncher
+    SalomeSDS
     SALOMEBasics
     SALOMELocalTrace
     ${LIBBATCH_LIBRARIES}
index 4bb4ecfd9d13c1e991c17c1bec5f92fb0893ac4e..b9ea0d7cf2054b832dde097006803c38292a93a7 100644 (file)
@@ -21,6 +21,7 @@
 //
 
 #include "SALOME_Launcher.hxx"
+#include "SALOMESDS_DataServerManager.hxx"
 #include "utilities.h"
 #include <sstream>
 #include <iostream>
@@ -85,18 +86,26 @@ int main(int argc, char* argv[])
     if(!CORBA::is_nil(obj))
       root_poa = PortableServer::POA::_narrow(obj);
     if(!CORBA::is_nil(root_poa))
-      pman = root_poa->the_POAManager();
+      {
+        pman = root_poa->the_POAManager();
+        pman->activate();
+      }
   }
   catch(CORBA::COMM_FAILURE&){
     MESSAGE( "Container: CORBA::COMM_FAILURE: Unable to contact the Naming Service" );
   }
-  try{
-    SALOME_Launcher *lServ=new SALOME_Launcher(orb,root_poa);
-    pman->activate();
-    lServ->_remove_ref();
-    orb->run();
-    orb->destroy();
-  }catch(CORBA::SystemException&){
+  try
+    {
+      SALOME_Launcher *lServ(new SALOME_Launcher(orb,root_poa));
+      lServ->_remove_ref();
+      //
+      SALOMESDS::DataServerManager *dsm(new SALOMESDS::DataServerManager(orb,root_poa));
+      dsm->_remove_ref();
+      //
+      orb->run();
+      orb->destroy();
+    }
+  catch(CORBA::SystemException&){
     MESSAGE("Caught CORBA::SystemException.");
   }catch(PortableServer::POA::WrongPolicy&){
     MESSAGE("Caught CORBA::WrongPolicyException.");
index f95cccdb953c944ab67f2814ac9d842fead800ad..a9805ca081d0158766fce9843c0e41b14cc4e581 100644 (file)
@@ -26,6 +26,7 @@
 #include "Utils_ORB_INIT.hxx"
 #include "Utils_SINGLETON.hxx"
 #include "Basics_Utils.hxx"
+#include "utilities.h"
 
 #include <iostream>
 #include <fstream>
index d6a53c28e2e6c138bd5421d827ec1292e03192df..07605c6f74e913737d9074589a85fecdcb384b3a 100644 (file)
@@ -35,7 +35,6 @@
 
 #include <vector>
 #include <string>
-#include "utilities.h"
 #include "Utils_Mutex.hxx"
 #include "ServiceUnreachable.hxx"
 
index 8f8cf52fc38eb0629458610c843c6af2687c8f04..456b9d617c286f1824abb9da419e4f5fa69fae21 100644 (file)
@@ -25,6 +25,7 @@
 #include "Utils_SINGLETON.hxx"
 #include "Basics_Utils.hxx"
 #include "SALOME_LifeCycleCORBA.hxx"
+#include "utilities.h"
 
 #include <iostream>
 #include <fstream>
index 3ffa83174d3350ddf8e389b3ce6eb8e657b330cd..ce80b264429d2560fa96eb8499563d1a0a79ad3f 100644 (file)
@@ -35,7 +35,8 @@
 #include "SALOMEDSImpl_Study.hxx"
 
 #include "Utils_ORB_INIT.hxx" 
-#include "Utils_SINGLETON.hxx" 
+#include "Utils_SINGLETON.hxx"
+#include "utilities.h" 
 
 #include "Basics_Utils.hxx"
 
index fa3169c1ea4b4c829f76359e5a3f97840175cfc2..96964389e9f3be8ad2bdc723cdea0e28ee4ca4b6 100644 (file)
@@ -22,11 +22,14 @@ INCLUDE_DIRECTORIES(
   ${OMNIORB_INCLUDE_DIR}
   ${PTHREAD_INCLUDE_DIR}
   ${PROJECT_BINARY_DIR}/idl
+  ${PROJECT_BINARY_DIR}/salome_adm
+  ${CMAKE_CURRENT_SOURCE_DIR}/../Utils
+  ${CMAKE_CURRENT_SOURCE_DIR}/../NamingService
 )
 
 ADD_DEFINITIONS(${OMNIORB_DEFINITIONS})
 
-SET(COMMON_LIBS SalomeIDLKernel ${OMNIORB_LIBRARIES})
+SET(COMMON_LIBS SalomeNS SalomeIDLKernel ${OMNIORB_LIBRARIES})
 
 SET(SalomeSDS_SOURCES
   SALOMESDS_Exception.cxx
index c535357af9100722c505f81d6b17e1eb20b7ad3f..bba349a1e2391768db7395ec6ce2d90970645575 100644 (file)
 #ifndef __SALOMESDS_ANYDATASERVER_HXX__
 #define __SALOMESDS_ANYDATASERVER_HXX__
 
-#include "SALOMESDS_BasicDataServer.hxx"
+#include "SALOMEconfig.h"
+#include CORBA_SERVER_HEADER(SALOME_SDS)
 
-#include "SALOME_SDS.hh"
-//#include CORBA_SERVER_HEADER(SALOME_SDS)
+#include "SALOMESDS_BasicDataServer.hxx"
 
 namespace SALOMESDS
 {
index 6ff19db7350e01f08718ff9ec13a766bae612e21..1a0b1ccff5f7c6c271b8293c4020bb8d13c6beab 100644 (file)
 #ifndef __SALOMESDS_BASICDATASERVER_HXX__
 #define __SALOMESDS_BASICDATASERVER_HXX__
 
-#include "SALOMESDS_AutoRefCountPtr.hxx"
-
-#include "SALOME_SDS.hh"
-//#include CORBA_SERVER_HEADER(SALOME_SDS)
+#include "SALOMEconfig.h"
+#include CORBA_SERVER_HEADER(SALOME_SDS)
 
 #include "SALOMESDS_RefCountServ.hxx"
 
index 969501947e08e65da3a3892fc9c4113c781e1a4e..5de47052fa4d231a93412e3c834727cdaad515fb 100644 (file)
@@ -28,7 +28,7 @@
 
 using namespace SALOMESDS;
 
-DataScopeServer::DataScopeServer(const std::string& scopeName):_name(scopeName)
+DataScopeServer::DataScopeServer(CORBA::ORB_ptr orb, const std::string& scopeName):_orb(CORBA::ORB::_duplicate(orb)),_name(scopeName)
 {
 }
 
@@ -59,7 +59,8 @@ SALOME::StringDataServer_ptr DataScopeServer::createGlobalStringVar(const char *
     }
   AutoRefCountPtr<StringDataServer> tmp(new StringDataServer(varNameCpp));
   _vars.push_back(DynamicCastSafe<StringDataServer,BasicDataServer>(tmp));
-  return tmp->_this();
+  CORBA::Object_var ret(activateWithDedicatedPOA(tmp));
+  return SALOME::StringDataServer::_narrow(ret);
 }
 
 /*!
@@ -77,7 +78,8 @@ SALOME::AnyDataServer_ptr DataScopeServer::createGlobalAnyVar(const char *varNam
     }
   AutoRefCountPtr<AnyDataServer> tmp(new AnyDataServer(varNameCpp));
   _vars.push_back(DynamicCastSafe<AnyDataServer,BasicDataServer>(tmp));
-  return tmp->_this();
+  CORBA::Object_var ret(activateWithDedicatedPOA(tmp));
+  return SALOME::AnyDataServer::_narrow(ret);
 }
 
 std::vector< std::string > DataScopeServer::getAllVarNames() const
@@ -89,3 +91,22 @@ std::vector< std::string > DataScopeServer::getAllVarNames() const
     ret[i]=(*it)->getVarNameCpp();
   return ret;
 }
+
+CORBA::Object_var DataScopeServer::activateWithDedicatedPOA(BasicDataServer *ds)
+{
+  CORBA::Object_var obj(_orb->resolve_initial_references("RootPOA"));
+  PortableServer::POA_var rootPoa;
+  if(!CORBA::is_nil(obj))
+    rootPoa=PortableServer::POA::_narrow(obj);
+  PortableServer::POAManager_var pman(rootPoa->the_POAManager());
+  CORBA::PolicyList policies;
+  policies.length(1);
+  PortableServer::ThreadPolicy_var threadPol(rootPoa->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL));
+  policies[0]=PortableServer::ThreadPolicy::_duplicate(threadPol);
+  PortableServer::POA_var poa(rootPoa->create_POA("SingleThPOA4SDS",pman,policies));
+  threadPol->destroy();
+  //
+  PortableServer::ObjectId_var id(poa->activate_object(ds));
+  CORBA::Object_var ret(poa->id_to_reference(id));
+  return ret;
+}
index 030b179893e867ee84e36c912d7f18cc53be04e1..e47d1fa2c2a9f4c0517015edc97dffe3b58a0d7c 100644 (file)
@@ -21,8 +21,8 @@
 #ifndef __SALOMESDS_DATASCOPEERVER_HXX__
 #define __SALOMESDS_DATASCOPEERVER_HXX__
 
-#include "SALOME_SDS.hh"
-//#include CORBA_SERVER_HEADER(SALOME_SDS)
+#include "SALOMEconfig.h"
+#include CORBA_SERVER_HEADER(SALOME_SDS)
 
 #include "SALOMESDS_AutoRefCountPtr.hxx"
 #include "SALOMESDS_RefCountServ.hxx"
@@ -37,14 +37,16 @@ namespace SALOMESDS
   class DataScopeServer : public RefCountServ, public virtual POA_SALOME::DataScopeServer
   {
   public:
-    DataScopeServer(const std::string& scopeName);
+    DataScopeServer(CORBA::ORB_ptr orb, const std::string& scopeName);
     DataScopeServer(const DataScopeServer& other);
     char *getScopeName();
     SALOME::StringDataServer_ptr createGlobalStringVar(const char *varName);
     SALOME::AnyDataServer_ptr createGlobalAnyVar(const char *varName);
   private:
     std::vector< std::string> getAllVarNames() const;
+    CORBA::Object_var activateWithDedicatedPOA(BasicDataServer *ds);
   private:
+    CORBA::ORB_var _orb;
     std::string _name;
     std::list< AutoRefCountPtr<BasicDataServer> > _vars;
   };
index 9931589696e0e5a54953f0364025f5703ba3d195..3be1d6e0537d07543c5ab9769f90837b1117ee27 100644 (file)
 #include "SALOMESDS_DataServerManager.hxx"
 #include "SALOMESDS_Exception.hxx"
 
+#include "SALOME_NamingService.hxx"
+
+#include <sstream>
+
 using namespace SALOMESDS;
 
-DataServerManager::DataServerManager():_dft_scope(new DataScopeServer(""))
+const char DataServerManager::NAME_IN_NS[]="/DataServerManager";
+
+const char DataServerManager::DFT_SCOPE_NAME_IN_NS[]="Default";
+
+DataServerManager::DataServerManager(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa):_dft_scope(new DataScopeServer(orb,DFT_SCOPE_NAME_IN_NS)),_orb(CORBA::ORB::_duplicate(orb))
 {
+  PortableServer::POAManager_var pman(poa->the_POAManager());
+  CORBA::PolicyList policies;
+  policies.length(1);
+  PortableServer::ThreadPolicy_var threadPol(poa->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL));
+  policies[0]=PortableServer::ThreadPolicy::_duplicate(threadPol);
+  _poa=poa->create_POA("SingleThPOA4SDS",pman,policies);
+  threadPol->destroy();
+  // activate this to be ready to be usable from NS.
+  PortableServer::ObjectId_var id(_poa->activate_object(this));
+  CORBA::Object_var obj(_poa->id_to_reference(id));
+  SALOME::DataServerManager_var obj2(SALOME::DataServerManager::_narrow(obj));
+  // publish Data server manager in NS
+  SALOME_NamingService ns(orb);
+  ns.Register(obj2,NAME_IN_NS);
+  // the default DataScopeServer object is the only one hosted by the current process
+  id=_poa->activate_object(_dft_scope);
+  obj=_poa->id_to_reference(id);
+  _ptr_dft_scope=SALOME::DataScopeServer::_narrow(obj);
+  _scopes.push_back(_dft_scope);
+  //
+  std::string fullNameInNS(CreateAbsNameInNSFromScopeName(DFT_SCOPE_NAME_IN_NS));
+  ns.Register(_ptr_dft_scope,fullNameInNS.c_str());
 }
 
 SALOME::DataScopeServer_ptr DataServerManager::getDefaultScope()
 {
-  
+  return SALOME::DataScopeServer::_duplicate(_ptr_dft_scope);
 }
 
 SALOME::DataScopeServer_ptr DataServerManager::createDataScope(const char *scopeName)
@@ -43,3 +73,9 @@ SALOME::DataScopeServer_ptr DataServerManager::retriveDataScope(const char *scop
 SALOME::DataScopeServer_ptr DataServerManager::removeDataScope(const char *scopeName)
 {
 }
+
+std::string DataServerManager::CreateAbsNameInNSFromScopeName(const std::string& scopeName)
+{
+  std::ostringstream oss; oss << NAME_IN_NS << "/" << scopeName;
+  return oss.str();
+}
index d0629c75ba32def80e66e49675098ff758cd8247..731739baaca3a813ad68a1f45c2dff36bc4e89bc 100644 (file)
@@ -21,8 +21,8 @@
 #ifndef __SALOMESDS_DATASERVERMANAGER_HXX__
 #define __SALOMESDS_DATASERVERMANAGER_HXX__
 
-#include "SALOME_SDS.hh"
-//#include CORBA_SERVER_HEADER(SALOME_SDS)
+#include "SALOMEconfig.h"
+#include CORBA_SERVER_HEADER(SALOME_SDS)
 
 #include "SALOMESDS_AutoRefCountPtr.hxx"
 #include "SALOMESDS_DataScopeServer.hxx"
@@ -37,14 +37,22 @@ namespace SALOMESDS
   class DataServerManager : public virtual POA_SALOME::DataServerManager
   {
   public:
-    DataServerManager();
+    DataServerManager(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa);
     SALOME::DataScopeServer_ptr getDefaultScope();
     SALOME::DataScopeServer_ptr createDataScope(const char *scopeName);
     SALOME::DataScopeServer_ptr retriveDataScope(const char *scopeName);
     SALOME::DataScopeServer_ptr removeDataScope(const char *scopeName);
+    static std::string CreateAbsNameInNSFromScopeName(const std::string& scopeName);
+  public:
+    static const char NAME_IN_NS[];
+    static const char DFT_SCOPE_NAME_IN_NS[];
   private:
     AutoRefCountPtr<DataScopeServer> _dft_scope;
+    SALOME::DataScopeServer_var _ptr_dft_scope;
     std::list< AutoRefCountPtr<DataScopeServer> > _scopes;
+    CORBA::ORB_var _orb;
+    //! single thread poa
+    PortableServer::POA_var _poa;
   };
 }
 
index 7b054f4a0ac2abe98c85e77abc5603a8feea1269..55f323d6aa3806040d1614bccaadce36bdd1d85d 100644 (file)
 #ifndef __SALOMESDS_STRINGDATASERVER_HXX__
 #define __SALOMESDS_STRINGDATASERVER_HXX__
 
-#include "SALOMESDS_BasicDataServer.hxx"
+#include "SALOMEconfig.h"
+#include CORBA_SERVER_HEADER(SALOME_SDS)
 
-#include "SALOME_SDS.hh"
-//#include CORBA_SERVER_HEADER(SALOME_SDS)
+#include "SALOMESDS_BasicDataServer.hxx"
 
 namespace SALOMESDS
 {