예제 #1
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();
                }
            }
        }
예제 #2
0
        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);
        }
예제 #3
0
 public ManagementServer()
 {
     _managementHandler  = new ManagementTransferRequestHandler();
     _transferServer     = new TransferServer(_managementHandler);
     _enumerationServer  = new EnumerationServer();
     _pullDeliveryServer = new EventingPullDeliveryServer();
     _eventingServer     = new EventingServer(_pullDeliveryServer);
 }
예제 #4
0
      public void If_invalid_subscription_context_specified_exception_is_thrown()
      {
         OperationContextProxy.Dummy.LocalAddress = ResourceUri;

         EventingServer server = new EventingServer();         
         server.Pull(new PullRequest
         {
            EnumerationContext = new EnumerationContextKey("aaa"),
         });
      }      
예제 #5
0
        public void If_invalid_subscription_context_specified_exception_is_thrown()
        {
            OperationContextProxy.Dummy.LocalAddress = ResourceUri;

            EventingServer server = new EventingServer();

            server.Pull(new PullRequest
            {
                EnumerationContext = new EnumerationContextKey("aaa"),
            });
        }
예제 #6
0
      public void If_pull_returns_no_items_exception_is_thrown()
      {
         IEventingRequestHandler<int> mockHandler = MockRepository.GenerateMock<IEventingRequestHandler<int>>();
         OperationContextProxy.Dummy.LocalAddress = ResourceUri;

         EventingServer server = new EventingServer();
         server.BindWithPullDelivery(ResourceUri, FilterMap.DefaultDialect, typeof(void), mockHandler, ResourceUri);
         SubscribeResponse subscribeResponse = server.Subscribe(ResourceUri.ToString(), null, new SubscribeRequest
             {
                Delivery = Delivery.Pull(),
                Expires = Expires.FromTimeSpan(TimeSpan.Zero)
             });
         server.Pull(new PullRequest
            {
               EnumerationContext = subscribeResponse.EnumerationContext,
            });
      }
예제 #7
0
        public void If_pull_returns_no_items_exception_is_thrown()
        {
            IEventingRequestHandler <int> mockHandler = MockRepository.GenerateMock <IEventingRequestHandler <int> >();

            OperationContextProxy.Dummy.LocalAddress = ResourceUri;

            EventingServer server = new EventingServer();

            server.BindWithPullDelivery(ResourceUri, FilterMap.DefaultDialect, typeof(void), mockHandler, ResourceUri);
            SubscribeResponse subscribeResponse = server.Subscribe(ResourceUri.ToString(), null, new SubscribeRequest
            {
                Delivery = Delivery.Pull(),
                Expires  = Expires.FromTimeSpan(TimeSpan.Zero)
            });

            server.Pull(new PullRequest
            {
                EnumerationContext = subscribeResponse.EnumerationContext,
            });
        }