Salome HOME
Support old formats for separator of MODULECatalog.xml file paths
[modules/kernel.git] / src / ModuleCatalog / SALOME_ModuleCatalog_Server.cxx
index d777b1128d5531fccf1cedcabbd9b18359268ab0..de5110a03e595010ece4dff01fe0c982b2c0bcdd 100644 (file)
 //  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 //
 //
 //  File   : SALOME_ModuleCatalog_Server.cxx
 //  Module : SALOME
-
 /* $Header$ */
+
 #include <iostream>
 #include "SALOME_NamingService.hxx"
 #include "SALOME_ModuleCatalog_impl.hxx"
@@ -38,17 +38,16 @@ using namespace std;
 
 int main(int argc,char **argv)
 {
+  // initialize the ORB
+  CORBA::ORB_ptr orb = CORBA::ORB_init (argc, argv);
+  //  LocalTraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
   try 
     {
       CosNaming::NamingContext_var _rootContext, catalogContext;
 
-      // initialize the ORB
-
-      CORBA::ORB_ptr orb = CORBA::ORB_init (argc, argv);
-
       // initialize POA
       //
-      long TIMESleep = 250000000;
+      long TIMESleep = 500000000;
       int NumberOfTries = 40;
       int a;
       timespec ts_req;
@@ -74,7 +73,11 @@ int main(int argc,char **argv)
       for (int i = 1; i<=NumberOfTries; i++)
        {
          if (i!=1) 
+#ifndef WNT
            a=nanosleep(&ts_req,&ts_rem);
+#else
+           Sleep(TIMESleep/1000000);
+#endif
          try
            { 
              obj = orb->resolve_initial_references("RootPOA");
@@ -85,16 +88,16 @@ int main(int argc,char **argv)
              if(!CORBA::is_nil(orb)) 
                theObj = orb->resolve_initial_references("NameService"); 
            }
-         catch( CORBA::COMM_FAILURE& )
+         catch( CORBA::SystemException& )
            {
-             MESSAGE( "Module Catalog Server: CORBA::COMM_FAILURE: Unable to contact the Naming Service" );
+             INFOS( "Module Catalog Server: CORBA::SystemException: Unable to contact the Naming Service" );
            }
          if (!CORBA::is_nil(theObj))
            {
              inc = CosNaming::NamingContext::_narrow(theObj);
              if(!CORBA::is_nil(inc))
                {
-                 MESSAGE( "Module Catalog Server: Naming Service was found" );
+                 INFOS( "Module Catalog Server: Naming Service was found" );
                  if(EnvL==1)
                    {
                      CORBA::ORB_var orb1 = CORBA::ORB_init(argc,argv) ;
@@ -103,20 +106,24 @@ int main(int argc,char **argv)
                      for(int j=1; j<=NumberOfTries; j++)
                        {
                          if (j!=1) 
+#ifndef WNT
                            a=nanosleep(&ts_req, &ts_rem);
+#else
+                           Sleep(TIMESleep/1000000);
+#endif
                          try{
                            object = inc->resolve(name);}
                          catch(CosNaming::NamingContext::NotFound)
                            {
-                             MESSAGE( "Logger Server wasn't found" );
+                             INFOS( "Logger Server wasn't found" );
                            }
                          catch(...)
                            {
-                             MESSAGE( "Module Catalog Server: Unknown exception" ) ;
+                             INFOS( "Module Catalog Server: Unknown exception" ) ;
                            }
                          if (!CORBA::is_nil(object))
                            {
-                             MESSAGE( "Module Catalog Server: Logger Server was found" );
+                             INFOS( "Module Catalog Server: Logger Server was found" );
                              MODULE_CATALOG=1;
                              break;
                            }
@@ -130,13 +137,13 @@ int main(int argc,char **argv)
   
       // Active catalog
 
-      SALOME_ModuleCatalogImpl* Catalogue_i = new SALOME_ModuleCatalogImpl(argc, argv);
-      poa->activate_object (Catalogue_i);
+      SALOME_ModuleCatalogImpl Catalogue_i(argc, argv, orb);
+      poa->activate_object (&Catalogue_i);
 
       mgr->activate();
 
   
-      CORBA::Object_ptr myCata = Catalogue_i->_this();
+      CORBA::Object_ptr myCata = Catalogue_i._this();
 
       // initialise Naming Service
       SALOME_NamingService *_NS;
@@ -155,8 +162,9 @@ int main(int argc,char **argv)
 #endif
       orb->run();
  
+      mgr->deactivate(true,true);
       poa->destroy(1,1);
+
     }
   catch(CORBA::SystemException&) {
     INFOS("Caught CORBA::SystemException.")
@@ -165,5 +173,6 @@ int main(int argc,char **argv)
     INFOS("Caught CORBA::Exception.")
       }
 
+  //  delete myThreadTrace;
   return 0;
 }