]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Make PVSERVER available in SSL mode. vuzlov/26460
authorrnv <rnv@opencascade.com>
Wed, 22 Dec 2021 10:47:01 +0000 (13:47 +0300)
committerrnv <rnv@opencascade.com>
Wed, 22 Dec 2021 10:47:01 +0000 (13:47 +0300)
src/PVServerService/ENGINE/CMakeLists.txt
src/PVServerService/ENGINE/PVSERVER.py
src/PVServerService/ENGINE/PVSERVER_SalomeSessionless.py [new file with mode: 0644]
src/PVServerService/ENGINE/PVSERVER_utils.py

index f40c59b9cde0cca94fe5c74184c239b36b15ca32..4cbc5e79606494621d6a2d9e3cfc1b64fc2f5201 100644 (file)
@@ -25,6 +25,7 @@ IF(NOT SALOME_LIGHT_ONLY)
   LIST(APPEND _bin_SCRIPTS
       PVSERVER.py
       PVSERVER_utils.py
+      PVSERVER_SalomeSessionless.py
   )
 ENDIF()
 
index 52b9d040bbfe697a7075e79ecefde1f39a505673..6ec683846619e4dfe0e38adc9c20ae7d04663d0c 100644 (file)
@@ -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 (file)
index 0000000..5694add
--- /dev/null
@@ -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
index f0ee4677dd1dc819bb177e91155a5f30ee9f2d70..a414db75aa108a4ecaceb447baf5b4e11c00208e 100644 (file)
@@ -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__
 
 ###