Session_ServerThread.hxx
Session_Session_i.hxx
Session_Promises.hxx
+ Session_NS_wrapper.hxx
)
# --- resources ---
Session_ServerThread.cxx
Session_Session_i.cxx
Session_Promises.cxx
+ Session_NS_wrapper.cxx
)
# --- rules ---
#include "Session_ServerCheck.hxx"
#include "Session_ServerLauncher.hxx"
#include "Session_Promises.hxx"
-#include "SALOME_Fake_NamingService.hxx"
+#include "Session_NS_wrapper.hxx"
#include "GUI_version.h"
#include "Qtx.h"
// ---------------------------- MAIN -----------------------
int AbstractGUIApp::main(int argc, char **argv)
{
- using NamingServiceImplementation = SALOME_Fake_NamingService;
+ using NamingServiceImplementation = NewStyleNS;
// Set-up application settings configuration (as for QSettings)
// Note: these are default settings which can be customized (see below)
QApplication::setOrganizationName("salome");
--- /dev/null
+// Copyright (C) 2021 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "Session_NS_wrapper.hxx"
+
+#include "SALOME_Container_i.hxx"
+#include "utilities.h"
+
+Engines_Container_i *OldStyleNS::activateContainer(CORBA::ORB_var orb, PortableServer::POA_var poa, int argc, char **argv)
+{
+ Engines_Container_i *_container = nullptr;
+ try
+ {
+ MESSAGE("Container thread started");
+
+ // get or create the child POA
+
+ PortableServer::POA_var factory_poa;
+ try
+ {
+ factory_poa = poa->find_POA("factory_poa", 0);
+ // 0 = no activation (already done if exists)
+ }
+ catch (PortableServer::POA::AdapterNonExistent &)
+ {
+ MESSAGE("factory_poa does not exists, create...");
+ // define policy objects
+ PortableServer::ImplicitActivationPolicy_var implicitActivation =
+ poa->create_implicit_activation_policy(PortableServer::NO_IMPLICIT_ACTIVATION);
+ // default = NO_IMPLICIT_ACTIVATION
+ PortableServer::ThreadPolicy_var threadPolicy =
+ 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);
+
+ PortableServer::POAManager_var nil_mgr = PortableServer::POAManager::_nil();
+ factory_poa = 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();
+
+ // obtain the factory poa manager
+ PortableServer::POAManager_var pmanfac = factory_poa->the_POAManager();
+ pmanfac->activate();
+ MESSAGE("pmanfac->activate()");
+ }
+
+ char *containerName = (char *)"";
+ if (argc > 1)
+ {
+ containerName = argv[1];
+ }
+ _container = new Engines_Container_i(orb, poa, containerName, argc, argv, true, false);
+ }
+ catch (CORBA::SystemException &)
+ {
+ INFOS("Caught CORBA::SystemException.");
+ }
+ catch (PortableServer::POA::WrongPolicy &)
+ {
+ INFOS("Caught CORBA::WrongPolicyException.");
+ }
+ catch (PortableServer::POA::ServantAlreadyActive &)
+ {
+ INFOS("Caught CORBA::ServantAlreadyActiveException");
+ }
+ catch (CORBA::Exception &)
+ {
+ INFOS("Caught CORBA::Exception.");
+ }
+ catch (...)
+ {
+ INFOS("Caught unknown exception.");
+ }
+ return _container;
+}
+
+Engines_Container_i *NewStyleNS::activateContainer(CORBA::ORB_var orb, PortableServer::POA_var poa, int argc, char **argv)
+{
+ return KERNEL::getContainerSA();
+}
--- /dev/null
+// Copyright (C) 2021 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#pragma once
+
+#include "SALOME_NamingService.hxx"
+
+#include "omniORB4/CORBA.h"
+
+class Engines_Container_i;
+
+class OldStyleNS
+{
+public:
+ using RealNS = SALOME_NamingService;
+public:
+ OldStyleNS(CORBA::ORB_ptr orb):_NS(orb) {}
+ void Register(CORBA::Object_ptr ObjRef, const char* Path) { _NS.Register(ObjRef,Path); }
+ CORBA::Object_ptr Resolve(const char* Path) { return _NS.Resolve(Path); }
+ RealNS *getNS() { return &_NS; }
+ Engines_Container_i *activateContainer(CORBA::ORB_var orb, PortableServer::POA_var poa, int argc, char** argv);
+private:
+ RealNS _NS;
+};
+
+#include "SALOME_Fake_NamingService.hxx"
+
+class NewStyleNS
+{
+public:
+ using RealNS = SALOME_Fake_NamingService;
+public:
+ NewStyleNS(CORBA::ORB_ptr orb):_NS(orb) {}
+ void Register(CORBA::Object_ptr ObjRef, const char* Path) { _NS.Register(ObjRef,Path); }
+ CORBA::Object_ptr Resolve(const char* Path) { return _NS.Resolve(Path); }
+ RealNS *getNS() { return &_NS; }
+ Engines_Container_i *activateContainer(CORBA::ORB_var orb, PortableServer::POA_var poa, int argc, char** argv);
+private:
+ RealNS _NS;
+};
}
}
-template class Session_ServerLauncher<SALOME_NamingService>;
+#include "Session_NS_wrapper.hxx"
-#include "SALOME_Fake_NamingService.hxx"
+template class Session_ServerLauncher<OldStyleNS>;
-template class Session_ServerLauncher<SALOME_Fake_NamingService>;
+template class Session_ServerLauncher<NewStyleNS>;
switch (_servType) {
case 0: // Container
{
- NamingService_WaitForServerReadiness(_NS.get(),"/Registry");
- NamingService_WaitForServerReadiness(_NS.get(),"/ContainerManager");
+ NamingService_WaitForServerReadiness(this->getNS(),"/Registry");
+ NamingService_WaitForServerReadiness(this->getNS(),"/ContainerManager");
ActivateContainer(_argc, _argv);
break;
}
case 1: // ModuleCatalog
{
- NamingService_WaitForServerReadiness(_NS.get(),"/Registry");
+ NamingService_WaitForServerReadiness(this->getNS(),"/Registry");
ActivateModuleCatalog(_argc, _argv);
break;
}
case 2: // Registry
{
- NamingService_WaitForServerReadiness(_NS.get(),"");
+ NamingService_WaitForServerReadiness(this->getNS(),"");
ActivateRegistry(_argc, _argv);
break;
}
case 3: // SALOMEDS
{
- NamingService_WaitForServerReadiness(_NS.get(),"/Kernel/ModulCatalog");
+ NamingService_WaitForServerReadiness(this->getNS(),"/Kernel/ModulCatalog");
ActivateSALOMEDS(_argc, _argv);
break;
}
case 4: // Session
{
- NamingService_WaitForServerReadiness(_NS.get(),"/Study");
+ NamingService_WaitForServerReadiness(this->getNS(),"/Study");
std::string containerName = "/Containers/";
containerName = containerName + Kernel_Utils::GetHostname();
containerName = containerName + "/FactoryServer";
- NamingService_WaitForServerReadiness(_NS.get(),containerName);
+ NamingService_WaitForServerReadiness(this->getNS(),containerName);
ActivateSession(_argc, _argv);
break;
}
case 5: // Container Manager
{
- NamingService_WaitForServerReadiness(_NS.get(),"");
+ NamingService_WaitForServerReadiness(this->getNS(),"");
ActivateContainerManager(_argc, _argv);
break;
}
}
}
+template<class MY_NS>
+typename MY_NS::RealNS *Session_ServerThread<MY_NS>::getNS()
+{
+ MY_NS *pt(_NS.get());
+ if(!pt)
+ THROW_SALOME_EXCEPTION("Session_ServerThread<MY_NS>::getNS : null pointer !");
+ return pt->getNS();
+}
+
template<class MY_NS>
void Session_ServerThread<MY_NS>::ActivateContainer(int argc, char** argv)
{
- try {
- MESSAGE("Container thread started");
-
- // get or create the child POA
-
- PortableServer::POA_var factory_poa;
- try {
- factory_poa = _root_poa->find_POA("factory_poa",0);
- // 0 = no activation (already done if exists)
- }
- catch (PortableServer::POA::AdapterNonExistent&) {
- MESSAGE("factory_poa does not exists, create...");
- // 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);
-
- PortableServer::POAManager_var nil_mgr
- = PortableServer::POAManager::_nil();
- 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();
-
- // obtain the factory poa manager
- PortableServer::POAManager_var pmanfac = factory_poa->the_POAManager();
- pmanfac->activate();
- MESSAGE("pmanfac->activate()");
- }
-
- char *containerName = (char*)"";
- if (argc >1) {
- containerName = argv[1];
- }
-
- _container = new Engines_Container_i(_orb, _root_poa, containerName, argc, argv, true, false);
- }
- catch(CORBA::SystemException&) {
- INFOS("Caught CORBA::SystemException.");
- }
- catch(PortableServer::POA::WrongPolicy&) {
- INFOS("Caught CORBA::WrongPolicyException.");
- }
- catch(PortableServer::POA::ServantAlreadyActive&) {
- INFOS("Caught CORBA::ServantAlreadyActiveException");
- }
- catch(CORBA::Exception&) {
- INFOS("Caught CORBA::Exception.");
- }
- catch(...) {
- INFOS("Caught unknown exception.");
- }
+ _container = this->_NS->activateContainer(this->_orb,this->_root_poa,argc,argv);
}
template<class MY_NS>
}
}
-template class Session_ServerThread<SALOME_NamingService>;
-template class Session_SessionThread<SALOME_NamingService>;
-
-#include "SALOME_Fake_NamingService.hxx"
+template class Session_ServerThread<OldStyleNS>;
+template class Session_SessionThread<OldStyleNS>;
-template class Session_ServerThread<SALOME_Fake_NamingService>;
-template class Session_SessionThread<SALOME_Fake_NamingService>;
+template class Session_ServerThread<NewStyleNS>;
+template class Session_SessionThread<NewStyleNS>;
#ifndef _SESSION_SERVERTHREAD_HXX_
#define _SESSION_SERVERTHREAD_HXX_
+#include "Session_NS_wrapper.hxx"
#include "SALOME_Session.hxx"
#include <omniORB4/CORBA.h>
template<class MY_NS>
class SESSION_EXPORT Session_ServerThread
{
+public:
+ using RealNS = typename MY_NS::RealNS;
public:
static const int NB_SRV_TYP;
static const char* _serverTypes[];
virtual void ActivateSession ( int argc, char ** argv );
void ActivateEngine ( int argc, char ** argv );
void ActivateContainerManager( int argc, char ** argv );
+ RealNS *getNS();
protected:
int _argc;
char ** _argv;
int _servType;
CORBA::ORB_var _orb;
PortableServer::POA_var _root_poa;
- std::unique_ptr<MY_NS> _NS;
+ std::unique_ptr<MY_NS> _NS;
Engines_Container_i* _container;
};