]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
CCAR: add a method to Container idl (create_component_instance_env) to be able
authorcaremoli <caremoli>
Tue, 16 Mar 2010 17:15:30 +0000 (17:15 +0000)
committercaremoli <caremoli>
Tue, 16 Mar 2010 17:15:30 +0000 (17:15 +0000)
to create a standalone component (executable) with predefined environment variables.
It's mainly the same method as create_component_instance with a third argument that is
a dict(string,Any) to pass in the environment variables.
create_component_instance has been reimplemented by calling create_component_instance_env with an empty dict (for compatibility with 5.1.3)
MPIContainer and ParallelContainer have been updated

13 files changed:
idl/Makefile.am
idl/SALOME_Component.idl
src/Container/Component_i.cxx
src/Container/Container_i.cxx
src/Container/SALOME_ContainerManager.cxx
src/Container/SALOME_ContainerManager.hxx
src/Container/SALOME_Container_i.hxx
src/MPIContainer/MPIContainer_i.cxx
src/MPIContainer/MPIContainer_i.hxx
src/ParallelContainer/SALOME_ParallelContainerProxy_i.cxx
src/ParallelContainer/SALOME_ParallelContainerProxy_i.hxx
src/ParallelContainer/SALOME_ParallelContainer_i.cxx
src/ParallelContainer/SALOME_ParallelContainer_i.hxx

index 57e246b7fab21af13c27c9684a746649f3758ec5..18c741859760b4fab1b3cf855ee7ccfa5dfed3a7 100644 (file)
@@ -126,6 +126,10 @@ if MPI_IS_OK
   STATIDL_SOURCES += $(MPIIDL_SOURCES)
 endif
 
+if MPI_IS_OK
+  DYNIDL_SRCS += SALOME_MPIObjectDynSK.cc SALOME_MPIContainerDynSK.cc SALOME_TestMPIComponentDynSK.cc
+endif
+
 $(DYNIDL_SRCS) : $(IDL_SOURCES)
 
 # also install all generated headers to use result library from another modules
index fc555dc34cc955bd708204bb10c517f490abd27b..6253ecb8f55f58119d9490edb3b73f9b104808ba 100644 (file)
@@ -96,6 +96,19 @@ module Engines
     Engines::Component create_component_instance(in string componentName,
                                                  in long studyId);
 
+    //! Create a new servant instance of a component with environment variables specified.
+    /*!
+      Component library must be loaded.
+      \param componentName Name of the component which will be registered
+                           in Registry and Name Service,
+                         (instance number suffix added to the registered name)
+      \param studyId        0 if instance is not associated to a study, 
+                            >0 otherwise (== study id)
+      \param env         a dict of env variables
+      \return a loaded component
+    */
+    Engines::Component create_component_instance_env(in string componentName,
+                                                 in long studyId, in FieldsDict env);
     //! Find a servant instance of a component
     /*!
       \param registeredName  Name of the component in Registry or Name Service,
index 5601df1ce059851d946813a3e40b5b01ca269002..ce9d79cd9491383ea74f3c1a529778378bb94f94 100644 (file)
@@ -123,7 +123,8 @@ Engines_Component_i::Engines_Component_i(CORBA::ORB_ptr orb,
                                                      _instanceName.c_str());
     }
 
-  _notifSupplier = new NOTIFICATION_Supplier(instanceName, notif);
+  if(notif)
+    _notifSupplier = new NOTIFICATION_Supplier(instanceName, notif);
 }
 
 //=============================================================================
@@ -169,7 +170,9 @@ Engines_Component_i::Engines_Component_i(CORBA::ORB_ptr orb,
   const CORBA::String_var ior = _orb->object_to_string(_container);
   if(regist)
     _myConnexionToRegistry = new RegistryConnexion(0, 0, ior,"theSession", _instanceName.c_str());
-  _notifSupplier = new NOTIFICATION_Supplier(instanceName, notif);
+  if(notif)
+    _notifSupplier = new NOTIFICATION_Supplier(instanceName, notif);
+
 }
 
 
index f7124ac82ba1074dd5e62579b0db86329bf985ff..1a838c60fa1bbc65a65a4bc11d301c03dbf9ffc8 100644 (file)
 #include <string.h>
 #include <stdio.h>
 #include <time.h>
+#include <sys/types.h>
 #ifndef WIN32
 #include <sys/time.h>
 #include <dlfcn.h>
 #include <unistd.h>
+#include <sys/wait.h>
 #else
 #include <signal.h>
 #include <process.h>
@@ -603,6 +605,28 @@ Engines_Container_i::load_component_Library(const char* componentName)
 Engines::Component_ptr
 Engines_Container_i::create_component_instance(const char*genericRegisterName,
                                                CORBA::Long studyId)
+{
+  Engines::FieldsDict_var env = new Engines::FieldsDict;
+  return create_component_instance_env(genericRegisterName,studyId,env);
+}
+
+//=============================================================================
+//! Create a new component instance with environment variables specified
+/*! 
+*  CORBA method: Creates a new servant instance of a component.
+*  The servant registers itself to naming service and Registry.
+*  \param genericRegisterName  Name of the component instance to register
+*                         in Registry & Name Service (without _inst_n suffix)
+*  \param studyId         0 for multiStudy instance, 
+*                         study Id (>0) otherwise
+*  \param env          dict of env variables
+*  \return a loaded component
+*/
+//=============================================================================
+
+Engines::Component_ptr
+Engines_Container_i::create_component_instance_env(const char*genericRegisterName,
+                                               CORBA::Long studyId,const Engines::FieldsDict& env)
 {
   if (studyId < 0)
   {
@@ -716,8 +740,45 @@ Engines_Container_i::create_component_instance(const char*genericRegisterName,
   command+=instanceName; //instance name
   command+=" &";
   MESSAGE("SALOME_Container::create_component_instance command=" << command);
+
+#ifndef WIN32
+  // use fork/execl instead of system to get finer control on env variables
+  int status;
+  pid_t pid = fork();
+  if(pid == 0) // child
+    {
+      for (CORBA::ULong i=0; i < env.length(); i++)
+        {
+          if (env[i].value.type()->kind() == CORBA::tk_string)
+            {
+              const char* value;
+              env[i].value >>= value;
+              std::string s(env[i].key);
+              s+='=';
+              s+=value;
+              putenv((char *)s.c_str());
+            }
+        }
+
+      execl("/bin/sh", "sh", "-c", command.c_str() , (char *)0);
+      status=-1;
+    }
+  else if(pid < 0)       // failed to fork
+    {
+      status=-1;
+    }
+  else            //parent
+    {
+      pid_t tpid;
+      do
+        {
+          tpid = wait(&status);
+        } while (tpid != pid);
+    }
+#else
   // launch component with a system call
   int status=system(command.c_str());
+#endif
 
   if (status == -1)
   {
index 1b17f0dd66881786b710a1e9fe34bb89bebb583a..03d9063813fe3b1c4afe691ef6e8bedf618b1ddf 100644 (file)
@@ -223,12 +223,12 @@ SALOME_ContainerManager::GiveContainer(const Engines::ContainerParameters& param
     {
       if (mode == "find")
       {
-       MESSAGE("[GiveContainer] no container found");
-       return ret;
+        MESSAGE("[GiveContainer] no container found");
+        return ret;
       }
       else
       {
-       mode = "start";
+        mode = "start";
       }
     }
   }
@@ -246,8 +246,8 @@ SALOME_ContainerManager::GiveContainer(const Engines::ContainerParameters& param
       Engines::Container_ptr cont = FindContainer(params, possibleResources[i].in());
       try
       {
-       if(!cont->_non_existent())
-         local_resources.push_back(string(possibleResources[i]));
+        if(!cont->_non_existent())
+          local_resources.push_back(string(possibleResources[i]));
       }
       catch(CORBA::Exception&) {}
     }
@@ -310,14 +310,14 @@ SALOME_ContainerManager::GiveContainer(const Engines::ContainerParameters& param
       Engines::Container_var cont=Engines::Container::_narrow(obj);
       if(!cont->_non_existent())
       {
-       if(std::string(params.mode.in())=="getorstart" || std::string(params.mode.in())=="get"){
-         return cont._retn(); /* the container exists and params.mode is getorstart or get use it*/
-       }
-       else
-       {
-         INFOS("[GiveContainer] A container is already registered with the name: " << containerNameInNS << ", shutdown the existing container");
-         cont->Shutdown(); // shutdown the registered container if it exists
-       }
+        if(std::string(params.mode.in())=="getorstart" || std::string(params.mode.in())=="get"){
+          return cont._retn(); /* the container exists and params.mode is getorstart or get use it*/
+        }
+        else
+        {
+          INFOS("[GiveContainer] A container is already registered with the name: " << containerNameInNS << ", shutdown the existing container");
+          cont->Shutdown(); // shutdown the registered container if it exists
+        }
       }
     }
     catch(CORBA::Exception&)
@@ -349,20 +349,20 @@ SALOME_ContainerManager::GiveContainer(const Engines::ContainerParameters& param
       SALOME_ModuleCatalog::Acomponent_var compoInfo = Catalog->GetComponent(compoi);
       if (CORBA::is_nil (compoInfo))
       {
-       continue;
+        continue;
       }
       SALOME_ModuleCatalog::ImplType impl=compoInfo->implementation_type();
       container_exe_tmp=compoInfo->implementation_name();
       if(impl==SALOME_ModuleCatalog::CEXE)
       {
-       if(found)
-       {
-         INFOS("ContainerManager Error: you can't have 2 CEXE component in the same container" );
-         return Engines::Container::_nil();
-       }
-       MESSAGE("[GiveContainer] Exe container found !: " << container_exe_tmp);
-       container_exe = container_exe_tmp.in();
-       found=1;
+        if(found)
+        {
+          INFOS("ContainerManager Error: you can't have 2 CEXE component in the same container" );
+          return Engines::Container::_nil();
+        }
+        MESSAGE("[GiveContainer] Exe container found !: " << container_exe_tmp);
+        container_exe = container_exe_tmp.in();
+        found=1;
       }
     }
   }
@@ -520,6 +520,9 @@ SALOME_ContainerManager::FindContainer(const Engines::ContainerParameters& param
   }
 }
 
+
+bool isPythonContainer(const char* ContainerName);
+
 //=============================================================================
 /*!
  *  This is no longer valid (C++ container are also python containers)
@@ -579,13 +582,13 @@ SALOME_ContainerManager::BuildCommandToLaunchRemoteContainer
     if (params.isMPI)
     {
       if ((params.resource_params.nb_node <= 0) && (params.resource_params.nb_proc_per_node <= 0))
-       nbproc = 1;
+        nbproc = 1;
       else if (params.resource_params.nb_node == 0)
-       nbproc = params.resource_params.nb_proc_per_node;
+        nbproc = params.resource_params.nb_proc_per_node;
       else if (params.resource_params.nb_proc_per_node == 0)
-       nbproc = params.resource_params.nb_node;
+        nbproc = params.resource_params.nb_node;
       else
-       nbproc = params.resource_params.nb_node * params.resource_params.nb_proc_per_node;
+        nbproc = params.resource_params.nb_node * params.resource_params.nb_proc_per_node;
     }
 
     // "ssh -l user machine distantPath/runRemote.sh hostNS portNS WORKINGDIR workingdir \
@@ -630,7 +633,7 @@ SALOME_ContainerManager::BuildCommandToLaunchRemoteContainer
       command += " WORKINGDIR ";
       command += " '";
       if(wdir == "$TEMPDIR")
-       wdir="\\$TEMPDIR";
+        wdir="\\$TEMPDIR";
       command += wdir; // requested working directory
       command += "'"; 
     }
@@ -645,10 +648,10 @@ SALOME_ContainerManager::BuildCommandToLaunchRemoteContainer
       command += "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace ";
 #elif defined(WITHOPENMPI)
       if( getenv("OMPI_URI_FILE") == NULL )
-       command += "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace";
+        command += "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace";
       else{
-       command += "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace -ompi-server file:";
-       command += getenv("OMPI_URI_FILE");
+        command += "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace -ompi-server file:";
+        command += getenv("OMPI_URI_FILE");
       }
 #endif        
       command += " SALOME_MPIContainer ";
@@ -697,7 +700,7 @@ SALOME_ContainerManager::BuildCommandToLaunchLocalContainer
       o << nbproc << " ";
 
       if( getenv("LIBBATCH_NODEFILE") != NULL )
-       o << "-machinefile " << machinesFile << " ";
+        o << "-machinefile " << machinesFile << " ";
 
 #ifdef WITHLAM
       o << "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace ";
@@ -1147,7 +1150,7 @@ SALOME_ContainerManager::checkPaCOParameters(Engines::ContainerParameters & para
 //=============================================================================
 Engines::Container_ptr
 SALOME_ContainerManager::StartPaCOPPContainer(const Engines::ContainerParameters& params_const,
-                                             std::string resource_selected)
+                                              std::string resource_selected)
 {
   CORBA::Object_var obj;
   PaCO::InterfaceManager_var container_proxy;
@@ -1168,8 +1171,8 @@ SALOME_ContainerManager::StartPaCOPPContainer(const Engines::ContainerParameters
 
   // Step 2 : Get a MachineFile for the parallel container
   std::string machine_file_name = _ResManager->getMachineFile(resource_selected, 
-                                                             params.nb_proc,
-                                                             params.parallelLib.in());
+                                                              params.nb_proc,
+                                                              params.parallelLib.in());
 
   if (machine_file_name == "")
   {
@@ -1308,8 +1311,8 @@ SALOME_ContainerManager::StartPaCOPPContainer(const Engines::ContainerParameters
 
 std::string 
 SALOME_ContainerManager::BuildCommandToLaunchPaCOProxyContainer(const Engines::ContainerParameters& params,
-                                                               std::string machine_file_name,
-                                                               std::string & proxy_hostname)
+                                                                std::string machine_file_name,
+                                                                std::string & proxy_hostname)
 {
   // In the proxy case, we always launch a Dummy Proxy
   std::string exe_name = "SALOME_ParallelContainerProxyDummy";
@@ -1391,9 +1394,9 @@ SALOME_ContainerManager::BuildCommandToLaunchPaCOProxyContainer(const Engines::C
 
 std::string 
 SALOME_ContainerManager::BuildCommandToLaunchPaCONodeContainer(const Engines::ContainerParameters& params,
-                                                              const std::string & machine_file_name,
-                                                              SALOME_ContainerManager::actual_launch_machine_t & vect_machine,
-                                                              const std::string & proxy_hostname)
+                                                               const std::string & machine_file_name,
+                                                               SALOME_ContainerManager::actual_launch_machine_t & vect_machine,
+                                                               const std::string & proxy_hostname)
 {
   // Name of exe
   std::string exe_name = "SALOME_ParallelContainerNode";
@@ -1430,8 +1433,8 @@ SALOME_ContainerManager::BuildCommandToLaunchPaCONodeContainer(const Engines::Co
       bool remote_execution = false;
       if (hostname != std::string(Kernel_Utils::GetHostname()))
       {
-       MESSAGE("[BuildCommandToLaunchPaCONodeContainer] remote machine case detected !");
-       remote_execution = true;
+        MESSAGE("[BuildCommandToLaunchPaCONodeContainer] remote machine case detected !");
+        remote_execution = true;
       }
 
       // For each node we have a new command
@@ -1449,17 +1452,17 @@ SALOME_ContainerManager::BuildCommandToLaunchPaCONodeContainer(const Engines::Co
       // a SALOME application
       if (remote_execution)
       {
-       ASSERT(getenv("NSHOST")); 
-       ASSERT(getenv("NSPORT"));
-
-       command_node_stream << resource_definition->protocol.in();
-       command_node_stream << " -l ";
-       command_node_stream << resource_definition->username.in();
-       command_node_stream << " " << hostname;
-       command_node_stream << " " << resource_definition->applipath.in();
-       command_node_stream << "/runRemote.sh ";
-       command_node_stream << getenv("NSHOST") << " "; // hostname of CORBA name server
-       command_node_stream << getenv("NSPORT") << " "; // port of CORBA name server
+        ASSERT(getenv("NSHOST")); 
+        ASSERT(getenv("NSPORT"));
+
+        command_node_stream << resource_definition->protocol.in();
+        command_node_stream << " -l ";
+        command_node_stream << resource_definition->username.in();
+        command_node_stream << " " << hostname;
+        command_node_stream << " " << resource_definition->applipath.in();
+        command_node_stream << "/runRemote.sh ";
+        command_node_stream << getenv("NSHOST") << " "; // hostname of CORBA name server
+        command_node_stream << getenv("NSPORT") << " "; // port of CORBA name server
       }
 
       command_node_stream << exe_name;
@@ -1567,11 +1570,11 @@ SALOME_ContainerManager::BuildCommandToLaunchPaCONodeContainer(const Engines::Co
 
 void
 SALOME_ContainerManager::LogConfiguration(const std::string & log_type,
-                                         const std::string & exe_type,
-                                         const std::string & container_name,
-                                         const std::string & hostname,
-                                         std::string & begin, 
-                                         std::string & end)
+                                          const std::string & exe_type,
+                                          const std::string & container_name,
+                                          const std::string & hostname,
+                                          std::string & begin, 
+                                          std::string & end)
 {
   if(log_type == "xterm")
   {
@@ -1594,8 +1597,8 @@ SALOME_ContainerManager::LogConfiguration(const std::string & log_type,
 
 CORBA::Object_ptr 
 SALOME_ContainerManager::LaunchPaCOProxyContainer(const std::string& command, 
-                                                 const Engines::ContainerParameters& params,
-                                                 const std::string & hostname)
+                                                  const Engines::ContainerParameters& params,
+                                                  const std::string & hostname)
 {
   PaCO::InterfaceManager_ptr container_proxy = PaCO::InterfaceManager::_nil();
 
@@ -1613,7 +1616,7 @@ SALOME_ContainerManager::LaunchPaCOProxyContainer(const std::string& command,
   int count = TIME_OUT_TO_LAUNCH_CONT;
   CORBA::Object_var obj = CORBA::Object::_nil();
   std::string containerNameInNS = _NS->BuildContainerNameForNS(params.container_name.in(), 
-                                                              hostname.c_str());
+                                                               hostname.c_str());
   MESSAGE("[LaunchParallelContainer]  Waiting for Parallel Container proxy : " << containerNameInNS);
 
   while (CORBA::is_nil(obj) && count) 
@@ -1713,7 +1716,7 @@ SALOME_ContainerManager::LaunchPaCONodeContainer(const std::string& command,
 
 Engines::Container_ptr
 SALOME_ContainerManager::StartPaCOPPContainer(const Engines::ContainerParameters& params,
-                                             std::string resource_selected)
+                                              std::string resource_selected)
 {
   Engines::Container_ptr ret = Engines::Container::_nil();
   INFOS("[StarPaCOPPContainer] is disabled !");
@@ -1723,34 +1726,34 @@ SALOME_ContainerManager::StartPaCOPPContainer(const Engines::ContainerParameters
 
 std::string 
 SALOME_ContainerManager::BuildCommandToLaunchPaCOProxyContainer(const Engines::ContainerParameters& params,
-                                                               std::string machine_file_name,
-                                                               std::string & proxy_hostname)
+                                                                std::string machine_file_name,
+                                                                std::string & proxy_hostname)
 {
   return "";
 }
 
 std::string 
 SALOME_ContainerManager::BuildCommandToLaunchPaCONodeContainer(const Engines::ContainerParameters& params,
-                                                              const std::string & machine_file_name,
-                                                              SALOME_ContainerManager::actual_launch_machine_t & vect_machine, 
-                                                              const std::string & proxy_hostname) 
+                                                               const std::string & machine_file_name,
+                                                               SALOME_ContainerManager::actual_launch_machine_t & vect_machine, 
+                                                               const std::string & proxy_hostname) 
 {
   return "";
 }
 void 
 SALOME_ContainerManager::LogConfiguration(const std::string & log_type,
-                                         const std::string & exe_type,
-                                         const std::string & container_name,
-                                         const std::string & hostname,
-                                         std::string & begin, 
-                                         std::string & end)
+                                          const std::string & exe_type,
+                                          const std::string & container_name,
+                                          const std::string & hostname,
+                                          std::string & begin, 
+                                          std::string & end)
 {
 }
 
 CORBA::Object_ptr 
 SALOME_ContainerManager::LaunchPaCOProxyContainer(const std::string& command, 
-                                                 const Engines::ContainerParameters& params,
-                                                 const std::string& hostname)
+                                                  const Engines::ContainerParameters& params,
+                                                  const std::string& hostname)
 {
   CORBA::Object_ptr ret = CORBA::Object::_nil();
   return ret;
@@ -1758,9 +1761,9 @@ SALOME_ContainerManager::LaunchPaCOProxyContainer(const std::string& command,
 
 bool 
 SALOME_ContainerManager::LaunchPaCONodeContainer(const std::string& command, 
-                       const Engines::ContainerParameters& params,
-                       const std::string& name,
-                       SALOME_ContainerManager::actual_launch_machine_t & vect_machine)
+                        const Engines::ContainerParameters& params,
+                        const std::string& name,
+                        SALOME_ContainerManager::actual_launch_machine_t & vect_machine)
 {
   return false;
 }
index 262b019b32dd57a63d1d9a215ea050022b1ff223..3633cffbb0fff13b8ec62bd218aecdf236a4864c 100644 (file)
@@ -68,7 +68,7 @@ protected:
                                                   const std::string& container_exe="SALOME_Container");
 
   std::string BuildCommandToLaunchLocalContainer(const Engines::ContainerParameters& params, 
-                                                const std::string& machinesFile,
+                                                 const std::string& machinesFile,
                                                  const std::string& container_exe="SALOME_Container");
 
   std::string BuildTempFileToLaunchRemoteContainer(const std::string& resource_name,
@@ -120,31 +120,31 @@ protected:
 
 
   std::string BuildCommandToLaunchPaCOProxyContainer(const Engines::ContainerParameters& params,
-                                                    std::string machine_file_name,
-                                                    std::string & proxy_hostname);
+                                                     std::string machine_file_name,
+                                                     std::string & proxy_hostname);
 
   std::string BuildCommandToLaunchPaCONodeContainer(const Engines::ContainerParameters& params,
-                                                   const std::string & machine_file_name,
-                                                   SALOME_ContainerManager::actual_launch_machine_t & vect_machine, 
-                                                   const std::string & proxy_hostname); 
+                                                    const std::string & machine_file_name,
+                                                    SALOME_ContainerManager::actual_launch_machine_t & vect_machine, 
+                                                    const std::string & proxy_hostname); 
 
   void LogConfiguration(const std::string & log_type,
-                       const std::string & exe_type,
-                       const std::string & container_name,
-                       const std::string & hostname,
-                       std::string & begin, 
-                       std::string & end);
+                        const std::string & exe_type,
+                        const std::string & container_name,
+                        const std::string & hostname,
+                        std::string & begin, 
+                        std::string & end);
 
   CORBA::Object_ptr 
   LaunchPaCOProxyContainer(const std::string& command, 
-                          const Engines::ContainerParameters& params,
-                          const std::string& hostname);
+                           const Engines::ContainerParameters& params,
+                           const std::string& hostname);
 
   bool 
   LaunchPaCONodeContainer(const std::string& command, 
-                         const Engines::ContainerParameters& params,
-                         const std::string& name,
-                         SALOME_ContainerManager::actual_launch_machine_t & vect_machine);
+                          const Engines::ContainerParameters& params,
+                          const std::string& name,
+                          SALOME_ContainerManager::actual_launch_machine_t & vect_machine);
   // End of PaCO++ Parallel extension
 };
 #endif
index 91d40f96f8857287becb9eccc22bf477f23285ab..c0a1891930b5d6994e45129b665084c5390a4090 100644 (file)
@@ -69,6 +69,10 @@ public:
   create_component_instance( const char* componentName,
                              CORBA::Long studyId); // 0 for multiStudy
 
+  virtual Engines::Component_ptr
+  create_component_instance_env( const char* componentName,
+                             CORBA::Long studyId,          // 0 for multiStudy
+                             const Engines::FieldsDict& env); 
   Engines::Component_ptr
   find_component_instance( const char* registeredName,
                            CORBA::Long studyId); // 0 for multiStudy
index 2886759c5a4623e4e58b932e28f588fd05b254eb..b03da70ed0bb4081aeb7372cc9f46b9f9cdcb17b 100644 (file)
@@ -209,8 +209,9 @@ bool Engines_MPIContainer_i::Lload_component_Library(const char* componentName)
 
 // Create an instance of component
 Engines::Component_ptr
-Engines_MPIContainer_i::create_component_instance( const char* componentName,
-                                                   CORBA::Long studyId)
+Engines_MPIContainer_i::create_component_instance_env( const char* componentName,
+                                                       CORBA::Long studyId,
+                                                       const Engines::FieldsDict& env)
 {
   pthread_t *th;
   if(_numproc == 0){
index 054f679a8650450f59d24717ddc099d9355316e0..899c068cc075c0104a9c6f17df1c38b00f8dac90 100644 (file)
@@ -71,9 +71,10 @@ class Engines_MPIContainer_i : public POA_Engines::MPIContainer,
 
   // Create an instance of component
   // synchronous version for process 0
-  Engines::Component_ptr
-  create_component_instance( const char* componentName,
-                             CORBA::Long studyId); // 0 for multiStudy
+  virtual Engines::Component_ptr
+  create_component_instance_env( const char* componentName,
+                                 CORBA::Long studyId,          // 0 for multiStudy
+                                 const Engines::FieldsDict& env);
 
   // Load a component in current MPI container
   // synchronous version for process 0
index 4f191ed5f730660431163d2d47ea247599e0812b..a37c15edcab2caa73473271b7ad8db424c398fd1 100644 (file)
@@ -264,12 +264,19 @@ Container_proxy_impl_final::load_component_Library(const char* componentName)
   return ret;
 }
 
+Engines::Component_ptr 
+Container_proxy_impl_final::create_component_instance(const char* componentName, ::CORBA::Long studyId)
+{
+  Engines::FieldsDict_var env = new Engines::FieldsDict;
+  return create_component_instance_env(componentName, studyId, env);
+}
+
 // Il y a deux cas :
 // Composant sequentiel -> on le créer sur le noeud 0 (on pourrait faire une répartition de charge)
 // Composant parallèle -> création du proxy ici puis appel de la création de chaque objet participant
 // au composant parallèle
 Engines::Component_ptr 
-Container_proxy_impl_final::create_component_instance(const char* componentName, ::CORBA::Long studyId)
+Container_proxy_impl_final::create_component_instance_env(const char* componentName, ::CORBA::Long studyId, const Engines::FieldsDict& env)
 {
   std::string aCompName = componentName;
   if (_libtype_map.count(aCompName) == 0)
index 5750cde7e2b163a2a814b4158cc65556de3f006c..900712494111b49dfdebdebdce5d30a47873a925 100644 (file)
@@ -56,6 +56,9 @@ class Container_proxy_impl_final :
 
     virtual ::CORBA::Boolean load_component_Library(const char* componentName);
     virtual Engines::Component_ptr create_component_instance(const char* componentName, ::CORBA::Long studyId);
+    virtual Engines::Component_ptr create_component_instance_env( const char* componentName,
+                                                                  CORBA::Long studyId,          // 0 for multiStudy
+                                                                  const Engines::FieldsDict& env);
 
   private:
     std::map<std::string, std::string> _libtype_map; // libname -> libtype (seq ou par)
index 1d53af5639263a24cfbb85e35144740337c71761..33d9be7b3ce82fe00caa2cfd24683e0a545ef5e8 100644 (file)
@@ -381,10 +381,32 @@ Engines_Parallel_Container_i::load_component_Library(const char* componentName)
  *  \return a loaded component
  */
 //=============================================================================
-
 Engines::Component_ptr
 Engines_Parallel_Container_i::create_component_instance(const char*genericRegisterName,
                                                         CORBA::Long studyId)
+{
+  Engines::FieldsDict_var env = new Engines::FieldsDict;
+  return create_component_instance_env(genericRegisterName,studyId,env);
+}
+
+//=============================================================================
+//! Create a new component instance
+/*! 
+ *  CORBA method: Creates a new servant instance of a component.
+ *  The servant registers itself to naming service and Registry.
+ *  \param genericRegisterName  Name of the component instance to register
+ *                         in Registry & Name Service (without _inst_n suffix)
+ *  \param studyId         0 for multiStudy instance, 
+ *                         study Id (>0) otherwise
+ *  \param env             dict of environment variables
+ *  \return a loaded component
+ */
+//=============================================================================
+
+Engines::Component_ptr
+Engines_Parallel_Container_i::create_component_instance_env(const char*genericRegisterName,
+                                                            CORBA::Long studyId,
+                                                            const Engines::FieldsDict& env)
 {
   MESSAGE("Begin of create_component_instance in node : " << getMyRank());
 
index 3c5298c8d3ed37bef9497594fb0611fa6bfd52c4..55bbf88028d3b51683681b34a3538b701d1709f2 100644 (file)
@@ -77,6 +77,11 @@ public:
   create_component_instance( const char* componentName,
                              CORBA::Long studyId); // 0 for multiStudy
 
+  virtual Engines::Component_ptr
+  create_component_instance_env( const char* componentName,
+                             CORBA::Long studyId,          // 0 for multiStudy
+                             const Engines::FieldsDict& env);
+
   Engines::Component_ptr
   find_component_instance( const char* registeredName,
                            CORBA::Long studyId); // 0 for multiStudy