Beispiel #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, 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);
        }
 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);
 }
Beispiel #4
0
        protected override void OnOpened()
        {
            this.ThrowIfNotAttachedToHost();
            base.OnOpened();
            this.errorBehavior = new ErrorBehavior(this);
            this.filterTable   = new System.ServiceModel.Dispatcher.EndpointDispatcherTable(base.ThisLock);
            for (int i = 0; i < this.endpointDispatchers.Count; i++)
            {
                EndpointDispatcher endpoint = this.endpointDispatchers[i];
                endpoint.DispatchRuntime.GetRuntime();
                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, 0x40008, System.ServiceModel.SR.GetString("TraceCodeEndpointListenerOpen"));
                }
            }
            System.ServiceModel.Dispatcher.ServiceThrottle serviceThrottle = this.serviceThrottle;
            if (serviceThrottle == null)
            {
                serviceThrottle = this.host.ServiceThrottle;
            }
            IListenerBinder listenerBinder = ListenerBinder.GetBinder(this.listener, this.messageVersion);

            this.listenerHandler = new ListenerHandler(listenerBinder, this, this.host, serviceThrottle, this.timeouts);
            this.listenerHandler.Open();
        }
Beispiel #5
0
        internal ErrorHandlingAcceptor(IListenerBinder binder, ChannelDispatcher dispatcher)
        {
            if (binder == null)
            {
                Fx.Assert("binder is null");
            }
            if (dispatcher == null)
            {
                Fx.Assert("dispatcher is null");
            }

            this.binder     = binder;
            this.dispatcher = dispatcher;
        }
        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
        }
Beispiel #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;
        }
Beispiel #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;
        }
Beispiel #9
0
        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(nameof(listenerBinder));
            }

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

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

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

            this.timeouts = timeouts;

            //endpoints = channelDispatcher.EndpointDispatcherTable;
            acceptor           = new ErrorHandlingAcceptor(listenerBinder, channelDispatcher);
            closingTokenSource = new CancellationTokenSource();
        }
 internal ErrorHandlingAcceptor(IListenerBinder binder, ChannelDispatcher dispatcher)
 {
     this.binder     = binder;
     this.dispatcher = dispatcher;
 }