]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
PR: debug for save study, filters not known components (Interface Applicative)
authorprascle <prascle>
Mon, 24 Jan 2005 06:26:52 +0000 (06:26 +0000)
committerprascle <prascle>
Mon, 24 Jan 2005 06:26:52 +0000 (06:26 +0000)
src/Container/SALOME_ContainerManager.cxx
src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx
src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx

index 14e377405abcbea8fce0310fe822ffbebacac4ba..d5fad0ae9d78a25f89e79f76aee7cf28d5553397 100644 (file)
@@ -9,7 +9,7 @@
 
 using namespace std;
 
-const char *SALOME_ContainerManager::_ContainerManagerNameInNS="ContainerManager";
+const char *SALOME_ContainerManager::_ContainerManagerNameInNS="/ContainerManager";
 
 SALOME_ContainerManager::SALOME_ContainerManager(CORBA::ORB_ptr orb)
 {
@@ -41,6 +41,7 @@ void SALOME_ContainerManager::ShutdownContainers()
   vector<string> vec=_NS->list_directory_recurs();
   for(vector<string>::iterator iter=vec.begin();iter!=vec.end();iter++)
     {
+      SCRUTE((*iter));
       CORBA::Object_var obj=_NS->Resolve((*iter).c_str());
       Engines::Container_var cont=Engines::Container::_narrow(obj);
       if(!CORBA::is_nil(cont))
@@ -79,6 +80,7 @@ Engines::Container_ptr SALOME_ContainerManager::FindOrStartContainer(const char
       if ( count != 10 )
        MESSAGE( count << ". Waiting for FactoryServer on " << theMachine);
       string containerNameInNS=BuildContainerNameInNS(containerName,theMachine.c_str());
+      SCRUTE(containerNameInNS);
       CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str());
       ret=Engines::Container::_narrow(obj);
     }
@@ -110,6 +112,7 @@ char* SALOME_ContainerManager::FindBest(const Engines::MachineList& possibleComp
 Engines::Container_ptr SALOME_ContainerManager::FindContainer(const char *containerName,const char *theMachine)
 {
   string containerNameInNS(BuildContainerNameInNS(containerName,theMachine));
+  SCRUTE(containerNameInNS);
   CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str());
   if( !CORBA::is_nil(obj) )
     return Engines::Container::_narrow(obj);
index cbc8b24ecc687ae74187ec385385498843b8acd1..d846594ab4f36f81bd135c075a4973128059ff54 100644 (file)
@@ -48,6 +48,7 @@ SALOME_LifeCycleCORBA::SALOME_LifeCycleCORBA(SALOME_NamingService *ns)
   _NS = ns;
   //add try catch
   CORBA::Object_var obj=_NS->Resolve(SALOME_ContainerManager::_ContainerManagerNameInNS);
+  ASSERT( !CORBA::is_nil(obj));
   _ContManager=Engines::ContainerManager::_narrow(obj);
 }
 
@@ -88,6 +89,34 @@ string SALOME_LifeCycleCORBA::ContainerName(
   return theComputerContainer ;
 }
 
+bool SALOME_LifeCycleCORBA::isKnownComponentClass(const char *componentName)
+{
+
+  try
+    {
+      CORBA::Object_var obj = _NS->Resolve("/Kernel/ModulCatalog");
+      SALOME_ModuleCatalog::ModuleCatalog_var Catalog = 
+       SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj) ;
+      SALOME_ModuleCatalog::Acomponent_ptr compoInfo = 
+       Catalog->GetComponent(componentName);
+      if (CORBA::is_nil (compoInfo)) 
+       {
+         INFOS("Catalog Error : Component not found in the catalog");
+         return false;
+       }
+      else return true;
+    }
+  catch (ServiceUnreachable&)
+    {
+      INFOS("Caught exception: Naming Service Unreachable");
+    }
+  catch (...)
+    {
+      INFOS("Caught unknown exception.");
+    }
+  return false;
+}
+
 string SALOME_LifeCycleCORBA::ComputerPath(
                                          const char * theComputer ) {
   CORBA::String_var path;
@@ -109,6 +138,7 @@ Engines::Component_ptr SALOME_LifeCycleCORBA::FindOrLoad_Component
                                   (const char *containerName,
                                   const char *componentName)
 {
+  if (! isKnownComponentClass(componentName)) return Engines::Component::_nil();
   char *stContainer=strdup(containerName);
   string st2Container(stContainer);
   int rg=st2Container.find("/");
@@ -139,6 +169,7 @@ Engines::Component_ptr SALOME_LifeCycleCORBA::FindOrLoad_Component
 Engines::Component_ptr SALOME_LifeCycleCORBA::FindOrLoad_Component(const Engines::MachineParameters& params,
                                                                   const char *componentName)
 {
+  if (! isKnownComponentClass(componentName)) return Engines::Component::_nil();
   Engines::MachineList_var listOfMachine=_ContManager->GetFittingResources(params,componentName);
   Engines::Component_ptr ret=FindComponent(params.container_name,componentName,listOfMachine);
   if(CORBA::is_nil(ret))
@@ -151,6 +182,7 @@ Engines::Component_ptr SALOME_LifeCycleCORBA::FindComponent(const char *containe
                                                                 const char *componentName,
                                                                 const Engines::MachineList& listOfMachines)
 {
+  if (! isKnownComponentClass(componentName)) return Engines::Component::_nil();
   if(containerName[0]!='\0')
     {
       Engines::MachineList_var machinesOK=new Engines::MachineList;
index ed5c78c25f9fa8874f12af56ebce1a4bc587a35c..249d4c0aa82e2268be516d3d0c74a746db4face2 100644 (file)
@@ -48,6 +48,7 @@ public:
                                              const char *componentName);
   Engines::Component_ptr FindOrLoad_Component(const char *containerName,
                                              const char *componentName);
+  bool isKnownComponentClass(const char *componentName);
 protected:
   //! Establish if a component called "componentName" in a container called "containerName" exists among the list of resources
   //! in "listOfMachines". This method uses Naming Service to find the component.