from omniORB import CORBA
import CosNaming
import Engines
+import Containers
#initialise the ORB
print "Name Service Reference is invalid"
sys.exit(1)
-#resolve the name /Containers.dir/FactoryServerPy.object
-myMachine=string.split(os.getenv( "HOSTNAME" ),'.')
-machineName= myMachine[0]
-containerName = "FactoryServerPy"
-name = [CosNaming.NameComponent("Containers","dir"),
- CosNaming.NameComponent(machineName,"dir"),
- CosNaming.NameComponent(containerName,"object")]
+name = [CosNaming.NameComponent("Kernel","dir"),
+ CosNaming.NameComponent("ContainersManager","object")]
try:
- obj = rootContext.resolve(name)
+ obj = rootContext.resolve( name )
except CosNaming.NamingContext.NotFound, ex:
- print containerName , " not found in Naming Service"
+ print "/Kernel/ContainersManager not found in Naming Service"
sys.exit(1)
-container = obj._narrow(Engines.Container)
-print container._get_machineName()
-comp = container.load_impl("SALOME_TestComponentPy","SALOME_TestComponentPy")
-print comp._get_instanceName()
+MyContainersMgr = obj._narrow(Containers.Manager)
+
+MyContainersMgr.ping()
+
+Params = MyContainersMgr.Parameters()
+
+Params.ContainerName = 'TestContainerPy'
+Params.ContainerType = Engines.PythonContainer
+
+#resolve the name /Containers.dir/FactoryServerPy.object
+#myMachine=string.split(os.getenv( "HOSTNAME" ),'.')
+#machineName= myMachine[0]
+#containerName = "FactoryServerPy"
+#name = [CosNaming.NameComponent("Containers","dir"),
+ #CosNaming.NameComponent(machineName,"dir"),
+ #CosNaming.NameComponent(containerName,"object")]
+comp = MyContainersMgr.FindOrLoad_Component( Params , "SALOME_TestComponentPy" )
comp.ping()
+
comptest = comp._narrow(Engines.TestComponent)
if comptest is None:
- print "probleme cast"
-print comptest.Coucou(1)
+ print "probleme narrow(Engines.TestComponent)"
+ sys.exit(1)
+
+print "comptest",comptest.Coucou(1)
+
+container = comptest.GetContainerRef()
+container.ping()
+print "container._get_name()",container._get_name()
+print "container._get_machineName()",container._get_machineName()
+
+comptest.destroy()
+print "Component SALOME_TestComponentPy destroyed"
+
+try :
+ container.destroy()
+except :
+ print ""
+
+print "Container TestContainerPy destroyed"
+
+
+from LifeCycleCORBA import *
+lcc = LifeCycleCORBA( orb )
+
+lcccomptest = lcc.FindOrLoadComponent( 'TestContainerPy' , 'SALOME_TestComponentPy' )
+
+print "lcccomptest",lcccomptest.Coucou(1)
+
+lcccontainer = lcccomptest.GetContainerRef()
+lcccontainer.ping()
+print "lcccontainer._get_name()",lcccontainer._get_name()
+print "lcccontainer._get_machineName()",lcccontainer._get_machineName()
+
+lcccomptest.destroy()
+print "Component SALOME_TestComponentPy destroyed"
+
+try :
+ lcccontainer.destroy()
+except :
+ print ""
+
+print "Container TestContainerPy destroyed"
+
#include <unistd.h>
#include <SALOMEconfig.h>
#include CORBA_CLIENT_HEADER(SALOME_Component)
+#include CORBA_CLIENT_HEADER(ContainersManager)
#include CORBA_CLIENT_HEADER(SALOME_TestComponent)
#include "SALOME_NamingService.hxx"
SALOME_NamingService _NS(orb) ;
string containerName = "/Containers/" ;
string hostName = GetHostname();
- containerName += hostName + "/FactoryServer";
+ containerName += hostName + "/TestContainerCpp";
+ Engines::Container_var iGenFact = Engines::Container::_nil() ;
+ MESSAGE( "TestContainer : " << containerName.c_str() ) ;
obj = _NS.Resolve(containerName.c_str()) ;
- Engines::Container_var iGenFact = Engines::Container::_narrow(obj);
+ if ( !CORBA::is_nil( obj ) ) {
+ try {
+ iGenFact = Engines::Container::_narrow( obj ) ;
+ iGenFact->ping() ;
+ }
+ catch ( ... ) {
+ INFOS("TestContainerCpp unreachable") ;
+ }
+ }
+ if ( CORBA::is_nil( iGenFact ) ) {
+ obj = _NS.Resolve( "/Kernel/ContainersManager" ) ;
+ if ( !CORBA::is_nil( obj ) ) {
+ try {
+ Containers::Manager_var MyContainersMgr = Containers::Manager::_narrow( obj ) ;
+ MyContainersMgr->ping() ;
+ Containers::MachineParameters * Params = MyContainersMgr->Parameters() ;
+ Params->ContainerName = "TestContainerCpp" ;
+ iGenFact = MyContainersMgr->FindOrStartContainer( *Params ) ;
+ }
+ catch ( ... ) {
+ INFOS("ContainersManager unreachable") ;
+ }
+ }
+ }
+
+// obj = _NS.Resolve(containerName.c_str()) ;
+// Engines::Container_var iGenFact = Engines::Container::_narrow(obj);
Engines::TestComponent_var m1;
for (int iter = 0; iter < 3 ; iter++)
{
INFOS("----------------------------------------------------" << iter);
- string dirn = getenv("KERNEL_ROOT_DIR");
- dirn += "/lib/salome/libSalomeTestComponentEngine.so";
+// string dirn = getenv("KERNEL_ROOT_DIR");
+// dirn += "/lib/salome/libSalomeTestComponentEngine.so";
+ iGenFact->ping() ;
+ string dirn = "libSalomeTestComponentEngine.so";
obj = iGenFact->load_impl("SalomeTestComponent",dirn.c_str());
m1 = Engines::TestComponent::_narrow(obj);
INFOS("recup m1");
}
// Clean-up.
iGenFact->finalize_removal() ;
+ INFOS("finalize_removal done" );
+ iGenFact->destroy() ;
+ INFOS("Container destroyed" );
orb->destroy();
+ INFOS("orb destroyed" );
}
catch(CORBA::COMM_FAILURE& ex) {
INFOS("Caught system exception COMM_FAILURE -- unable to contact the object.")