Salome HOME
PR: container lifecycle, new design, first part
[modules/kernel.git] / src / Container / Container_i.cxx
1 //  SALOME Container : implementation of container and engine for Kernel
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : Container_i.cxx
25 //  Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA 
26 //  Module : SALOME
27 //  $Header$
28
29 #define private public
30 #include <SALOMEconfig.h>
31 #include CORBA_SERVER_HEADER(SALOME_Component)
32 #include "SALOME_Container_i.hxx"
33 #include "SALOME_Component_i.hxx"
34 #include "SALOME_NamingService.hxx"
35 #include "OpUtil.hxx"
36 #include <string.h>
37 #include <stdio.h>
38 #include <dlfcn.h>
39 #include <unistd.h>
40
41 #include "utilities.h"
42 using namespace std;
43
44 bool _Sleeping = false ;
45
46 // Needed by multi-threaded Python
47 int _ArgC ;
48 char ** _ArgV ;
49
50
51 // Containers with name FactoryServer are started via rsh in LifeCycleCORBA
52 // Other Containers are started via start_impl of FactoryServer
53
54 extern "C" {void ActSigIntHandler() ; }
55 extern "C" {void SigIntHandler(int, siginfo_t *, void *) ; }
56
57 const char *Engines_Container_i::_defaultContainerName="FactoryServer";
58
59 //=============================================================================
60 /*! 
61  *  Default constructor, not for use
62  */
63 //=============================================================================
64
65 Engines_Container_i::Engines_Container_i () :
66   _numInstance(0)
67 {
68 }
69
70 //=============================================================================
71 /*! 
72  *  Construtor to use
73  */
74 //=============================================================================
75
76 Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb, 
77                                           PortableServer::POA_ptr poa,
78                                           char *containerName ,
79                                           int argc , char* argv[],
80                                           bool activAndRegist,
81                                           bool isServantAloneInProcess
82                                           ) :
83   _numInstance(0),_isServantAloneInProcess(isServantAloneInProcess)
84 {
85   _pid = (long)getpid();
86
87   if(activAndRegist)
88     ActSigIntHandler() ;
89
90   _ArgC = argc ;
91   _ArgV = argv ;
92
93   _argc = argc ;
94   _argv = argv ;
95   int i = strlen( _argv[ 0 ] ) - 1 ;
96   while ( i >= 0 )
97     {
98       if ( _argv[ 0 ][ i ] == '/' )
99         {
100           _argv[ 0 ][ i+1 ] = '\0' ;
101           break ;
102         }
103       i -= 1 ;
104     }
105   string hostname = GetHostname();
106   MESSAGE(hostname << " " << getpid() << " Engines_Container_i starting argc "
107           << _argc << " Thread " << pthread_self() ) ;
108   i = 0 ;
109   while ( _argv[ i ] )
110     {
111       MESSAGE("           argv" << i << " " << _argv[ i ]) ;
112       i++ ;
113     }
114   if ( argc != 4 )
115     {
116       MESSAGE("SALOME_Container usage : SALOME_Container ServerName " <<
117               "-ORBInitRef NameService=corbaname::hostname:tcpipPortNumber") ;
118       //    exit(0) ;
119     }
120
121   _containerName = BuildContainerNameForNS(containerName,hostname.c_str());
122   
123   _orb = CORBA::ORB::_duplicate(orb) ;
124   _poa = PortableServer::POA::_duplicate(poa) ;
125   
126   // Pour les containers paralleles: il ne faut pas enregistrer et activer
127   // le container generique, mais le container specialise
128
129   if(activAndRegist)
130     {
131       _id = _poa->activate_object(this);
132       _NS = new SALOME_NamingService();
133       _NS->init_orb( CORBA::ORB::_duplicate(_orb) ) ;
134       CORBA::Object_var obj=_poa->id_to_reference(*_id);
135       Engines::Container_var pCont 
136         = Engines::Container::_narrow(obj);
137       SCRUTE(_containerName);
138       _NS->Register(pCont, _containerName.c_str()); 
139     }
140 }
141
142 //=============================================================================
143 /*! 
144  *  Destructor
145  */
146 //=============================================================================
147
148 Engines_Container_i::~Engines_Container_i()
149 {
150   MESSAGE("Container_i::~Container_i()");
151   delete _id;
152 }
153
154 //=============================================================================
155 /*! 
156  *  CORBA attribute: Container name (see constructor)
157  */
158 //=============================================================================
159
160 char* Engines_Container_i::name()
161 {
162    return CORBA::string_dup(_containerName.c_str()) ;
163 }
164
165 //=============================================================================
166 /*! 
167  *  CORBA method: Get the hostName of the Container (without domain extensions)
168  */
169 //=============================================================================
170
171 char* Engines_Container_i::getHostName()
172 {
173   string s = GetHostname();
174   MESSAGE("Engines_Container_i::getHostName " << s);
175   return CORBA::string_dup(s.c_str()) ;
176 }
177
178 //=============================================================================
179 /*! 
180  *  CORBA method: Get the PID (process identification) of the Container
181  */
182 //=============================================================================
183
184 CORBA::Long Engines_Container_i::getPID()
185 {
186   return (CORBA::Long)getpid();
187 }
188
189 //=============================================================================
190 /*! 
191  *  CORBA method: check if servant is still alive
192  */
193 //=============================================================================
194
195 void Engines_Container_i::ping()
196 {
197   MESSAGE("Engines_Container_i::ping() pid "<< getpid());
198 }
199
200 //=============================================================================
201 /*! 
202  *  CORBA method, oneway: Server shutdown. 
203  *  - Container name removed from naming service,
204  *  - servant deactivation,
205  *  - orb shutdown if no other servants in the process 
206  */
207 //=============================================================================
208
209 void Engines_Container_i::Shutdown()
210 {
211   MESSAGE("Engines_Container_i::Shutdown()");
212   _NS->Destroy_Name(_containerName.c_str());
213   //_remove_ref();
214   //_poa->deactivate_object(*_id);
215   if(_isServantAloneInProcess)
216     _orb->shutdown(0);
217 }
218
219
220 //=============================================================================
221 /*! 
222  *  CORBA method: load a new component class (dynamic library)
223  *  \param componentLibraryName like "libCOMPONENTEngine.so"
224  *  \return true if dlopen successfull or already done, false otherwise
225  */
226 //=============================================================================
227
228 bool
229 Engines_Container_i::load_component_Library(const char* componentLibraryName)
230 {
231   string impl_name = componentLibraryName;
232   SCRUTE(impl_name);
233
234   if (_library_map[impl_name])
235     {
236       MESSAGE("Library " << impl_name << " already loaded");
237       return true;
238     }
239   void* handle;
240   handle = dlopen( impl_name.c_str() , RTLD_LAZY ) ;
241   if ( !handle )
242     {
243       INFOS("Can't load shared library : " << impl_name);
244       INFOS("error dlopen: " << dlerror());
245       return false;
246     }
247   else
248     {
249       _library_map[impl_name] = handle;
250       return true;
251     }
252 }
253
254 //=============================================================================
255 /*! 
256  *  CORBA method: Creates a new servant instance of a component.
257  *  The servant registers itself to naming service and Registry.
258  *  \param genericRegisterName  Name of the component instance to register
259  *                         in Registry & Name Service (without _inst_n suffix)
260  *  \param componentName   Name of the constructed library of the component
261  *  \param studyId         0 for multiStudy instance, 
262  *                         study Id (>0) otherwise
263  *  \return a loaded component
264  */
265 //=============================================================================
266
267 Engines::Component_ptr
268 Engines_Container_i::create_component_instance(const char*genericRegisterName,
269                                                const char*componentLibraryName,
270                                                CORBA::Long studyId)
271 {
272   if (studyId < 0)
273     {
274       INFOS("studyId must be > 0 for mono study instance, =0 for multiStudy");
275       return Engines::Component::_nil() ;
276     }
277
278   string impl_name = componentLibraryName;
279   void* handle = _library_map[impl_name];
280   if ( !handle )
281     {
282       INFOS("shared library " << impl_name <<"must be loaded before instance");
283       return Engines::Component::_nil() ;
284     }
285   else
286     {
287       Engines::Component_var iobject = Engines::Component::_nil() ;
288       iobject = createInstance(genericRegisterName,
289                                handle,
290                                studyId);
291       return iobject._retn();
292     }
293 }
294
295 //=============================================================================
296 /*! 
297  *  CORBA method: Finds a servant instance of a component
298  *  \param registeredName  Name of the component in Registry or Name Service,
299  *                         without instance suffix number
300  *  \param studyId         0 if instance is not associated to a study, 
301  *                         >0 otherwise (== study id)
302  *  \return the first instance found with same studyId
303  */
304 //=============================================================================
305
306 Engines::Component_ptr
307 Engines_Container_i::find_component_instance( const char* registeredName,
308                                               CORBA::Long studyId)
309 {
310   ASSERT(0);
311 }
312
313 //=============================================================================
314 /*! 
315  *  CORBA method: find or create an instance of the component (servant),
316  *  load a new component class (dynamic library) if required,
317  *  ---- FOR COMPATIBILITY WITH 2.2 ---- 
318  *  ---- USE ONLY FOR MULTISTUDY INSTANCES ! --------
319  *  The servant registers itself to naming service and Registry.
320  *  \param genericRegisterName  Name of the component to register
321  *                              in Registry & Name Service
322  *  \param componentName       Name of the constructed library of the component
323  *  \return a loaded component
324  */
325 //=============================================================================
326
327 Engines::Component_ptr
328 Engines_Container_i::load_impl( const char* genericRegisterName,
329                                 const char* componentName )
330 {
331   Engines::Component_var iobject = Engines::Component::_nil() ;
332   if (load_component_Library(componentName))
333     iobject = find_or_create_instance(genericRegisterName, componentName);
334   return iobject._retn();
335 }
336     
337
338 //=============================================================================
339 /*! 
340  *  CORBA method: Stops the component servant, and deletes all related objects
341  *  \param component_i     Component to be removed
342  */
343 //=============================================================================
344
345 void Engines_Container_i::remove_impl(Engines::Component_ptr component_i)
346 {
347   ASSERT(! CORBA::is_nil(component_i));
348   string instanceName = component_i->instanceName() ;
349   MESSAGE("unload component " << instanceName);
350   _listInstances_map.erase(instanceName);
351   component_i->destroy() ;
352 }
353
354 //=============================================================================
355 /*! 
356  *  CORBA method: Discharges all components from the container.
357  */
358 //=============================================================================
359
360 void Engines_Container_i::finalize_removal()
361 {
362   MESSAGE("finalize unload : dlclose");
363   map<string, void *>::iterator im ;
364   _numInstanceMutex.lock() ; // lock on the explore _remove_map & dlclose
365   for (im = _remove_map.begin() ; im != _remove_map.end() ; im ++)
366     {
367       void * handle = (*im).second ;
368       dlclose(handle) ;
369       MESSAGE("dlclose " << (*im).first);
370     }
371   _remove_map.clear() ;  
372   _numInstanceMutex.unlock() ;
373   MESSAGE("_remove_map.clear()");
374 }
375
376 //=============================================================================
377 /*! 
378  *  CORBA method: Kill the container process with exit(0).
379  *  To remove :  never returns !
380  */
381 //=============================================================================
382
383 bool Engines_Container_i::Kill_impl()
384 {
385   MESSAGE("Engines_Container_i::Kill() pid "<< getpid() << " containerName "
386           << _containerName.c_str() << " machineName "
387           << GetHostname().c_str());
388   INFOS("===============================================================");
389   INFOS("= REMOVE calls to Kill_impl in C++ container                  =");
390   INFOS("===============================================================");
391   //exit( 0 ) ;
392   ASSERT(0);
393 }
394
395 //=============================================================================
396 /*! 
397  *  C++ method: Finds an already existing servant instance of a component, or
398  *              create an instance.
399  *  ---- USE ONLY FOR MULTISTUDY INSTANCES ! --------
400  *  \param genericRegisterName    Name of the component instance to register
401  *                                in Registry & Name Service,
402  *                                (without _inst_n suffix, like "COMPONENT")
403  *  \param componentLibraryName   like "libCOMPONENTEngine.so"
404  *  \return a loaded component
405  * 
406  *  example with names:
407  *  aGenRegisterName = COMPONENT (= first argument)
408  *  impl_name = libCOMPONENTEngine.so (= second argument)
409  *  _containerName = /Containers/cli76ce/FactoryServer
410  *  factoryName = COMPONENTEngine_factory
411  *  component_registerBase = /Containers/cli76ce/FactoryServer/COMPONENT
412  *
413  *  instanceName = COMPONENT_inst_1
414  *  component_registerName = /Containers/cli76ce/FactoryServer/COMPONENT_inst_1
415  */
416 //=============================================================================
417
418 Engines::Component_ptr
419 Engines_Container_i::find_or_create_instance(string genericRegisterName,
420                                              string componentLibraryName)
421 {
422   string aGenRegisterName = genericRegisterName;
423   string impl_name = componentLibraryName;
424   void* handle = _library_map[impl_name];
425   if ( !handle )
426     {
427       INFOS("shared library " << impl_name <<"must be loaded before instance");
428       return Engines::Component::_nil() ;
429     }
430   else
431     {
432       // --- find a registered instance in naming service, or create
433
434       string component_registerBase =
435         _containerName + "/" + aGenRegisterName;
436       Engines::Component_var iobject = Engines::Component::_nil() ;
437       try
438         {
439           CORBA::Object_var obj =
440             _NS->ResolveFirst( component_registerBase.c_str());
441           if ( CORBA::is_nil( obj ) )
442             {
443               iobject = createInstance(genericRegisterName,
444                                        handle,
445                                        0); // force multiStudy instance here !
446             }
447           else
448             { 
449               iobject = Engines::Component::_narrow( obj ) ;
450               Engines_Component_i *servant =
451                 dynamic_cast<Engines_Component_i*>
452                 (_poa->reference_to_servant(iobject));
453               ASSERT(servant)
454               int studyId = servant->getStudyId(); 
455               ASSERT (studyId >= 0);
456               if (studyId == 0) // multiStudy instance, OK
457                 {
458                   // No ReBind !
459                   MESSAGE(component_registerBase.c_str()<<" already bound");
460                 }
461               else // monoStudy instance: NOK
462                 {
463                   iobject = Engines::Component::_nil();
464                   INFOS("load_impl & find_component_instance methods "
465                         << "NOT SUITABLE for mono study components");
466                 }
467             }
468         }
469       catch (...)
470         {
471           INFOS( "Container_i::load_impl catched" ) ;
472         }
473       return iobject._retn();
474     }
475 }
476
477 //=============================================================================
478 /*! 
479  *  C++ method: create a servant instance of a component.
480  *  \param genericRegisterName    Name of the component instance to register
481  *                                in Registry & Name Service,
482  *                                (without _inst_n suffix, like "COMPONENT")
483  *  \param handle                 loaded library handle
484  *  \param studyId                0 for multiStudy instance, 
485  *                                study Id (>0) otherwise
486  *  \return a loaded component
487  * 
488  *  example with names:
489  *  aGenRegisterName = COMPONENT (= first argument)
490  *  _containerName = /Containers/cli76ce/FactoryServer
491  *  factoryName = COMPONENTEngine_factory
492  *  component_registerBase = /Containers/cli76ce/FactoryServer/COMPONENT
493  *  instanceName = COMPONENT_inst_1
494  *  component_registerName = /Containers/cli76ce/FactoryServer/COMPONENT_inst_1
495  */
496 //=============================================================================
497
498 Engines::Component_ptr
499 Engines_Container_i::createInstance(string genericRegisterName,
500                                     void *handle,
501                                     int studyId)
502 {
503   // --- find the factory
504
505   string aGenRegisterName = genericRegisterName;
506   string factory_name = aGenRegisterName + string("Engine_factory");
507   SCRUTE(factory_name) ;
508
509   typedef  PortableServer::ObjectId * (*FACTORY_FUNCTION)
510     (CORBA::ORB_ptr,
511      PortableServer::POA_ptr, 
512      PortableServer::ObjectId *, 
513      const char *, 
514      const char *) ;
515
516   FACTORY_FUNCTION Component_factory
517     = (FACTORY_FUNCTION) dlsym(handle, factory_name.c_str());
518
519   char *error ;
520   if ( (error = dlerror() ) != NULL)
521     {
522       INFOS("Can't resolve symbol: " + factory_name);
523       SCRUTE(error);
524       return Engines::Component::_nil() ;
525     }
526
527   // --- create instance
528
529   Engines::Component_var iobject = Engines::Component::_nil() ;
530
531   try
532     {
533       _numInstanceMutex.lock() ; // lock on the instance number
534       _numInstance++ ;
535       int numInstance = _numInstance ;
536       _numInstanceMutex.unlock() ;
537
538       char aNumI[12];
539       sprintf( aNumI , "%d" , numInstance ) ;
540       string instanceName = aGenRegisterName + "_inst_" + aNumI ;
541       string component_registerName =
542         _containerName + "/" + instanceName;
543
544       // --- Instanciate required CORBA object
545
546       PortableServer::ObjectId * id ;
547       id = (Component_factory) ( _orb, _poa, _id, instanceName.c_str(),
548                                  aGenRegisterName.c_str() ) ;
549
550       // --- get reference & servant from id
551
552       CORBA::Object_var obj = _poa->id_to_reference(*id);
553       iobject = Engines::Component::_narrow( obj ) ;
554
555       Engines_Component_i *servant =
556         dynamic_cast<Engines_Component_i*>(_poa->reference_to_servant(iobject));
557       ASSERT(servant);
558       SCRUTE(servant->pd_refCount);
559       servant->_remove_ref(); // compensate previous id_to_reference 
560       SCRUTE(servant->pd_refCount);
561       _listInstances_map[instanceName] = iobject;
562       SCRUTE(servant->pd_refCount);
563       ASSERT(servant->setStudyId(studyId));
564
565       // --- register the engine under the name
566       //     containerName(.dir)/instanceName(.object)
567
568       _NS->Register( iobject , component_registerName.c_str() ) ;
569       MESSAGE( component_registerName.c_str() << " bound" ) ;
570     }
571   catch (...)
572     {
573       INFOS( "Container_i::createInstance exception catched" ) ;
574     }
575   return iobject._retn();
576 }
577
578
579 //=============================================================================
580 /*! 
581  *  Retrieves only with container naming convention if it is a python container
582  */
583 //=============================================================================
584
585 bool Engines_Container_i::isPythonContainer(const char* ContainerName)
586 {
587   bool ret=false;
588   int len=strlen(ContainerName);
589   if(len>=2)
590     if(strcmp(ContainerName+len-2,"Py")==0)
591       ret=true;
592   return ret;
593 }
594
595 //=============================================================================
596 /*! 
597  *  Returns string = container path + name, to use in Naming service
598  */
599 //=============================================================================
600
601 string Engines_Container_i::BuildContainerNameForNS(const char *ContainerName,
602                                                     const char *hostname)
603 {
604   string ret="/Containers/";
605   ret += hostname;
606   ret+="/";
607   if (strlen(ContainerName)== 0)
608     ret+=_defaultContainerName;
609   else
610     ret += ContainerName;
611   return ret;
612 }
613
614 //=============================================================================
615 /*! 
616  *  
617  */
618 //=============================================================================
619
620 void ActSigIntHandler()
621 {
622   struct sigaction SigIntAct ;
623   SigIntAct.sa_sigaction = &SigIntHandler ;
624   SigIntAct.sa_flags = SA_SIGINFO ;
625   // DEBUG 03.02.2005 : the first parameter of sigaction is not a mask of signals (SIGINT | SIGUSR1) :
626   // it must be only one signal ===> one call for SIGINT and an other one for SIGUSR1
627   if ( sigaction( SIGINT , &SigIntAct, NULL ) ) {
628     perror("SALOME_Container main ") ;
629     exit(0) ;
630   }
631   if ( sigaction( SIGUSR1 , &SigIntAct, NULL ) ) {
632     perror("SALOME_Container main ") ;
633     exit(0) ;
634   }
635   INFOS(pthread_self() << "SigIntHandler activated") ;
636 }
637
638 void SetCpuUsed() ;
639
640 void SigIntHandler(int what , siginfo_t * siginfo ,
641                                         void * toto )
642 {
643   MESSAGE(pthread_self() << "SigIntHandler what     " << what << endl
644           << "              si_signo " << siginfo->si_signo << endl
645           << "              si_code  " << siginfo->si_code << endl
646           << "              si_pid   " << siginfo->si_pid) ;
647   if ( _Sleeping ) {
648     _Sleeping = false ;
649     MESSAGE("SigIntHandler END sleeping.") ;
650     return ;
651   }
652   else {
653     ActSigIntHandler() ;
654     if ( siginfo->si_signo == SIGUSR1 ) {
655       SetCpuUsed() ;
656     }
657     else {
658       _Sleeping = true ;
659       MESSAGE("SigIntHandler BEGIN sleeping.") ;
660       int count = 0 ;
661       while( _Sleeping ) {
662         sleep( 1 ) ;
663         count += 1 ;
664       }
665       MESSAGE("SigIntHandler LEAVE sleeping after " << count << " s.") ;
666     }
667     return ;
668   }
669 }
670
671 //=============================================================================
672 /*! 
673  *  CORBA method: Create one instance of componentName component 
674  *  and register it as genericRegisterName in naming service
675  */
676 //=============================================================================
677
678 // Engines::Component_ptr Engines_Container_i::instance( const char* genericRegisterName,
679 //                                                    const char* componentName )
680 // {
681 //   _numInstanceMutex.lock() ; // lock on the instance number
682 //   BEGIN_OF( "Container_i::instance " << componentName ) ;
683
684 //   string _genericRegisterName = genericRegisterName;
685 //   string component_registerName = _containerName + "/" + _genericRegisterName;
686   
687 //   Engines::Component_var iobject = Engines::Component::_nil() ;
688   
689 //   try 
690 //     {
691 //       CORBA::Object_var obj = _NS->Resolve( component_registerName.c_str() ) ;
692 //       if (! CORBA::is_nil( obj ) )
693 //      {
694 //        MESSAGE( "Container_i::instance " << component_registerName.c_str() << " already registered" ) ;
695 //        iobject = Engines::Component::_narrow( obj ) ;
696 //      }
697 //       else
698 //      {
699 //        string _compo_name = componentName;
700 //        string _impl_name = "lib" + _compo_name + "Engine.so";
701 //        SCRUTE(_impl_name);
702       
703 //        void* handle;
704 //        handle = dlopen( _impl_name.c_str() , RTLD_LAZY ) ;
705           
706 //        if ( handle )
707 //          {
708 //            string factory_name = _compo_name + "Engine_factory";
709 //            SCRUTE(factory_name) ;
710               
711 //            typedef  PortableServer::ObjectId * (*FACTORY_FUNCTION)
712 //              (CORBA::ORB_ptr,
713 //               PortableServer::POA_ptr, 
714 //               PortableServer::ObjectId *, 
715 //               const char *, 
716 //               const char *) ; 
717 //            FACTORY_FUNCTION Component_factory = (FACTORY_FUNCTION) dlsym(handle, factory_name.c_str());
718
719 //            char *error ;
720 //            if ( (error = dlerror() ) == NULL)
721 //              {
722 //                // Instanciate required CORBA object
723 //                _numInstance++ ;
724 //                char _aNumI[12];
725 //                sprintf( _aNumI , "%d" , _numInstance ) ;
726 //                string instanceName = _compo_name + "_inst_" + _aNumI ;
727 //                SCRUTE(instanceName);
728                   
729 //                PortableServer::ObjectId * id ;
730 //                id = (Component_factory) ( _orb, _poa, _id, instanceName.c_str() ,
731 //                                           _genericRegisterName.c_str() ) ;
732 //                // get reference from id
733 //                obj = _poa->id_to_reference(*id);
734 //                iobject = Engines::Component::_narrow( obj ) ;
735                   
736 //                // register the engine under the name containerName.dir/genericRegisterName.object
737 //                _NS->Register( iobject , component_registerName.c_str() ) ;
738 //                MESSAGE( "Container_i::instance " << component_registerName.c_str() << " registered" ) ;
739 //                _handle_map[instanceName] = handle;
740 //              }
741 //            else
742 //              {
743 //                INFOS("Can't resolve symbol: " + factory_name);
744 //                SCRUTE(error);
745 //              }  
746 //          }
747 //        else
748 //          {
749 //            INFOS("Can't load shared library : " << _impl_name);
750 //            INFOS("error dlopen: " << dlerror());
751 //          }      
752 //      }
753 //     }
754 //   catch (...)
755 //     {
756 //       INFOS( "Container_i::instance exception caught" ) ;
757 //     }
758 //   END_OF("Container_i::instance");
759 //   _numInstanceMutex.unlock() ;
760 //   return Engines::Component::_duplicate(iobject);
761 // }
762
763 //=============================================================================
764 /*! 
765  *  CORBA attribute: Machine Name (hostname without domain extensions)
766  */
767 //=============================================================================
768
769 // char* Engines_Container_i::machineName()
770 // {
771 //   string s = GetHostname();
772 //   MESSAGE("Engines_Container_i::machineName " << s);
773 //    return CORBA::string_dup(s.c_str()) ;
774 // }