// ********************************************************************** // // Copyright (c) 2002 // ZeroC, Inc. // Billerica, MA, USA // // All Rights Reserved. // // Ice is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License version 2 as published by // the Free Software Foundation. // // ********************************************************************** #include #include // We need ObjectAdapterI, not ObjectAdapter, because of inc/decDirectCount(). #include #include #include #include using namespace std; using namespace Ice; using namespace IceInternal; IceInternal::Direct::Direct(const Current& current) : _current(current) { dynamic_cast(_current.adapter.get())->incDirectCount(); try { _servant = _current.adapter->identityToServant(_current.id); if(!_servant && !_current.id.category.empty()) { _locator = _current.adapter->findServantLocator(_current.id.category); if(_locator) { _servant = _locator->locate(_current, _cookie); } } if(!_servant) { _locator = _current.adapter->findServantLocator(""); if(_locator) { _servant = _locator->locate(_current, _cookie); } } if(!_servant) { ObjectNotExistException ex(__FILE__, __LINE__); ex.id = _current.id; ex.facet = _current.facet; ex.operation = _current.operation; throw ex; } if(!_current.facet.empty()) { _facetServant = _servant->ice_findFacetPath(_current.facet, 0); if(!_facetServant) { FacetNotExistException ex(__FILE__, __LINE__); ex.id = _current.id; ex.facet = _current.facet; ex.operation = _current.operation; throw ex; } } } catch(...) { if(_locator && _servant) { try { _locator->finished(_current, _servant, _cookie); } catch(...) { dynamic_cast(_current.adapter.get())->decDirectCount(); throw; } } dynamic_cast(_current.adapter.get())->decDirectCount(); throw; } } IceInternal::Direct::~Direct() { if(_locator && _servant) { try { _locator->finished(_current, _servant, _cookie); } catch(...) { dynamic_cast(_current.adapter.get())->decDirectCount(); throw; } } dynamic_cast(_current.adapter.get())->decDirectCount(); } const ObjectPtr& IceInternal::Direct::facetServant() { if(_facetServant) { return _facetServant; } else { return _servant; } }