Ejemplo n.º 1
0
        public Ice.ObjectAdapter createObjectAdapter(string name, Ice.RouterPrx router)
        {
            lock (this)
            {
                if (instance_ == null)
                {
                    throw new Ice.CommunicatorDestroyedException();
                }

                Ice.ObjectAdapterI adapter = null;
                if (name.Length == 0)
                {
                    string uuid = System.Guid.NewGuid().ToString();
                    adapter = new Ice.ObjectAdapterI(instance_, _communicator, this, uuid, null, true);
                }
                else
                {
                    if (_adapterNamesInUse.Contains(name))
                    {
                        Ice.AlreadyRegisteredException ex = new Ice.AlreadyRegisteredException();
                        ex.kindOfObject = "object adapter";
                        ex.id           = name;
                        throw ex;
                    }
                    adapter = new Ice.ObjectAdapterI(instance_, _communicator, this, name, router, false);
                    _adapterNamesInUse.Add(name);
                }
                _adapters.Add(adapter);
                return(adapter);
            }
        }
Ejemplo n.º 2
0
        public Ice.ObjectAdapter createObjectAdapter(string name, Ice.RouterPrx router)
        {
            lock(this)
            {
                if(instance_ == null)
                {
                    throw new Ice.CommunicatorDestroyedException();
                }

                Ice.ObjectAdapterI adapter = null;
                if(name.Length == 0)
                {
                    string uuid = System.Guid.NewGuid().ToString();
                    adapter = new Ice.ObjectAdapterI(instance_, _communicator, this, uuid, null, true);
                }
                else
                {
                    if(_adapterNamesInUse.Contains(name))
                    {
                        Ice.AlreadyRegisteredException ex = new Ice.AlreadyRegisteredException();
                        ex.kindOfObject = "object adapter";
                        ex.id = name;
                        throw ex;
                    }
                    adapter = new Ice.ObjectAdapterI(instance_, _communicator, this, name, router, false);
                    _adapterNamesInUse.Add(name);
                }
                _adapters.Add(adapter);
                return adapter;
            }
        }
Ejemplo n.º 3
0
        public CollocatedRequestHandler(Reference @ref, Ice.ObjectAdapter adapter)
        {
            _reference = @ref;
            _dispatcher = _reference.getInstance().initializationData().dispatcher != null;
            _response = _reference.getMode() == Reference.Mode.ModeTwoway;
            _adapter = (Ice.ObjectAdapterI)adapter;

            _logger = _reference.getInstance().initializationData().logger; // Cached for better performance.
            _traceLevels = _reference.getInstance().traceLevels(); // Cached for better performance.
            _requestId = 0;
        }
Ejemplo n.º 4
0
        public void removeObjectAdapter(Ice.ObjectAdapterI adapter)
        {
            lock (this)
            {
                if (_instance == null)
                {
                    return;
                }

                _adapters.Remove(adapter);
                _adapterNamesInUse.Remove(adapter.getName());
            }
        }
Ejemplo n.º 5
0
        public void destroy()
        {
            Ice.ObjectAdapterI adapter = (Ice.ObjectAdapterI)_current.adapter;
            Debug.Assert(adapter != null);

            try
            {
                if (_locator != null && _servant != null)
                {
                    _locator.finished(_current, _servant, _cookie);
                }
            }
            finally
            {
                adapter.decDirectCount();
            }
        }
Ejemplo n.º 6
0
        public void removeObjectAdapter(Ice.ObjectAdapterI adapter)
        {
            _m.Lock();
            try
            {
                if (instance_ == null)
                {
                    return;
                }

                _adapters.Remove(adapter);
                _adapterNamesInUse.Remove(adapter.getName());
            }
            finally
            {
                _m.Unlock();
            }
        }
Ejemplo n.º 7
0
        public Ice.ObjectAdapter createObjectAdapter(string name, Ice.RouterPrx router)
        {
            lock (this)
            {
                if (_instance == null)
                {
                    throw new Ice.CommunicatorDestroyedException();
                }

                if (name.Length > 0)
                {
                    if (_adapterNamesInUse.Contains(name))
                    {
                        Ice.AlreadyRegisteredException ex = new Ice.AlreadyRegisteredException();
                        ex.kindOfObject = "object adapter";
                        ex.id           = name;
                        throw ex;
                    }
                    _adapterNamesInUse.Add(name);
                }
            }

            //
            // Must be called outside the synchronization since initialize can make client invocations
            // on the router if it's set.
            //
            Ice.ObjectAdapterI adapter = null;
            try
            {
                if (name.Length == 0)
                {
                    string uuid = System.Guid.NewGuid().ToString();
                    adapter = new Ice.ObjectAdapterI(_instance, _communicator, this, uuid, null, true);
                }
                else
                {
                    adapter = new Ice.ObjectAdapterI(_instance, _communicator, this, name, router, false);
                }

                lock (this)
                {
                    if (_instance == null)
                    {
                        throw new Ice.CommunicatorDestroyedException();
                    }
                    _adapters.Add(adapter);
                }
            }
            catch (Ice.CommunicatorDestroyedException ex)
            {
                if (adapter != null)
                {
                    adapter.destroy();
                }
                throw ex;
            }
            catch (Ice.LocalException ex)
            {
                if (name.Length > 0)
                {
                    lock (this)
                    {
                        _adapterNamesInUse.Remove(name);
                    }
                }
                throw ex;
            }

            return(adapter);
        }
Ejemplo n.º 8
0
        public Direct(Ice.Current current, RunDelegate run)
        {
            _current = current;
            _run     = run;

            Ice.ObjectAdapterI adapter = (Ice.ObjectAdapterI)_current.adapter;
            Debug.Assert(adapter != null);

            //
            // Must call incDirectCount() first, because it checks for
            // adapter deactivation, and prevents deactivation completion
            // until decDirectCount() is called. This is important,
            // because getServantManager() may not be called afer
            // deactivation completion.
            //
            adapter.incDirectCount();

            ServantManager servantManager = adapter.getServantManager();

            Debug.Assert(servantManager != null);

            _servant = servantManager.findServant(_current.id, _current.facet);
            if (_servant == null)
            {
                _locator = servantManager.findServantLocator(_current.id.category);
                if (_locator == null && _current.id.category.Length > 0)
                {
                    _locator = servantManager.findServantLocator("");
                }
                if (_locator != null)
                {
                    try
                    {
                        _servant = _locator.locate(_current, out _cookie);
                    }
                    catch (System.Exception)
                    {
                        adapter.decDirectCount();
                        throw;
                    }
                }
            }

            if (_servant == null)
            {
                adapter.decDirectCount();
                if (servantManager != null && servantManager.hasServant(_current.id))
                {
                    Ice.FacetNotExistException ex = new Ice.FacetNotExistException();
                    ex.id        = _current.id;
                    ex.facet     = _current.facet;
                    ex.operation = _current.operation;
                    throw ex;
                }
                else
                {
                    Ice.ObjectNotExistException ex = new Ice.ObjectNotExistException();
                    ex.id        = _current.id;
                    ex.facet     = _current.facet;
                    ex.operation = _current.operation;
                    throw ex;
                }
            }
        }