namespace SALOMESDS
{
- class POAHolder
+ class POAHolder : public virtual PortableServer::ServantBase
{
public:
virtual PortableServer::POA_var getPOA() const = 0;
+ void enforcedRelease()
+ {
+ PortableServer::POA_var poa(getPOA());
+ PortableServer::ObjectId_var oid(poa->servant_to_id(this));
+ poa->deactivate_object(oid);
+ _remove_ref();
+ }
};
template<class T>
class AutoServantPtr
{
public:
- AutoServantPtr(T *ptr=0):_ptr(ptr) { }
+ AutoServantPtr(T *ptr=0):_ptr(ptr),_ph(0) { }
+ void setHolder(POAHolder *ph) { _ph=ph; }
~AutoServantPtr() { destroyPtr(); }
bool operator==(const AutoServantPtr& other) const { return _ptr==other._ptr; }
bool operator==(const T *other) const { return _ptr==other; }
operator T *() { return _ptr; }
operator const T *() const { return _ptr; }
private:
- void destroyPtr() { if(!_ptr) return; }
+ void destroyPtr()
+ {
+ if(!_ptr)
+ return;
+ if(!_ph)
+ throw Exception("AutoServantPtr : null POA holder !");
+ _ph->enforcedRelease();
+ }
private:
T *_ptr;
+ POAHolder *_ph;
};
}
using namespace SALOMESDS;
+int BasicDataServer::POA_CNT=0;
+
BasicDataServer::BasicDataServer(DataScopeServer *father, const std::string& varName):_father(father),_var_name(varName)
{
+ PortableServer::POA_var poa(_father->getPOA());
+ PortableServer::POAManager_var pman(poa->the_POAManager());
+ CORBA::Object_var obj(_father->getORB()->resolve_initial_references("RootPOA"));
+ PortableServer::POA_var rootPOA(PortableServer::POA::_narrow(obj));
+ CORBA::PolicyList policies;
+ policies.length(1);
+ PortableServer::ThreadPolicy_var threadPol(rootPOA->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL));
+ policies[0]=PortableServer::ThreadPolicy::_duplicate(threadPol);
+ std::ostringstream poaName; poaName << "POA_" << POA_CNT++ << "_" << _var_name;
+ _poa=rootPOA->create_POA(poaName.str().c_str(),pman,policies);
+ threadPol->destroy();
}
SALOME::DataScopeServer_ptr BasicDataServer::getMyDataScopeServer()
{
- CORBA::Object_var obj(getPOA()->servant_to_reference(_father));
+ CORBA::Object_var obj(_father->getPOA()->servant_to_reference(_father));
return SALOME::DataScopeServer::_narrow(obj);
}
enforcedRelease();
}
-PortableServer::POA_var BasicDataServer::getPOA() const
-{
- return _father->getPOA();
-}
public:
std::string getVarNameCpp() const { return _var_name; }
protected:
- PortableServer::POA_var getPOA() const;
+ PortableServer::POA_var getPOA() const { return _poa; }
protected:
DataScopeServer *_father;
private:
std::string _var_name;
+ PortableServer::POA_var _poa;
+ static int POA_CNT;
};
}
PyObject *getLocals() const { return _locals; }
PyObject *getPickler() const { return _pickler; }
PortableServer::POA_var getPOA() { return _poa; }
+ CORBA::ORB_var getORB() { return _orb; }
static std::string BuildTmpVarNameFrom(const std::string& varName);
private:
std::vector< std::string> getAllVarNames() const;
return ret;
}
-void RefCountServ::enforcedRelease()
-{
- PortableServer::POA_var poa(getPOA());
- PortableServer::ObjectId_var oid(poa->servant_to_id(this));
- poa->deactivate_object(oid);
- _remove_ref();
-}
-
RefCountServ::RefCountServ():_cnt(1)
{
}
void incrRef() const;
bool decrRef() const;
protected:
- void enforcedRelease();
RefCountServ();
RefCountServ(const RefCountServ& other);
virtual ~RefCountServ();
FromByteSeqToVB(constValue,_data);
}
+void TransactionVarCreate::prepareRollBackInCaseOfFailure()
+{//nothing it is not a bug
+}
+
void TransactionVarCreate::checkAliveAndKicking()
{
SALOME::DataScopeServer_var dsc(_tf->getDSM()->retriveDataScope(_scope_name.c_str()));
public:
Transaction(TransactionFactory *tf, const std::string& varName, const std::string& scopeName):_tf(tf),_var_name(varName),_scope_name(scopeName) { }
virtual void checkAliveAndKicking();
+ virtual void prepareRollBackInCaseOfFailure() = 0;
public:
static void FromByteSeqToVB(const SALOME::ByteVec& bsToBeConv, std::vector<unsigned char>& ret);
protected:
public:
TransactionVarCreate(TransactionFactory *tf, const std::string& varName, const std::string& scopeName, const SALOME::ByteVec& constValue);
void checkAliveAndKicking();
+ void prepareRollBackInCaseOfFailure();
protected:
std::vector<unsigned char> _data;
};
}
elt->_remove_ref();
transactionsCpp[i]=elt;
+ transactionsCpp[i].setHolder(this);
}
+ for(std::size_t i=0;i<sz;i++)
+ transactionsCpp[i]->checkAliveAndKicking();
}
{
class DataServerManager;
- class SALOMESDS_EXPORT TransactionFactory : public virtual POA_SALOME::TransactionFactory
+ class SALOMESDS_EXPORT TransactionFactory : public virtual POA_SALOME::TransactionFactory, POAHolder
{
public:
TransactionFactory(DataServerManager *dsm);