From 437d4c85cf1299465130f37c01202450eb22c4e6 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Mon, 24 Jan 2022 16:25:14 +0100 Subject: [PATCH 1/1] Remove StandaloneLifecyle to reduce code divergence between SSL and classical. It allows GEOM and SMESH component to appear into the NS --- src/KERNEL_PY/__init__.py | 26 +++----------------- src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx | 9 ++++++- src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx | 6 +++++ src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py | 12 ++++++--- 4 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/KERNEL_PY/__init__.py b/src/KERNEL_PY/__init__.py index b82ee7dfe..80449ac00 100644 --- a/src/KERNEL_PY/__init__.py +++ b/src/KERNEL_PY/__init__.py @@ -188,26 +188,6 @@ def salome_init(path=None, embedded=False): else: salome_init_with_session(path, embedded) -class StandAloneLifecyle: - def __init__(self, containerManager, resourcesManager): - self._cm = containerManager - self._rm = resourcesManager - - def FindOrLoadComponent(self,contName,moduleName): - global orb - import importlib - builder_name = moduleName + "_SalomeSessionless" - moduleObj = importlib.import_module(builder_name) - result, orb = moduleObj.buildInstance(orb) - return result - #raise RuntimeError("Undealed situation cont = {} module = {}".format(contName,moduleName)) - - def getContainerManager(self): - return self._cm - - def getResourcesManager(self): - return self._rm - def salome_init_without_session_common(path=None, embedded=False): from ORBConfigFile import writeORBConfigFileSSL OMNIORB_USER_PATH = "OMNIORB_USER_PATH" @@ -250,7 +230,8 @@ def salome_init_without_session(path=None, embedded=False): global lcc,cm,dsm,esm import KernelLauncher cm = KernelLauncher.myContainerManager() - lcc = StandAloneLifecyle(cm, KernelLauncher.myResourcesManager()) + from LifeCycleCORBA import LifeCycleCORBASSL + lcc = LifeCycleCORBASSL() # create a FactoryServer Container servant import KernelContainer KernelContainer.myContainer() @@ -286,8 +267,9 @@ def salome_init_without_session_attached(path=None, embedded=False): rm = orb.string_to_object( nsAbroad.Resolve(RM_NAME_IN_NS).decode() ) naming_service.Register(rm,RM_NAME_IN_NS) # + from LifeCycleCORBA import LifeCycleCORBASSL + lcc = LifeCycleCORBASSL() DSM_NAME_IN_NS = "/DataServerManager" - lcc = StandAloneLifecyle(cm,rm) dsm = orb.string_to_object( nsAbroad.Resolve(DSM_NAME_IN_NS).decode() ) naming_service.Register(dsm,DSM_NAME_IN_NS) # diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx index a576b5b6f..d8e39f3ef 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx @@ -89,7 +89,7 @@ SALOME_LifeCycleCORBA::SALOME_LifeCycleCORBA(SALOME_NamingService_Abstract *ns) // in a Python module CORBA::ORB_var orb = KERNEL::GetRefToORB(); // LocalTraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb); - _NSnew=0; + _NSnew = nullptr; if (!ns) { _NS = new SALOME_NamingService(orb); @@ -837,3 +837,10 @@ CORBA::ORB_ptr SALOME_LifeCycleCORBA::orb() THROW_SALOME_EXCEPTION("SALOME_LifeCycleCORBA::orb : not a CORBA SALOME_NamingService "); return NSC->orb(); } + +#include "SALOME_Fake_NamingService.hxx" + +SALOME_LifeCycleCORBASSL::SALOME_LifeCycleCORBASSL():SALOME_LifeCycleCORBA(new SALOME_Fake_NamingService) +{ + _NSnew = _NS;//give to SALOME_LifeCycleCORBA owenership of _NS +} diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx index fc5406547..851459fd7 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx @@ -125,4 +125,10 @@ protected: } ; +class SALOME_LifeCycleCORBASSL : public SALOME_LifeCycleCORBA +{ +public: + SALOME_LifeCycleCORBASSL(); +}; + #endif diff --git a/src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py b/src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py index c7b99bd44..5ff4dc5b8 100644 --- a/src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py +++ b/src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py @@ -30,15 +30,19 @@ import Engines from libSALOME_LifeCycleCORBA import * -class LifeCycleCORBA (SALOME_LifeCycleCORBA): +class LifeCycleCORBA(SALOME_LifeCycleCORBA): def __init__(self, orb = None): SALOME_LifeCycleCORBA.__init__(self) def FindOrLoadComponent(self, containerName, componentName): - return SALOME_LifeCycleCORBA.FindOrLoad_Component(self, - containerName, - componentName) + return SALOME_LifeCycleCORBA.FindOrLoad_Component(self,containerName,componentName) + +class LifeCycleCORBASSL(SALOME_LifeCycleCORBASSL): + def __init__(self): + SALOME_LifeCycleCORBASSL.__init__(self) + def FindOrLoadComponent(self, containerName, componentName): + return SALOME_LifeCycleCORBA.FindOrLoad_Component(self,containerName,componentName) class ContainerParameters (Engines.ContainerParameters): def __init__(self, container_name='', mode='start', workingdir='', nb_proc=0, isMPI=False, parallelLib='',resource_params=None): -- 2.39.2