From bf3729b95ca9928b07babe4f1216883cdc37086b Mon Sep 17 00:00:00 2001 From: Benoit Foucher Date: Fri, 28 Apr 2006 16:24:03 +0000 Subject: More allocation fixes, removed session based Query interface. --- cpp/src/IceGrid/SessionI.cpp | 65 +++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 31 deletions(-) (limited to 'cpp/src/IceGrid/SessionI.cpp') diff --git a/cpp/src/IceGrid/SessionI.cpp b/cpp/src/IceGrid/SessionI.cpp index 34af6687ca9..e4cc9d55913 100644 --- a/cpp/src/IceGrid/SessionI.cpp +++ b/cpp/src/IceGrid/SessionI.cpp @@ -16,20 +16,26 @@ using namespace std; using namespace IceGrid; +namespace IceGrid +{ + +template class AllocateObject : public ObjectAllocationRequest { + typedef IceUtil::Handle TPtr; + public: - AllocateObject(const SessionIPtr& session, const AMD_Session_allocateObjectPtr& cb) : + AllocateObject(const SessionIPtr& session, const TPtr& cb) : ObjectAllocationRequest(session), _cb(cb) { } - virtual void + virtual void response(const Ice::ObjectPrx& proxy) { assert(_cb); - _cb->ice_response(); + _cb->ice_response(proxy); _cb = 0; } @@ -41,15 +47,23 @@ public: _cb = 0; } - virtual bool - allocateOnce() + virtual bool + allocateOnce() { return true; // Only allow one allocation } private: - AMD_Session_allocateObjectPtr _cb; + TPtr _cb; +}; + +template static AllocateObject* +newAllocateObject(const SessionIPtr& session, const IceUtil::Handle& cb) +{ + return new AllocateObject(session, cb); +} + }; SessionReapable::SessionReapable(const SessionIPtr& session, const SessionPrx& proxy) : @@ -100,7 +114,6 @@ SessionI::SessionI(const string& userId, // Register session based query and locator interfaces // Ice::CommunicatorPtr com = adapter->getCommunicator(); - _query = QueryPrx::uncheckedCast(adapter->addWithUUID(new QueryI(com, _database, this))); _locator = Ice::LocatorPrx::uncheckedCast(adapter->addWithUUID(new LocatorI(com, _database, registry, this))); } @@ -134,12 +147,6 @@ SessionI::getTimeout(const Ice::Current&) const return _timeout; } -QueryPrx -SessionI::getQuery(const Ice::Current& current) const -{ - return _query; -} - Ice::LocatorPrx SessionI::getLocator(const Ice::Current& current) const { @@ -147,29 +154,25 @@ SessionI::getLocator(const Ice::Current& current) const } void -SessionI::allocateObject_async(const AMD_Session_allocateObjectPtr& cb, const Ice::ObjectPrx& prx, const Ice::Current&) +SessionI::allocateObjectById_async(const AMD_Session_allocateObjectByIdPtr& cb, + const Ice::Identity& id, + const Ice::Current&) { - // - // TODO: Check if the proxy points to a replicated object and eventually throw if that's the case. - // - if(!prx) - { - throw AllocationException("proxy is null"); - } - _database->allocateObject(prx->ice_getIdentity(), new AllocateObject(this, cb)); + _database->allocateObject(id, newAllocateObject(this, cb)); } void -SessionI::releaseObject(const Ice::ObjectPrx& prx, const Ice::Current&) +SessionI::allocateObjectByType_async(const AMD_Session_allocateObjectByTypePtr& cb, + const string& type, + const Ice::Current&) { - // - // TODO: Check if the proxy points to a replicated object and eventually throw if that's the case. - // - if(!prx) - { - throw AllocationException("proxy is null"); - } - _database->releaseObject(prx->ice_getIdentity(), this); + _database->allocateObjectByType(type, newAllocateObject(this, cb)); +} + +void +SessionI::releaseObject(const Ice::Identity& id, const Ice::Current&) +{ + _database->releaseObject(id, this); } void -- cgit v1.2.3