示例#1
0
        protected override void OnOpened()
        {
            base.OnOpened();

            if (WcfEventSource.Instance.ListenerOpenStopIsEnabled())
            {
                WcfEventSource.Instance.ListenerOpenStop(_eventTraceActivity);
                _eventTraceActivity = null; // clear this since we don't need this anymore.
            }

            _errorBehavior = new ErrorBehavior(this);

            _filterTable = new EndpointDispatcherTable(this.ThisLock);
            for (int i = 0; i < _endpointDispatchers.Count; i++)
            {
                EndpointDispatcher endpoint = _endpointDispatchers[i];

                // Force a build of the runtime to catch any unexpected errors before we are done opening.
                // Lock down the DispatchRuntime.
                endpoint.DispatchRuntime.LockDownProperties();

                _filterTable.AddEndpoint(endpoint);
            }

            IListenerBinder binder = ListenerBinder.GetBinder(_listener, _messageVersion);

            _listenerHandler = new ListenerHandler(binder, this, _timeouts);
            _listenerHandler.Open();  // This never throws, which is why it's ok for it to happen in OnOpened
        }
 internal ListenerHandler(IListenerBinder listenerBinder, System.ServiceModel.Dispatcher.ChannelDispatcher channelDispatcher, ServiceHostBase host, ServiceThrottle throttle, IDefaultCommunicationTimeouts timeouts)
 {
     this.listenerBinder = listenerBinder;
     if (this.listenerBinder == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("listenerBinder");
     }
     this.channelDispatcher = channelDispatcher;
     if (this.channelDispatcher == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("channelDispatcher");
     }
     this.host = host;
     if (this.host == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("host");
     }
     this.throttle = throttle;
     if (this.throttle == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("throttle");
     }
     this.timeouts = timeouts;
     this.endpoints = channelDispatcher.EndpointDispatcherTable;
     this.acceptor = new ErrorHandlingAcceptor(listenerBinder, channelDispatcher);
 }
        internal ListenerHandler(IListenerBinder listenerBinder, ChannelDispatcher channelDispatcher, ServiceHostBase host, ServiceThrottle throttle, IDefaultCommunicationTimeouts timeouts)
        {
            this.listenerBinder = listenerBinder;
            if (!((this.listenerBinder != null)))
            {
                Fx.Assert("ListenerHandler.ctor: (this.listenerBinder != null)");
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("listenerBinder");
            }

            this.channelDispatcher = channelDispatcher;
            if (!((this.channelDispatcher != null)))
            {
                Fx.Assert("ListenerHandler.ctor: (this.channelDispatcher != null)");
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("channelDispatcher");
            }

            this.host = host;
            if (!((this.host != null)))
            {
                Fx.Assert("ListenerHandler.ctor: (this.host != null)");
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("host");
            }

            this.throttle = throttle;
            if (!((this.throttle != null)))
            {
                Fx.Assert("ListenerHandler.ctor: (this.throttle != null)");
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("throttle");
            }

            this.timeouts = timeouts;

            this.endpoints = channelDispatcher.EndpointDispatcherTable;
            this.acceptor  = new ErrorHandlingAcceptor(listenerBinder, channelDispatcher);
        }
示例#4
0
        private void OnRemoveEndpoint(EndpointDispatcher endpoint)
        {
            lock (ThisLock)
            {
                if (State == CommunicationState.Opened)
                {
                    EndpointDispatcherTable.RemoveEndpoint(endpoint);
                }

                endpoint.Detach(this);
            }
        }
示例#5
0
        private void OnAddEndpoint(EndpointDispatcher endpoint)
        {
            lock (ThisLock)
            {
                endpoint.Attach(this);

                if (State == CommunicationState.Opened)
                {
                    EndpointDispatcherTable.AddEndpoint(endpoint);
                }
            }
        }
        protected override void OnOpened()
        {
            ThrowIfNotAttachedToHost();
            base.OnOpened();

            if (TD.ListenerOpenStopIsEnabled())
            {
                TD.ListenerOpenStop(this.eventTraceActivity);
                this.eventTraceActivity = null; // clear this since we don't need this anymore.
            }

            this.errorBehavior = new ErrorBehavior(this);

            this.filterTable = new EndpointDispatcherTable(this.ThisLock);
            for (int i = 0; i < this.endpointDispatchers.Count; i++)
            {
                EndpointDispatcher endpoint = this.endpointDispatchers[i];

                // Force a build of the runtime to catch any unexpected errors before we are done opening.
                endpoint.DispatchRuntime.GetRuntime();
                // Lock down the DispatchRuntime.
                endpoint.DispatchRuntime.LockDownProperties();

                this.filterTable.AddEndpoint(endpoint);

                if ((this.addressTable != null) && (endpoint.OriginalAddress != null))
                {
                    this.addressTable.Add(endpoint.AddressFilter, endpoint.OriginalAddress, endpoint.FilterPriority);
                }

                if (DiagnosticUtility.ShouldTraceInformation)
                {
                    this.TraceEndpointLifetime(endpoint, TraceCode.EndpointListenerOpen, SR.GetString(SR.TraceCodeEndpointListenerOpen));
                }
            }

            ServiceThrottle throttle = this.serviceThrottle;

            if (throttle == null)
            {
                throttle = this.host.ServiceThrottle;
            }

            IListenerBinder binder = ListenerBinder.GetBinder(this.listener, this.messageVersion);

            this.listenerHandler = new ListenerHandler(binder, this, this.host, throttle, this.timeouts);
            this.listenerHandler.Open();  // This never throws, which is why it's ok for it to happen in OnOpened
        }
示例#7
0
        internal ListenerHandler(IListenerBinder listenerBinder, ChannelDispatcher channelDispatcher, IDefaultCommunicationTimeouts timeouts)
        {
            _listenerBinder = listenerBinder;
            if (!((_listenerBinder != null)))
            {
                Fx.Assert("ListenerHandler.ctor: (this.listenerBinder != null)");
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("listenerBinder");
            }

            _channelDispatcher = channelDispatcher;
            if (!((_channelDispatcher != null)))
            {
                Fx.Assert("ListenerHandler.ctor: (this.channelDispatcher != null)");
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("channelDispatcher");
            }

            _timeouts = timeouts;

            _endpoints = channelDispatcher.EndpointDispatcherTable;
        }
示例#8
0
        internal ListenerHandler(IListenerBinder listenerBinder, ChannelDispatcher channelDispatcher, IDefaultCommunicationTimeouts timeouts)
        {
            _listenerBinder = listenerBinder;
            if (!((_listenerBinder != null)))
            {
                Fx.Assert("ListenerHandler.ctor: (this.listenerBinder != null)");
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("listenerBinder");
            }

            _channelDispatcher = channelDispatcher;
            if (!((_channelDispatcher != null)))
            {
                Fx.Assert("ListenerHandler.ctor: (this.channelDispatcher != null)");
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("channelDispatcher");
            }

            _timeouts = timeouts;

            _endpoints = channelDispatcher.EndpointDispatcherTable;
        }