From: rnv Date: Wed, 22 Dec 2021 10:47:01 +0000 (+0300) Subject: Make PVSERVER available in SSL mode. X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fvuzlov%2F26460;p=modules%2Fgui.git Make PVSERVER available in SSL mode. --- diff --git a/src/PVServerService/ENGINE/CMakeLists.txt b/src/PVServerService/ENGINE/CMakeLists.txt index f40c59b9c..4cbc5e796 100644 --- a/src/PVServerService/ENGINE/CMakeLists.txt +++ b/src/PVServerService/ENGINE/CMakeLists.txt @@ -25,6 +25,7 @@ IF(NOT SALOME_LIGHT_ONLY) LIST(APPEND _bin_SCRIPTS PVSERVER.py PVSERVER_utils.py + PVSERVER_SalomeSessionless.py ) ENDIF() diff --git a/src/PVServerService/ENGINE/PVSERVER.py b/src/PVServerService/ENGINE/PVSERVER.py index 52b9d040b..6ec683846 100644 --- a/src/PVServerService/ENGINE/PVSERVER.py +++ b/src/PVServerService/ENGINE/PVSERVER.py @@ -20,7 +20,8 @@ # import PVSERVER_ORB__POA -from SALOME_NamingServicePy import SALOME_NamingServicePy_i +import SALOME_ComponentPy +import SALOME_Embedded_NamingService_ClientPy from PVSERVER_impl import PVSERVER_impl, MESSAGE class PVSERVER(PVSERVER_ORB__POA.PVSERVER_Gen, @@ -43,16 +44,26 @@ class PVSERVER(PVSERVER_ORB__POA.PVSERVER_Gen, # self._interfaceName = interfaceName self._containerName = containerName # self._contId = contID + self._compo_o = None + + emb_ns = contID.get_embedded_NS_if_ssl() + import CORBA + if CORBA.is_nil(emb_ns): + self._naming_service = SALOME_ComponentPy.SALOME_NamingServicePy_i( self._orb ) + else: + self._naming_service = SALOME_Embedded_NamingService_ClientPy.SALOME_Embedded_NamingService_ClientPy(emb_ns) - self._naming_service = SALOME_NamingServicePy_i(self._orb) Component_path = self._containerName + "/" + self._instanceName MESSAGE( 'SALOME_ComponentPy_i Register' + str( Component_path ) ) id_o = poa.activate_object(self) - compo_o = poa.id_to_reference(id_o) + self._compo_o = poa.id_to_reference(id_o) ## And launch registration ## - self._naming_service.Register(compo_o, Component_path) + self._naming_service.Register(self._compo_o, Component_path) + + def getCorbaRef(self): + return self._compo_o """ Override base class destroy to make sure we try to kill the pvserver before leaving. @@ -60,4 +71,5 @@ class PVSERVER(PVSERVER_ORB__POA.PVSERVER_Gen, def destroy(self): # TODO self.StopPVServer() + \ No newline at end of file diff --git a/src/PVServerService/ENGINE/PVSERVER_SalomeSessionless.py b/src/PVServerService/ENGINE/PVSERVER_SalomeSessionless.py new file mode 100644 index 000000000..5694adde6 --- /dev/null +++ b/src/PVServerService/ENGINE/PVSERVER_SalomeSessionless.py @@ -0,0 +1,49 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2021 CEA/DEN, EDF R&D +# +# 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 +# + +def buildInstance(orb): + from PVSERVER import PVSERVER + + # set SSL mode, if not done yes + import KernelBasis + KernelBasis.setSSLMode(True) + + # check if PYHELLO is already registered + import KernelServices + try: + return KernelServices.RetrieveCompo("PVSERVER"), orb + except Exception: + pass + + # initialize and register PVSERVER engine + import PortableServer + obj = orb.resolve_initial_references("RootPOA") + poa = obj._narrow(PortableServer.POA) + pman = poa._get_the_POAManager() + pman.activate() + # + from SALOME_ContainerPy import SALOME_ContainerPy_SSL_i + cont = SALOME_ContainerPy_SSL_i(orb, poa, "FactoryServer") + conObj = poa.id_to_reference(poa.activate_object(cont)) + # + servant = PVSERVER(orb, poa, conObj, "FactoryServer", "PVSERVER_inst_1", "PVSERVER") + ret = servant.getCorbaRef() + KernelServices.RegisterCompo("PVSERVER", ret) + return ret, orb diff --git a/src/PVServerService/ENGINE/PVSERVER_utils.py b/src/PVServerService/ENGINE/PVSERVER_utils.py index f0ee4677d..a414db75a 100644 --- a/src/PVServerService/ENGINE/PVSERVER_utils.py +++ b/src/PVServerService/ENGINE/PVSERVER_utils.py @@ -19,6 +19,7 @@ # Author : Adrien BRUNETON (CEA) # +import salome from omniORB import CORBA from SALOME_NamingServicePy import SALOME_NamingServicePy_i import SALOMEDS @@ -28,7 +29,7 @@ import PVSERVER_ORB ### # Get verbose level -### +### __verbose__ = None def verbose(): import os @@ -45,41 +46,32 @@ def verbose(): ### # Get ORB reference ### -__orb__ = None def getORB(): - global __orb__ - if __orb__ is None: - __orb__ = CORBA.ORB_init( [''], CORBA.ORB_ID ) - pass - return __orb__ - -### -# Get naming service instance -### -__naming_service__ = None -def getNS(): - global __naming_service__ - if __naming_service__ is None: - __naming_service__ = SALOME_NamingServicePy_i( getORB() ) - pass - return __naming_service__ + salome.salome_init() + return salome.orb ### # Get PVSERVER service ### __service__ = None __serviceLoader__ = None -def getService(): +def getService(): global __service__, __serviceLoader__ + import KernelBasis containerName = "FactoryServer" - if __serviceLoader__ is None: - __serviceLoader__ = PVServer_ServiceLoader() - if __service__ is None: - import PVSERVER - ior = __serviceLoader__.findOrLoadService(containerName) - obj = getORB().string_to_object( ior ) - __service__ = obj._narrow(PVSERVER.PVSERVER) - pass + if KernelBasis.getSSLMode(): + if __service__ is None: + salome.salome_init() + __service__ = salome.lcc.FindOrLoadComponent(containerName, "PVSERVER") + else: + if __serviceLoader__ is None: + __serviceLoader__ = PVServer_ServiceLoader() + if __service__ is None: + import PVSERVER + ior = __serviceLoader__.findOrLoadService(containerName) + obj = getORB().string_to_object( ior ) + __service__ = obj._narrow(PVSERVER.PVSERVER) + pass return __service__ ###