public void Start()
        {
            if (_serviceHost != null)
            {
                throw new InvalidOperationException("Server is already started.");
            }

            var managementHandler = new ManagementTransferRequestHandler();

            managementHandler.Bind(Schema.DynamicMBeanResourceUri, new DynamicMBeanManagementRequestHandler(_server));
            managementHandler.Bind(Schema.MBeanServerResourceUri, new MBeanServerManagementRequestHandler(_server));

            var enumerationServer = new EnumerationServer();

            enumerationServer.Bind(Schema.DynamicMBeanResourceUri, Schema.QueryNamesDialect, typeof(string), new QueryNamesEnumerationRequestHandler(_server));
            enumerationServer.Bind(Schema.DynamicMBeanResourceUri, FilterMap.DefaultDialect, typeof(void), new IsRegisteredEnumerationRequestHandler(_server));

            var eventingServer = new EventingServer(new EventingRequestHandler(_server));

            eventingServer.Bind(Schema.NotificationDialect, typeof(NotificationFilter));
            eventingServer.EnablePullDeliveryUsing(enumerationServer.PullServer);

            var extensionHandler = new Jsr262ExtensionMethodHandler(_server);

            _serviceHost = new HttpListenerTransferEndpoint(_serviceUrl,
                                                            new TransferServer(managementHandler),
                                                            enumerationServer,
                                                            enumerationServer,
                                                            eventingServer,
                                                            extensionHandler);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            XmlConfigurator.Configure();

            var eventingServer = new EventingServer(new RequestHandler());
            var pullServer     = new PullServer();

            eventingServer.EnablePullDeliveryUsing(pullServer);
            eventingServer.Bind(FilterMap.DefaultDialect, typeof(JmxNotificationFilter));

            Console.WriteLine("WARNING! TimedOut exception which will cause your Visual Studio to break into");
            Console.WriteLine("debugging mode are part of WS-Eventing protocol and should be skipped");
            Console.WriteLine("with F5 while debugging.");
            Console.WriteLine();

            var client = new EventingClient("http://localhost:12345/Eventing");

            client.BindFilterDialect(FilterMap.DefaultDialect, typeof(JmxNotificationFilter));

            using (new HttpListenerTransferEndpoint("http://localhost:12345/", eventingServer, pullServer))
            {
                using (client.SubscribeUsingPullDelivery <EventData>(
                           x => Console.WriteLine(x.Value),
                           true,
                           new Filter(FilterMap.DefaultDialect, new JmxNotificationFilter())))
                {
                    Console.WriteLine("Press any key to exit.");
                    Console.ReadKey();
                }
            }
        }