//There is a CXX example of LifeCycleCORBA using
#include CORBA_CLIENT_HEADER(TestComponent)
#include "SALOME_NamingService.hxx"
#include "SALOME_LifeCycleCORBA.hxx"
int main (int argc, char * argv[]){
try {
// Initializing omniORB
CORBA::ORB_var orb = CORBA::ORB_init(argc,
argv);
// Obtain a reference
to the root POA
CORBA::Object_var obj = orb->resolve_initial_references("RootPOA")
;
PortableServer::POA_var poa = PortableServer::POA::_narrow(obj)
;
SALOME_NamingService _NS(orb) ;
SALOME_LifeCycleCORBA _LCC(&_NS) ;
Engines::Component_var myComponent = _LCC.FindOrLoad_Component("FactoryServerPy","TestComponentPy");
if(!CORBA::is_nil(myComponent)){
Engines::TestComponent_var
myConcreateComponent = TestComponent::_narrow(myComponent);
//do something
what you like with the interface
...
return 0;
}
}
catch(CORBA::COMM_FAILURE& ex){
cout<<"Caught system exception COMM_FAILURE
-- unable to contact the object.\n";
}catch(CORBA::SystemException&){
cout<<"Caught a CORBA::SystemException.\n";
}catch(CORBA::Exception&){
cout<<"Caught CORBA::Exception.\n";
}catch(...){
cout<<"Caught unknown exception.\n";
}
return 1;
}
#The example may be rewritten on Python like this:
from omniORB import CORBA
from SALOME_TestComponent import *
from SALOME_NamingServicePy import *
from LifeCycleCORBA import *
try:
orb = CORBA.ORB_init(sys.argv,CORBA.ORB_ID)
_NS = SALOME_NamingService(orb)
_LCC = SALOME_LifeCycleCORBA(orb)
myComponent = _LCC.FindOrLoadComponent("FactoryServerPy","TestComponentPy");
myConcreatComponent = myComponent._narrow(TestComponent)
if myConcreatComponent is not None :
//do something what you like with the
interface
...
return 0
}
except CosNaming.NamingContext.NotFound, e :
print "Caught exception: Naming Service can't found Logger"
except CORBA.COMM_FAILURE, e:
print "Caught CORBA::SystemException CommFailure"
except CORBA.SystemException, e:
print "Caught CORBA::SystemException."
except CORBA.Exception, e:
print "Caught CORBA::Exception."
except Exception, e:
print "Caught unknown exception."