delete _myConnexionToRegistry;
_myConnexionToRegistry = 0 ;
- _poa->deactivate_object(*_id) ;
- delete(_id) ;
+ if(_id)
+ delete(_id) ;
//SCRUTE(pd_refCount);
_thisObj->_remove_ref();
//SCRUTE(pd_refCount);
}
else
{
- int count=10;
+ int count=20;
CORBA::Object_var obj = CORBA::Object::_nil() ;
while ( CORBA::is_nil(obj) && count )
{
{
MESSAGE("SALOME_Container::create_component_instance successful");
iobject=Engines::Component::_narrow(obj);
+ _listInstances_map[instanceName] = iobject;
return iobject._retn();
}
}
CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str());
if ( !CORBA::is_nil(obj) )
{
- // unregister the registered container if it exists
- _NS->Destroy_Name(containerNameInNS.c_str());
- // unregister component instances ???
- //Engines::Container_var cont=Engines::Container::_narrow(obj);
+ // shutdown the registered container if it exists
+ Engines::Container_var cont=Engines::Container::_narrow(obj);
+ if(!CORBA::is_nil(cont))
+ {
+ try
+ {
+ cont->Shutdown();
+ }
+ catch(CORBA::Exception&)
+ {
+ INFOS("CORBA::Exception ignored.");
+ }
+ }
}
//redirect stdout and stderr in a file
#-------------------------------------------------------------------------
def Shutdown(self):
+ self._naming_service.Destroy_Name(self._containerName);
+ self._naming_service.Destroy_FullDirectory(self._containerName);
self._orb.shutdown(0)
pass
#=============================================================================
-#initialise the ORB and find the root POA
-print "Starting ",sys.argv[1]
-orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
-poa = orb.resolve_initial_references("RootPOA")
-if verbose(): print "ORB and POA initialized"
-
-#create an instance of SALOME_ContainerPy_i and a Container reference
-#containerName = "FactoryServerPy"
-MESSAGE( str(sys.argv) )
-containerName = sys.argv[1]
-cpy_i = SALOME_ContainerPy_i(orb, poa, containerName)
-if verbose(): print "SALOME_ContainerPy_i instance created ",cpy_i
-cpy_o = cpy_i._this()
-if verbose(): print "SALOME_ContainerPy_i instance activated ",cpy_o
-sys.stdout.flush()
-sys.stderr.flush()
-
-#activate the POA
-poaManager = poa._get_the_POAManager()
-poaManager.activate()
-
-#Block for ever
-orb.run()
-
-
-
-
-
-
+if __name__ == "__main__":
+ #initialise the ORB and find the root POA
+ if verbose():print "Starting ",sys.argv[1]
+ orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
+ poa = orb.resolve_initial_references("RootPOA")
+ if verbose():print "ORB and POA initialized"
+
+ #create an instance of SALOME_ContainerPy_i and a Container reference
+ #containerName = "FactoryServerPy"
+ MESSAGE( str(sys.argv) )
+ containerName = sys.argv[1]
+ cpy_i = SALOME_ContainerPy_i(orb, poa, containerName)
+ if verbose():print "SALOME_ContainerPy_i instance created ",cpy_i
+ cpy_o = cpy_i._this()
+ if verbose():print "SALOME_ContainerPy_i instance activated ",cpy_o
+ sys.stdout.flush()
+ sys.stderr.flush()
+
+ #activate the POA
+ poaManager = poa._get_the_POAManager()
+ poaManager.activate()
+
+ #Block for ever
+ orb.run()
+ if verbose():print "SALOME_ContainerPy_i shutdown"
public virtual POA_Ports::PortProperties, \
public GenericProvidesPort< __VA_ARGS__ , CalciumCouplingPolicy, calcium_provides_port > { \
private : \
- omni_semaphore _mustnotdisconnectyet; \
+ omni_mutex _disconnect_mutex; \
+ int _mustnotdisconnect; \
public : \
typedef __VA_ARGS__ DataManipulator; \
typedef DataManipulator::Type CorbaDataType; \
typedef GenericPort< DataManipulator , \
CalciumCouplingPolicy > Port; \
+ specificPortName () : _mustnotdisconnect(0) {}; \
\
- specificPortName () :_mustnotdisconnectyet(0) {}; \
- \
virtual ~ specificPortName (); \
\
inline void disconnect(bool provideLastGivenValue) { \
- if (! _mustnotdisconnectyet.trywait() ) { \
- Port::disconnect(provideLastGivenValue); \
- } \
- } \
+ _disconnect_mutex.lock(); \
+ if(_mustnotdisconnect > 1) \
+ { \
+ _mustnotdisconnect--; \
+ } \
+ else if(_mustnotdisconnect == 1) \
+ { \
+ _mustnotdisconnect--; \
+ Port::disconnect(provideLastGivenValue); \
+ } \
+ _disconnect_mutex.unlock(); \
+ } \
inline void setDependencyType(CalciumTypes::DependencyType dependencyType) { \
Port::setDependencyType(dependencyType); \
} \
virtual void provides_port_changed(int connection_nbr, \
const Engines::DSC::Message message) { \
if ( message == Engines::DSC::AddingConnection) \
- _mustnotdisconnectyet.post(); \
+ { \
+ _disconnect_mutex.lock(); \
+ _mustnotdisconnect++; \
+ _disconnect_mutex.unlock(); \
+ } \
else if ( message == Engines::DSC::RemovingConnection ) \
- disconnect(false); \
+ { \
+ disconnect(false); \
+ } \
} \
}; \
import time
from omniORB import CORBA
import CosNaming
+import string
from string import *
from SALOME_utilities import *
#delete first '/' before split
Path=Path[1:]
- result_resolve_path = split(Path,'/')
+ result_resolve_path = string.split(Path,'/')
if len(result_resolve_path)>1:
# A directory is treated (not only an object name)
# We had to test if the directory where ObjRef should be recorded
#delete first '/' before split
Path=Path[1:]
- result_resolve_path = split(Path,'/')
+ result_resolve_path = string.split(Path,'/')
_context_name=[]
for i in range(len(result_resolve_path)-1):
_context_name.append(CosNaming.NameComponent(result_resolve_path[i],"dir"))
#delete first '/' before split
Path=Path[1:]
- result_resolve_path = split(Path,'/')
+ result_resolve_path = string.split(Path,'/')
_context_name = []
for i in range(len(result_resolve_path)):
_context_name[CosNaming.NameComponent(result_resolve_path[i],"dir")]
MESSAGE ( "Create_Directory : CosNaming.NamingContext.CannotProceed" )
except (CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE):
MESSAGE ( "Create_Directory : CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE" )
-
-
-
+ def Destroy_Name(self,Path):
+ resolve_path=string.split(Path,'/')
+ if resolve_path[0] == '': del resolve_path[0]
+ dir_path=resolve_path[:-1]
+ context_name=[]
+ for e in dir_path:
+ context_name.append(CosNaming.NameComponent(e,"dir"))
+ context_name.append(CosNaming.NameComponent(resolve_path[-1],"object"))
+
+ try:
+ self._root_context.unbind(context_name)
+ except CosNaming.NamingContext.NotFound, ex:
+ return
+ except CORBA.Exception,ex:
+ return
+
+ def Destroy_FullDirectory(self,Path):
+ context_name=[]
+ for e in string.split(Path,'/'):
+ if e == '':continue
+ context_name.append(CosNaming.NameComponent(e,"dir"))
+
+ try:
+ context=self._root_context.resolve(context_name)
+ except CosNaming.NamingContext.NotFound, ex:
+ return
+ except CORBA.Exception,ex:
+ return
+
+ bl,bi=context.list(0)
+ if bi is not None:
+ ok,b=bi.next_one()
+ while(ok):
+ for s in b.binding_name :
+ if s.kind == "object":
+ context.unbind([s])
+ elif s.kind == "dir":
+ context.unbind([s])
+ ok,b=bi.next_one()
+
+ context.destroy()
+ self._root_context.unbind(context_name)