LIST(APPEND _${PROJECT_NAME}_exposed_targets
DF SalomeLoggerServer with_loggerTraceCollector SalomeNS SalomeGenericObj
Registry SalomeCatalog ResourcesManager SalomeResourcesManager
- SalomeNotification SalomeContainer Launcher SalomeLauncher
+ SalomeNotification SalomeContainer SalomeSDS Launcher SalomeLauncher
SalomeLifeCycleCORBA SalomeDSClient TOOLSDS SalomeKernelHelpers
SalomeDSImpl SalomeDS SalomeCommunication SalomeDSCContainer)
# Temporary solution for package src\DSC on windows
SET(KERNEL_SalomeCatalog SalomeCatalog)
SET(KERNEL_SalomeCommunication SalomeCommunication)
SET(KERNEL_SalomeContainer SalomeContainer)
+SET(KERNEL_SalomeSDS SalomeSDS)
SET(KERNEL_SalomeDatastream SalomeDatastream)
SET(KERNEL_SalomeDSCContainer SalomeDSCContainer)
SET(KERNEL_SalomeDSClient SalomeDSClient)
any getValueOf();
};
+ interface DataServerManager;
+
interface DataScopeServer
{
string getScopeName();
BasicDataServer retrieveVar(in string varName);
StringDataServer createGlobalStringVar(in string varName);
AnyDataServer createGlobalAnyVar(in string varName);
+ void shutdownIfNotHostedByDSM();
};
interface DataServerManager
DataScopeServer createDataScope(in string scopeName);
DataScopeServer retriveDataScope(in string scopeName);
void removeDataScope(in string scopeName);
+ void shutdownScopes();
};
};
${CMAKE_CURRENT_SOURCE_DIR}/../Batch
${CMAKE_CURRENT_SOURCE_DIR}/../Notification
${CMAKE_CURRENT_SOURCE_DIR}/../Registry
+ ${CMAKE_CURRENT_SOURCE_DIR}/../SALOMESDS
${PROJECT_BINARY_DIR}/idl
)
SalomeContainer
SalomeResourcesManager
SalomeNS
+ SalomeSDS
OpUtil
SALOMELocalTrace
SALOMEBasics
#include "SALOME_LifeCycleCORBA.hxx"
#include "SALOME_ResourcesManager.hxx"
+#include "SALOMESDS_DataServerManager.hxx"
#include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog)
#include CORBA_CLIENT_HEADER(SALOME_Session)
#include CORBA_CLIENT_HEADER(DSC_Engines)
#include CORBA_CLIENT_HEADER(SALOME_Registry)
#include CORBA_CLIENT_HEADER(SALOMEDS)
+#include CORBA_CLIENT_HEADER(SALOME_SDS)
#include CORBA_CLIENT_HEADER(Logger)
#include CORBA_CLIENT_HEADER(SALOME_Launcher)
#ifndef WIN32
nanosleep(&ts_req,0);
#endif
+ // 4 ) Remote ScopeServer (the DataServer is hosted by SalomeLauncher shutdown right after)
+ try
+ {
+ CORBA::Object_var objDSM(_NS->Resolve(SALOMESDS::DataServerManager::NAME_IN_NS));
+ SALOME::DataServerManager_var dsm(SALOME::DataServerManager::_narrow(objDSM));
+ if ( !CORBA::is_nil(dsm) )
+ dsm->shutdownScopes();
+ }
+ catch(const CORBA::Exception& e)
+ {
+ // ignore and continue
+ }
- // 4) SalomeLauncher
+ // 5) SalomeLauncher
try
{
CORBA::Object_var objSL = _NS->Resolve("/SalomeLauncher");
nanosleep(&ts_req,0);
#endif
- // 5) Registry
+ // 6) Registry
try
{
CORBA::Object_var objR = _NS->Resolve("/Registry");
// ignore and continue
}
- /*
- // 6) Session
- if ( !CORBA::is_nil( session ) ) {
- try
- {
- session->Shutdown();
- }
- catch(const CORBA::Exception& e)
- {
- // ignore and continue
- }
- }
- */
-
// 7) Logger
int argc = 0;
char *xargv = (char*)"";
// Author : Anthony GEAY (EDF R&D)
#include "SALOMESDS_DataScopeServer.hxx"
+#include "SALOMESDS_DataServerManager.hxx"
#include "SALOMESDS_StringDataServer.hxx"
#include "SALOMESDS_AnyDataServer.hxx"
+#include "SALOME_NamingService.hxx"
#include "SALOMESDS_Exception.hxx"
#include <sstream>
{
}
-DataScopeServer::DataScopeServer(const DataScopeServer& other):RefCountServ(other),_name(other._name),_vars(other._vars)
+DataScopeServer::DataScopeServer(const DataScopeServer& other):_name(other._name),_vars(other._vars)
{
}
return SALOME::AnyDataServer::_narrow(ret);
}
+void DataScopeServer::shutdownIfNotHostedByDSM()
+{
+ SALOME_NamingService ns(_orb);
+ CORBA::Object_var obj(ns.Resolve(DataServerManager::NAME_IN_NS));
+ SALOME::DataServerManager_var dsm(SALOME::DataServerManager::_narrow(obj));
+ if(CORBA::is_nil(dsm))
+ return ;
+ // destroy ref in the naming service
+ std::string fullScopeName(SALOMESDS::DataServerManager::CreateAbsNameInNSFromScopeName(_name));
+ ns.Destroy_Name(fullScopeName.c_str());
+ // establish if dsm and this shared the same POA. If yes dsm and this are collocated !
+ PortableServer::ServantBase *ret(0);
+ try
+ {
+ ret=_poa->reference_to_servant(dsm);
+ }
+ catch(...) { ret=0; }
+ //
+ if(!ret)
+ _orb->shutdown(0);
+ else
+ ret->_remove_ref();
+}
+
+/*!
+ * \a ptr has been activated by the POA \a poa.
+ */
+void DataScopeServer::setPOAAndRegister(PortableServer::POA_var poa, SALOME::DataScopeServer_ptr ptr)
+{
+ _poa=poa;
+ std::string fullScopeName(SALOMESDS::DataServerManager::CreateAbsNameInNSFromScopeName(_name));
+ SALOME_NamingService ns(_orb);
+ ns.Register(ptr,fullScopeName.c_str());
+}
+
std::vector< std::string > DataScopeServer::getAllVarNames() const
{
std::size_t sz(_vars.size());
#include "SALOMEconfig.h"
#include CORBA_SERVER_HEADER(SALOME_SDS)
-#include "SALOMESDS_AutoRefCountPtr.hxx"
#include "SALOMESDS_RefCountServ.hxx"
+#include "SALOMESDS_AutoRefCountPtr.hxx"
#include "SALOMESDS_BasicDataServer.hxx"
#include <string>
namespace SALOMESDS
{
- class DataScopeServer : public RefCountServ, public virtual POA_SALOME::DataScopeServer
+ class DataScopeServer : public virtual POA_SALOME::DataScopeServer
{
public:
DataScopeServer(CORBA::ORB_ptr orb, const std::string& scopeName);
SALOME::BasicDataServer_ptr retrieveVar(const char *varName);
SALOME::StringDataServer_ptr createGlobalStringVar(const char *varName);
SALOME::AnyDataServer_ptr createGlobalAnyVar(const char *varName);
+ void shutdownIfNotHostedByDSM();
+ public:
+ void setPOAAndRegister(PortableServer::POA_var poa, SALOME::DataScopeServer_ptr ptr);
private:
std::vector< std::string> getAllVarNames() const;
CORBA::Object_var activateWithDedicatedPOA(BasicDataServer *ds);
private:
+ PortableServer::POA_var _poa;
CORBA::ORB_var _orb;
std::string _name;
std::list< std::pair< SALOME::BasicDataServer_var, AutoRefCountPtr<BasicDataServer> > > _vars;
#include "SALOME_NamingService.hxx"
#include <sstream>
+#include <algorithm>
using namespace SALOMESDS;
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))
+DataServerManager::DataServerManager(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa):_orb(CORBA::ORB::_duplicate(orb))
{
+ DataScopeServer *dftScope(new DataScopeServer(orb,DFT_SCOPE_NAME_IN_NS));//_remove_ref will be call by DataScopeServer::shutdownIfNotHostedByDSM
PortableServer::POAManager_var pman(poa->the_POAManager());
CORBA::PolicyList policies;
policies.length(1);
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);
+ id=_poa->activate_object(dftScope);
obj=_poa->id_to_reference(id);
- _ptr_dft_scope=SALOME::DataScopeServer::_narrow(obj);
- _scopes.push_back(_ptr_dft_scope);
- //
- std::string fullNameInNS(CreateAbsNameInNSFromScopeName(DFT_SCOPE_NAME_IN_NS));
- ns.Register(_ptr_dft_scope,fullNameInNS.c_str());
+ SALOME::DataScopeServer_var dftScopePtr(SALOME::DataScopeServer::_narrow(obj));
+ dftScope->setPOAAndRegister(_poa,dftScopePtr);
}
SALOME::StringVec *DataServerManager::listScopes()
{
+ std::vector<std::string> scopes(listOfScopesCpp());
SALOME::StringVec *ret(new SALOME::StringVec);
- std::size_t sz(_scopes.size());
+ std::size_t sz(scopes.size());
ret->length(sz);
- std::list< SALOME::DataScopeServer_var >::iterator it(_scopes.begin());
- for(std::size_t i=0;i<sz;it++,i++)
- {
- SALOME::DataScopeServer_var obj(*it);
- char *name(obj->getScopeName());
- (*ret)[i]=CORBA::string_dup(name);
- CORBA::string_free(name);
- }
+ for(std::size_t i=0;i<sz;i++)
+ (*ret)[i]=CORBA::string_dup(scopes[i].c_str());
return ret;
}
SALOME::DataScopeServer_ptr DataServerManager::getDefaultScope()
{
- return SALOME::DataScopeServer::_duplicate(_ptr_dft_scope);
+ return retriveDataScope(DFT_SCOPE_NAME_IN_NS);
}
SALOME::DataScopeServer_ptr DataServerManager::createDataScope(const char *scopeName)
{
std::string scopeNameCpp(scopeName);
- std::size_t sz(_scopes.size());
- std::list< SALOME::DataScopeServer_var >::iterator it(_scopes.begin());
- for(std::size_t i=0;i<sz;it++,i++)
+ std::vector<std::string> scopes(listOfScopesCpp());
+ if(std::find(scopes.begin(),scopes.end(),scopeNameCpp)!=scopes.end())
{
- CORBA::String_var zeName((*it)->getScopeName());
- if(scopeNameCpp==(const char *)zeName)
- {
- std::ostringstream oss; oss << "DataServerManager::createDataScope : scope name \"" << scopeName << "\" already exists !";
- throw Exception(oss.str());
- }
+ std::ostringstream oss; oss << "DataServerManager::createDataScope : scope name \"" << scopeName << "\" already exists !";
+ throw Exception(oss.str());
}
//
SALOME_NamingService ns(_orb);
CORBA::Object_var obj(ns.Resolve(fullScopeName.c_str()));
ret=SALOME::DataScopeServer::_narrow(obj);
}
- if(!CORBA::is_nil(ret))
- {
- _scopes.push_back(ret);
- }
return SALOME::DataScopeServer::_duplicate(ret);
}
SALOME::DataScopeServer_ptr DataServerManager::retriveDataScope(const char *scopeName)
{
- std::list< SALOME::DataScopeServer_var >::iterator it(getScopePtrGivenName(scopeName));
- return SALOME::DataScopeServer::_duplicate(*it);
+ SALOME::DataScopeServer_var ret(getScopePtrGivenName(scopeName));
+ return SALOME::DataScopeServer::_duplicate(ret);
}
void DataServerManager::removeDataScope(const char *scopeName)
{
- std::list< SALOME::DataScopeServer_var >::iterator it(getScopePtrGivenName(scopeName));
+ SALOME::DataScopeServer_var scs(getScopePtrGivenName(scopeName));
+ scs->shutdownIfNotHostedByDSM();
+}
+
+void DataServerManager::shutdownScopes()
+{
+ std::vector<std::string> scopeNames(listOfScopesCpp());
+ for(std::vector<std::string>::const_iterator it=scopeNames.begin();it!=scopeNames.end();it++)
+ getScopePtrGivenName(*it)->shutdownIfNotHostedByDSM();
}
std::string DataServerManager::CreateAbsNameInNSFromScopeName(const std::string& scopeName)
return oss.str();
}
-std::list< SALOME::DataScopeServer_var >::iterator DataServerManager::getScopePtrGivenName(const std::string& scopeName)
+std::vector<std::string> DataServerManager::listOfScopesCpp()
{
- std::size_t sz(_scopes.size());
- std::list< SALOME::DataScopeServer_var >::iterator it(_scopes.begin());
- bool found(false);
- for(std::size_t i=0;i<sz;it++,i++)
- {
- CORBA::String_var zeName((*it)->getScopeName());
- found=(scopeName==(const char *)zeName);
- if(found)
- break;
- }
- if(!found)
+ SALOME_NamingService ns(_orb);
+ ns.Change_Directory(NAME_IN_NS);
+ std::vector<std::string> ret(ns.list_directory());
+ return ret;
+}
+
+SALOME::DataScopeServer_var DataServerManager::getScopePtrGivenName(const std::string& scopeName)
+{
+ std::vector<std::string> scopes(listOfScopesCpp());
+ std::size_t sz(scopes.size());
+ if(std::find(scopes.begin(),scopes.end(),scopeName)==scopes.end())
{
std::ostringstream oss; oss << "DataServerManager::getScopePtrGivenName : scope name \"" << scopeName << "\" does not exist !";
throw Exception(oss.str());
}
- return it;
+ SALOME_NamingService ns(_orb);
+ std::string fullScopeName(CreateAbsNameInNSFromScopeName(scopeName));
+ CORBA::Object_var obj(ns.Resolve(fullScopeName.c_str()));
+ SALOME::DataScopeServer_var ret(SALOME::DataScopeServer::_narrow(obj));
+ return ret;
}
#include "SALOMESDS_AutoRefCountPtr.hxx"
#include "SALOMESDS_DataScopeServer.hxx"
-#include <list>
#include <string>
namespace SALOMESDS
SALOME::DataScopeServer_ptr createDataScope(const char *scopeName);
SALOME::DataScopeServer_ptr retriveDataScope(const char *scopeName);
void removeDataScope(const char *scopeName);
+ void shutdownScopes();
static std::string CreateAbsNameInNSFromScopeName(const std::string& scopeName);
public:
static const char NAME_IN_NS[];
static const char DFT_SCOPE_NAME_IN_NS[];
private:
- std::list< SALOME::DataScopeServer_var >::iterator getScopePtrGivenName(const std::string& scopeName);
+ std::vector<std::string> listOfScopesCpp();
+ SALOME::DataScopeServer_var getScopePtrGivenName(const std::string& scopeName);
private:
- AutoRefCountPtr<DataScopeServer> _dft_scope;
- SALOME::DataScopeServer_var _ptr_dft_scope;
- std::list< SALOME::DataScopeServer_var > _scopes;
CORBA::ORB_var _orb;
//! single thread poa
PortableServer::POA_var _poa;
PortableServer::ObjectId_var id(poa2->activate_object(server));
obj=poa2->id_to_reference(id);
SALOME::DataScopeServer_var serverPtr(SALOME::DataScopeServer::_narrow(obj));
- //
- std::string fullScopeName(SALOMESDS::DataServerManager::CreateAbsNameInNSFromScopeName(scopeName));
- SALOME_NamingService ns(orb);
- ns.Register(serverPtr,fullScopeName.c_str());
+ server->setPOAAndRegister(poa2,serverPtr);
//
orb->run();
- server->decrRef();
+ server->_remove_ref();
return 0;
}