]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Go on for RequestSwitcher conquest
authorAnthony Geay <anthony.geay@edf.fr>
Fri, 5 Jan 2018 14:23:58 +0000 (15:23 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Fri, 5 Jan 2018 14:23:58 +0000 (15:23 +0100)
idl/SALOME_SDS.idl
src/Launcher/SALOME_LauncherServer.cxx
src/SALOMESDS/CMakeLists.txt
src/SALOMESDS/SALOMESDS_DataScopeServer.cxx
src/SALOMESDS/SALOMESDS_DataScopeServer.hxx
src/SALOMESDS/SALOMESDS_DataServerManager.cxx
src/SALOMESDS/SALOMESDS_DataServerManager.hxx
src/SALOMESDS/SALOMESDS_RequestSwitcher.cxx [new file with mode: 0644]
src/SALOMESDS/SALOMESDS_RequestSwitcher.hxx [new file with mode: 0644]

index 07950bd6ecc1dcdfc5bbe6c17a0b0e6794ce3abd..82f6c2dcf524a413dbe33d4afe5706f30b38c25e 100644 (file)
@@ -71,11 +71,15 @@ module SALOME
   {
     void shutdown();
   };
-  
-  interface RequestSwitcher
+
+  interface RequestSwitcherBase
   {
     void holdRequests();
     void activeRequests();
+  };
+  
+  interface RequestSwitcher : RequestSwitcherBase
+  {
     StringVec listVars();
     ByteVec fetchSerializedContent(in string varName) raises (SALOME::SALOME_Exception);
   };
index a82d900507122e508994a4c6c3b250d748e4d640..e7da460f6bbecc86e6a3eaf99eb254fac26569a7 100644 (file)
@@ -76,8 +76,19 @@ int main(int argc, char* argv[])
   PortableServer::POA_var root_poa;
   PortableServer::POAManager_var pman;
   CORBA::Object_var obj;
-
-  CORBA::ORB_var orb = CORBA::ORB_init( argc , argv ) ;
+  CORBA::ORB_var orb;
+  {
+    int myArgc(argc+2);
+    char **myArgv(new char *[myArgc]);
+    for(int i=0;i<argc;i++)
+      myArgv[i]=strdup(argv[i]);
+    myArgv[argc+0]=strdup("-ORBsupportCurrent");
+    myArgv[argc+1]=strdup("0");
+    orb = CORBA::ORB_init( myArgc , myArgv ) ;
+    for(int i=0;i<myArgc;i++)
+      free(myArgv[i]);
+    delete [] myArgv;
+  }
   //  LocalTraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
   INFOS_COMPILATION;
   BEGIN_OF(argv[0]);
index 66cfb77995aefdb0cce2e648e573a1521072a2d4..a56faba1e0fc5c61d98d1416e99efc348edd0b8d 100644 (file)
@@ -39,6 +39,7 @@ SET(SalomeSDS_SOURCES
   SALOMESDS_RefCountServ.cxx
   SALOMESDS_BasicDataServer.cxx
   SALOMESDS_DataScopeServer.cxx
+  SALOMESDS_RequestSwitcher.cxx
   SALOMESDS_DataServerManager.cxx
   SALOMESDS_PickelizedPyObjServer.cxx
   SALOMESDS_PickelizedPyObjRdOnlyServer.cxx
index 7b3f185b8f9890521eb798856aa10f56d42dfd8c..7622f6d10224f98101bc2e4bc8ad678c45a7d361 100644 (file)
@@ -52,34 +52,8 @@ void DataScopeKiller::shutdown()
   _orb->shutdown(0);
 }
 
-RequestSwitcher::RequestSwitcher(CORBA::ORB_ptr orb, DataScopeServerBase *ds):_ds(ds)
+RequestSwitcher::RequestSwitcher(CORBA::ORB_ptr orb, DataScopeServerBase *ds):RequestSwitcherBase(orb),_ds(ds)
 {
-  CORBA::Object_var obj(orb->resolve_initial_references("RootPOA"));
-  PortableServer::POA_var poa(PortableServer::POA::_narrow(obj));
-  _poa_manager_under_control=poa->the_POAManager();
-  //
-  CORBA::PolicyList policies;
-  policies.length(1);
-  PortableServer::ThreadPolicy_var threadPol(poa->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL));
-  policies[0]=PortableServer::ThreadPolicy::_duplicate(threadPol);
-  // all is in PortableServer::POAManager::_nil. By specifying _nil cf Advanced CORBA Programming with C++ p 506
-  // a new POA manager is created. This POA manager is independent from POA manager of the son ones.
-  _poa_for_request_control=poa->create_POA("4RqstSwitcher",PortableServer::POAManager::_nil(),policies);
-  threadPol->destroy();
-  PortableServer::POAManager_var mgr(_poa_for_request_control->the_POAManager());
-  mgr->activate();
-  //obj=orb->resolve_initial_references ("POACurrent");// agy : usage of POACurrent breaks the hold_requests. Why ?
-  //PortableServer::Current_var current(PortableServer::Current::_narrow(obj));
-}
-
-void RequestSwitcher::holdRequests()
-{
-  _poa_manager_under_control->hold_requests(true);
-}
-
-void RequestSwitcher::activeRequests()
-{
-  _poa_manager_under_control->activate();
 }
 
 SALOME::StringVec *RequestSwitcher::listVars()
index 64eb544c96caeface53d9f3ce7def3ec7dc065a4..05468fc08752264f7bd0e9f4e71a957b0d95b3d7 100644 (file)
@@ -24,6 +24,7 @@
 #include "SALOMEconfig.h"
 #include CORBA_SERVER_HEADER(SALOME_SDS)
 
+#include "SALOMESDS_RequestSwitcher.hxx"
 #include "SALOMESDS_RefCountServ.hxx"
 #include "SALOMESDS_AutoRefCountPtr.hxx"
 #include "SALOMESDS_BasicDataServer.hxx"
@@ -47,23 +48,18 @@ namespace SALOMESDS
   };
 
   class DataScopeServerBase;
-
+  
   /*!
    * Servant activated by a specific POA (single thread) having itself its specific POA_manager.
    * This class is able to hold/active the default POA_manager shared by other POA than this.
    */
-  class SALOMESDS_EXPORT RequestSwitcher : public POA_SALOME::RequestSwitcher, public POAHolder
+  class SALOMESDS_EXPORT RequestSwitcher : public RequestSwitcherBase, public virtual POA_SALOME::RequestSwitcher
   {
   public:
     RequestSwitcher(CORBA::ORB_ptr orb, DataScopeServerBase *ds);
-    void holdRequests();
-    void activeRequests();
     SALOME::StringVec *listVars();
     SALOME::ByteVec *fetchSerializedContent(const char *varName);
-    PortableServer::POA_var getPOA() const { return _poa_for_request_control; }
   private:
-    PortableServer::POA_var _poa_for_request_control;
-    PortableServer::POAManager_var _poa_manager_under_control;
     //! handle on its creator to give access to services when _poa_manager_under_control is in hold mode.
     DataScopeServerBase *_ds;
   };
index 8296ba8f2f7b1fb92d0e83df930b7719d5d2ceca..a613a3a7deef4d777843a6cbfc20b17f4898767d 100644 (file)
@@ -43,6 +43,19 @@ DataServerManager::DataServerManager(int argc, char *argv[], CORBA::ORB_ptr orb,
   policies[0]=PortableServer::ThreadPolicy::_duplicate(threadPol);
   _poa=poa->create_POA("SingleThPOA4SDS",pman,policies);
   threadPol->destroy();
+  //An another _poa_for_request_control to give to my boss the pure power
+  {
+    CORBA::PolicyList policies;
+    policies.length(1);
+    PortableServer::ThreadPolicy_var threadPol(poa->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL));
+    policies[0]=PortableServer::ThreadPolicy::_duplicate(threadPol);
+    // all is in PortableServer::POAManager::_nil. By specifying _nil cf Advanced CORBA Programming with C++ p 506
+    // a new POA manager is created. This POA manager is independent from POA manager of the son ones.
+    _poa_for_request_control=poa->create_POA("4RqstSwitcher",PortableServer::POAManager::_nil(),policies);
+    threadPol->destroy();
+    PortableServer::POAManager_var mgr(_poa_for_request_control->the_POAManager());
+    mgr->activate();
+  }
   //
   dftScope->initializePython(argc,argv);// agy : Very important ! invoke this method BEFORE activation !
   // activate this to be ready to be usable from NS.
index 8d7a9da48509b9d1ae6d051ab8a50701747b0d92..f476db082c0a58c12b19f533d8083d66c0bef3b5 100644 (file)
@@ -71,6 +71,8 @@ namespace SALOMESDS
     CORBA::ORB_var _orb;
     //! single thread poa
     PortableServer::POA_var _poa;
+    //! single thread poa and with a specific poa_manager
+    PortableServer::POA_var _poa_for_request_control;
   };
 }
 
diff --git a/src/SALOMESDS/SALOMESDS_RequestSwitcher.cxx b/src/SALOMESDS/SALOMESDS_RequestSwitcher.cxx
new file mode 100644 (file)
index 0000000..22edf72
--- /dev/null
@@ -0,0 +1,53 @@
+// Copyright (C) 2007-2016  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
+//
+// Author : Anthony GEAY (EDF R&D)
+
+#include "SALOMESDS_RequestSwitcher.hxx"
+
+using namespace SALOMESDS;
+
+RequestSwitcherBase::RequestSwitcherBase(CORBA::ORB_ptr orb)
+{
+  CORBA::Object_var obj(orb->resolve_initial_references("RootPOA"));
+  PortableServer::POA_var poa(PortableServer::POA::_narrow(obj));
+  _poa_manager_under_control=poa->the_POAManager();
+  //
+  CORBA::PolicyList policies;
+  policies.length(1);
+  PortableServer::ThreadPolicy_var threadPol(poa->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL));
+  policies[0]=PortableServer::ThreadPolicy::_duplicate(threadPol);
+  // all is in PortableServer::POAManager::_nil. By specifying _nil cf Advanced CORBA Programming with C++ p 506
+  // a new POA manager is created. This POA manager is independent from POA manager of the son ones.
+  _poa_for_request_control=poa->create_POA("4RqstSwitcher",PortableServer::POAManager::_nil(),policies);
+  threadPol->destroy();
+  PortableServer::POAManager_var mgr(_poa_for_request_control->the_POAManager());
+  mgr->activate();
+  //obj=orb->resolve_initial_references ("POACurrent");// agy : usage of POACurrent breaks the hold_requests. Why ?
+  //PortableServer::Current_var current(PortableServer::Current::_narrow(obj));
+}
+
+void RequestSwitcherBase::holdRequests()
+{
+  _poa_manager_under_control->hold_requests(true);
+}
+
+void RequestSwitcherBase::activeRequests()
+{
+  _poa_manager_under_control->activate();
+}
diff --git a/src/SALOMESDS/SALOMESDS_RequestSwitcher.hxx b/src/SALOMESDS/SALOMESDS_RequestSwitcher.hxx
new file mode 100644 (file)
index 0000000..1cb7410
--- /dev/null
@@ -0,0 +1,48 @@
+// Copyright (C) 2018  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
+//
+// Author : Anthony GEAY (EDF R&D)
+
+#ifndef __SALOMESDS_REQUESTSWITCHER_HXX__
+#define __SALOMESDS_REQUESTSWITCHER_HXX__
+
+#include "SALOMEconfig.h"
+#include CORBA_SERVER_HEADER(SALOME_SDS)
+#include "SALOMESDS_AutoRefCountPtr.hxx"
+#include "SALOMESDS_Defines.hxx"
+
+namespace SALOMESDS
+{
+  /*!
+   * Servant activated by a specific POA (single thread) having itself its specific POA_manager.
+   * This class is able to hold/active the default POA_manager shared by other POA than this.
+   */
+  class SALOMESDS_EXPORT RequestSwitcherBase : public virtual POA_SALOME::RequestSwitcherBase, public POAHolder
+  {
+  public:
+    RequestSwitcherBase(CORBA::ORB_ptr orb);
+    void holdRequests();
+    void activeRequests();
+    PortableServer::POA_var getPOA() const { return _poa_for_request_control; }
+  private:
+    PortableServer::POA_var _poa_for_request_control;
+    PortableServer::POAManager_var _poa_manager_under_control;
+  };
+}
+
+#endif