Salome HOME
Shutdown data servers scopes in driver command.
[modules/yacs.git] / src / yacsloader / driver.cxx
index 85cd180e7b7341d50131b18d31bd202a50743edc..95f0e4de67035ac0b07e5b6df04a61f94328a5d6 100644 (file)
 #include "LinkInfo.hxx"
 #include "ObserverAsPlugin.hxx"
 
-#ifdef SALOME_KERNEL
 #include "KernelBasis.hxx"
 #include "SALOME_Launcher.hxx"
 #include "ServiceUnreachable.hxx"
 #include "SALOME_NamingService_Wrapper.hxx"
+#include "SALOME_NamingService.hxx"
 #include "SALOME_ModuleCatalog.hh"
+#include "SALOMESDS_DataServerManager.hxx"
 #include "Basics_Utils.hxx"
-#endif
 
 #include <iostream>
 #include <fstream>
@@ -303,6 +303,33 @@ void InitializeSSL()
   KERNEL::getLauncherSA();
 }
 
+void shutdownServers()
+{
+  // shutdown data server scopes
+  try
+    {
+      YACS::ENGINE::RuntimeSALOME* runTime = YACS::ENGINE::getSALOMERuntime();
+      runTime->loadModulCatalog();
+      CORBA::ORB_ptr orb = runTime->getOrb();
+      if (orb)
+      {
+        SALOME_NamingService_Wrapper namingService(orb);
+        CORBA::Object_var objDSM(namingService.Resolve(SALOMESDS::DataServerManager::NAME_IN_NS));
+        SALOME::DataServerManager_var dsm(SALOME::DataServerManager::_narrow(objDSM));
+        if ( !CORBA::is_nil(dsm) )
+          dsm->shutdownScopes();
+      }
+    }
+  catch(const CORBA::Exception& )
+    {
+       // ignore and continue
+    }
+  catch(ServiceUnreachable& e)
+    {
+       // ignore and continue
+    }
+}
+
 int main (int argc, char* argv[])
 {
      
@@ -315,7 +342,7 @@ int main (int argc, char* argv[])
   myArgs.dump = 0;
   myArgs.loadState = (char *)"";
   myArgs.xmlSchema = (char *)"";
-  myArgs.shutdown = 1;
+  myArgs.shutdown = 10;
   myArgs.reset = 0;
   myArgs.killPort = 0;
   myArgs.init_ports.clear();
@@ -359,6 +386,7 @@ int main (int argc, char* argv[])
   try
     {
       YACS::ENGINE::RuntimeSALOME* runTime = YACS::ENGINE::getSALOMERuntime();
+      runTime->loadModulCatalog();
       CORBA::ORB_ptr orb = runTime->getOrb();
       if (orb)
         {
@@ -498,11 +526,12 @@ int main (int argc, char* argv[])
         }
 
       if (myArgs.stop)
+      {
         if (strlen(myArgs.dumpErrorFile) >0)
           executor.setStopOnError(true, myArgs.dumpErrorFile);
         else
           executor.setStopOnError(false, myArgs.dumpErrorFile);
-
+      }
       if(myArgs.display>0)
         {
           std::ofstream f("toto");
@@ -564,6 +593,7 @@ int main (int argc, char* argv[])
       if(myArgs.shutdown < 999)
         {
           p->shutdown(myArgs.shutdown);
+          shutdownServers();
         }
       delete p;
       Runtime* r=YACS::ENGINE::getRuntime();