${CMAKE_CURRENT_SOURCE_DIR}/../Notification
${CMAKE_CURRENT_SOURCE_DIR}/../Container
${CMAKE_CURRENT_SOURCE_DIR}/../ResourcesManager
+ ${CMAKE_CURRENT_SOURCE_DIR}/../SALOMESDS
${PROJECT_BINARY_DIR}/idl
)
SET(SALOME_LauncherServer_LIBS
Launcher
SalomeLauncher
+ SalomeSDS
SALOMEBasics
SALOMELocalTrace
${LIBBATCH_LIBRARIES}
//
#include "SALOME_Launcher.hxx"
+#include "SALOMESDS_DataServerManager.hxx"
#include "utilities.h"
#include <sstream>
#include <iostream>
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.");
#include "Utils_ORB_INIT.hxx"
#include "Utils_SINGLETON.hxx"
#include "Basics_Utils.hxx"
+#include "utilities.h"
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
-#include "utilities.h"
#include "Utils_Mutex.hxx"
#include "ServiceUnreachable.hxx"
#include "Utils_SINGLETON.hxx"
#include "Basics_Utils.hxx"
#include "SALOME_LifeCycleCORBA.hxx"
+#include "utilities.h"
#include <iostream>
#include <fstream>
#include "SALOMEDSImpl_Study.hxx"
#include "Utils_ORB_INIT.hxx"
-#include "Utils_SINGLETON.hxx"
+#include "Utils_SINGLETON.hxx"
+#include "utilities.h"
#include "Basics_Utils.hxx"
${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
#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
{
#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"
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)
{
}
}
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);
}
/*!
}
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
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;
+}
#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"
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;
};
#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)
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();
+}
#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"
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;
};
}
#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
{