diff options
Diffstat (limited to 'cpp/src/IceGrid/QueryI.cpp')
-rw-r--r-- | cpp/src/IceGrid/QueryI.cpp | 101 |
1 files changed, 6 insertions, 95 deletions
diff --git a/cpp/src/IceGrid/QueryI.cpp b/cpp/src/IceGrid/QueryI.cpp index 1ddac7287d9..ae39a17b2cb 100644 --- a/cpp/src/IceGrid/QueryI.cpp +++ b/cpp/src/IceGrid/QueryI.cpp @@ -17,55 +17,9 @@ using namespace std; using namespace Ice; using namespace IceGrid; -template<class T> -class GetObjectProxy : public ObjectAllocationRequest -{ - typedef IceUtil::Handle<T> TPtr; - -public: - - GetObjectProxy(const SessionIPtr& session, const TPtr& cb) : - ObjectAllocationRequest(session), _cb(cb) - { - } - - virtual void - response(const Ice::ObjectPrx& proxy) - { - assert(_cb); - _cb->ice_response(proxy); - _cb = 0; - } - - virtual void - exception(const AllocationException& ex) - { - assert(_cb); - _cb->ice_response(0); - _cb = 0; - } - - virtual bool - allocateOnce() - { - return true; // Only allow one allocation - } - -private: - - TPtr _cb; -}; - -template<class T> static GetObjectProxy<T>* -newGetObjectProxy(const SessionIPtr& session, const IceUtil::Handle<T>& cb) -{ - return new GetObjectProxy<T>(session, cb); -} - -QueryI::QueryI(const CommunicatorPtr& communicator, const DatabasePtr& database, const SessionIPtr& session) : +QueryI::QueryI(const CommunicatorPtr& communicator, const DatabasePtr& database) : _communicator(communicator), - _database(database), - _session(session) + _database(database) { } @@ -78,18 +32,7 @@ QueryI::findObjectById_async(const AMD_Query_findObjectByIdPtr& cb, const Ice::I { try { - if(_session) - { - _database->allocateObject(id, newGetObjectProxy(_session, cb)); - } - else - { - cb->ice_response(_database->getObjectProxy(id)); - } - } - catch(const NotAllocatableException&) - { - cb->ice_response(0); + cb->ice_response(_database->getObjectProxy(id, 0)); } catch(const ObjectNotRegisteredException&) { @@ -102,18 +45,7 @@ QueryI::findObjectByType_async(const AMD_Query_findObjectByTypePtr& cb, const st { try { - if(_session) - { - _database->allocateObjectByType(type, newGetObjectProxy(_session, cb)); - } - else - { - cb->ice_response(_database->getObjectByType(type)); - } - } - catch(const NotAllocatableException&) - { - cb->ice_response(0); + cb->ice_response(_database->getObjectByType(type)); } catch(const ObjectNotRegisteredException&) { @@ -129,18 +61,7 @@ QueryI::findObjectByTypeOnLeastLoadedNode_async(const AMD_Query_findObjectByType { try { - if(_session) - { - _database->allocateObjectByTypeOnLeastLoadedNode(type, newGetObjectProxy(_session, cb), sample); - } - else - { - cb->ice_response(_database->getObjectByTypeOnLeastLoadedNode(type, sample)); - } - } - catch(const NotAllocatableException&) - { - cb->ice_response(0); + cb->ice_response(_database->getObjectByTypeOnLeastLoadedNode(type, sample)); } catch(const ObjectNotRegisteredException&) { @@ -155,17 +76,7 @@ QueryI::findAllObjectsByType_async(const AMD_Query_findAllObjectsByTypePtr& cb, { try { - if(_session) - { - // - // We don't allow allocating multiple objects. - // - cb->ice_response(Ice::ObjectProxySeq()); - } - else - { - cb->ice_response(_database->getObjectsByType(type)); - } + cb->ice_response(_database->getObjectsByType(type)); } catch(const ObjectNotRegisteredException&) { |