Exemplo n.º 1
0
        public override void addObserver(ServiceObserverPrx observer, Ice.Current current)
        {
            List <string> activeServices = new List <string>();

            //
            // Null observers and duplicate registrations are ignored
            //

            _m.Lock();
            try
            {
                if (observer != null)
                {
                    try
                    {
                        _observers.Add(observer, true);
                    }
                    catch (ArgumentException)
                    {
                        return;
                    }

                    if (_traceServiceObserver >= 1)
                    {
                        _logger.trace("IceBox.ServiceObserver",
                                      "Added service observer " + _communicator.proxyToString(observer));
                    }

                    foreach (ServiceInfo info in _services)
                    {
                        if (info.status == ServiceStatus.Started)
                        {
                            activeServices.Add(info.name);
                        }
                    }
                }
            }
            finally
            {
                _m.Unlock();
            }

            if (activeServices.Count > 0)
            {
                observer.begin_servicesStarted(activeServices.ToArray(), this.observerCompleted, null);
            }
        }
Exemplo n.º 2
0
        public override void addObserver(ServiceObserverPrx observer, Ice.Current current)
        {
            List<string> activeServices = new List<string>();

            //
            // Null observers and duplicate registrations are ignored
            //

            lock(this)
            {
            if(observer != null)
            {
                try
                {
                    _observers.Add(observer, true);
                }
                catch(ArgumentException)
                {
                    return;
                }

                if(_traceServiceObserver >= 1)
                {
                    _logger.trace("IceBox.ServiceObserver",
                                  "Added service observer " + _communicator.proxyToString(observer));
                }

                foreach(ServiceInfo info in _services)
                {
                    if(info.status == ServiceStatus.Started)
                    {
                        activeServices.Add(info.name);
                    }
                }
            }
            }

            if(activeServices.Count > 0)
            {
            observer.begin_servicesStarted(activeServices.ToArray(), this.observerCompleted, null);
            }
        }