コード例 #1
0
ファイル: Global.asax.cs プロジェクト: SzymonPobiega/NetMX
        private static void InitializeMBeanServer()
        {
            _beanServer = MBeanServerFactory.CreateMBeanServer();

             _beanServer.RegisterMBean(new RelationService(), RelationService.ObjectName);

             Sample sample1 = new Sample();
             Sample sample2 = new Sample();
             Sample sample3 = new Sample();
             _beanServer.RegisterMBean(sample1, "Sample:type=Sample,id=1");
             _beanServer.RegisterMBean(sample2, "Sample:type=Sample,id=2");
             _beanServer.RegisterMBean(sample3, "Sample:type=Sample,id=3");

             RelationServiceMBean relationSerice = NetMXProxyExtensions.NewMBeanProxy<RelationServiceMBean>(_beanServer, RelationService.ObjectName);
             relationSerice.CreateRelationType("Binding", new RoleInfo[] {
            new RoleInfo("Source", typeof(SampleMBean), true, false, 1, 1, "Source"),
            new RoleInfo("Destination", typeof(SampleMBean), true, false, 1, 1, "Destination")});

             relationSerice.CreateRelation("Rel1", "Binding", new Role[] {
            new Role("Source", new ObjectName("Sample:type=Sample,id=1")),
            new Role("Destination", new ObjectName("Sample:type=Sample,id=2"))});

             relationSerice.CreateRelation("Rel2", "Binding", new Role[] {
            new Role("Source", new ObjectName("Sample:type=Sample,id=1")),
            new Role("Destination", new ObjectName("Sample:type=Sample,id=3"))});

             Uri serviceUrl = new Uri("net.pipe://localhost/MBeanServer");

             _connectorServer = NetMXConnectorServerFactory.NewNetMXConnectorServer(serviceUrl, _beanServer);
             _connectorServer.Start();
        }
コード例 #2
0
ファイル: TestBase.cs プロジェクト: SzymonPobiega/NetMX
        public void Initialize()
        {
            Server = MBeanServerFactory.CreateMBeanServer();

            Server.RegisterMBean(new Sample(), "sample:a=b");
            var dynamicMBean = new SampleDynamicMBean();
            dynamicMBean.AddRow(1, "Simon");
            dynamicMBean.AddRow(2, "John");
            dynamicMBean.SetComposite(3, "Jane");
            dynamicMBean.SetArray(new[]{1, 2.5m, 4m, 5m});

            Server.RegisterMBean(dynamicMBean, "dynamic:a=b");

            Adaptor = new SelfHostingHttpAdaptor(Server, "http://localhost:12345/adaptor");
            Adaptor.Start();
        }
コード例 #3
0
        public void Initialize()
        {
            Server = MBeanServerFactory.CreateMBeanServer();

            Server.RegisterMBean(new Sample(), "sample:a=b");
            var dynamicMBean = new SampleDynamicMBean();

            dynamicMBean.AddRow(1, "Simon");
            dynamicMBean.AddRow(2, "John");
            dynamicMBean.SetComposite(3, "Jane");
            dynamicMBean.SetArray(new[] { 1, 2.5m, 4m, 5m });

            Server.RegisterMBean(dynamicMBean, "dynamic:a=b");

            Adaptor = new SelfHostingHttpAdaptor(Server, "http://localhost:12345/adaptor");
            Adaptor.Start();
        }
コード例 #4
0
 public void Initialize()
 {
     _bean = new Sample
                 {
                     Attribute = "Text"
                 };
     _server = new MBeanServer();
     _server.RegisterMBean(_bean, "sample:id=1");
 }
コード例 #5
0
 public void Initialize()
 {
     _bean = new Sample
     {
         Attribute = "Text"
     };
     _server = new MBeanServer();
     _server.RegisterMBean(_bean, "sample:id=1");
 }
コード例 #6
0
        public void Initialize()
        {
            _server = new NetMX.Default.MBeanServer();
             _relationService = new RelationService();
             _server.RegisterMBean(_relationService, ":type=RelationService");

             _parent = new Parent();
             _server.RegisterMBean(_parent, ":type=Parent");
             _child1 = new Child();
             _server.RegisterMBean(_child1, ":type=Child,id=1");
             _child2 = new Child();
             _server.RegisterMBean(_child2, ":type=Child,id=2");

             _relationService.CreateRelationType("Parenthood",
            new RoleInfo[] {
               new RoleInfo("Parent", typeof(ParentMBean), true, true, 1, 1, "Parent"),
               new RoleInfo("Child", typeof(ChildMBean), true, true, 0, RoleInfo.RoleCardinalityInfinity, "Child") });
        }
コード例 #7
0
        public void Initialize()
        {
            _server          = new MBeanServer();
            _relationService = new RelationService();
            _server.RegisterMBean(_relationService, ":type=RelationService");

            _parent = new Parent();
            _server.RegisterMBean(_parent, ":type=Parent");
            _child1 = new Child();
            _server.RegisterMBean(_child1, ":type=Child,id=1");
            _child2 = new Child();
            _server.RegisterMBean(_child2, ":type=Child,id=2");

            _relationService.CreateRelationType("Parenthood",
                                                new RoleInfo[] {
                new RoleInfo("Parent", typeof(ParentMBean), true, true, 1, 1, "Parent"),
                new RoleInfo("Child", typeof(ChildMBean), true, true, 0, RoleInfo.RoleCardinalityInfinity, "Child")
            });
        }
コード例 #8
0
        public void SetUp()
        {
            _bean1   = new Test();
            _server1 = MBeanServerFactory.CreateMBeanServer("1");
            _server1.RegisterMBean(_bean1, "someDomain:t=test");

            _bean2   = new Test();
            _server2 = MBeanServerFactory.CreateMBeanServer("2");
            _server2.RegisterMBean(_bean2, "someDomain:t=test");

            _bean3   = new Test();
            _server3 = MBeanServerFactory.CreateMBeanServer("3");
            _server3.RegisterMBean(_bean3, "someDomain:t=test");
            _server3.RegisterMBean(_bean3, "invalidPrefix.someDomain:t=test");

            _aggregateConnection = new AggregateMBeanServerConnection(_server3);
            _aggregateConnection.AddChildServer("one", _server1);
            _aggregateConnection.AddChildServer("two", _server2);
        }
コード例 #9
0
ファイル: LoadBalancer.cs プロジェクト: terceser/LoadBalancer
        public static bool initializeServerMBean()
        {
            if (!initializedServerMBean)
            {
                server = MBeanServerFactory.CreateMBeanServer();
                server1Counter = new Counter();
                server2Counter = new Counter();
                server3Counter = new Counter();
                name = new ObjectName("server1Counter:");
                name2 = new ObjectName("server2Counter:");
                name3 = new ObjectName("server3Counter:");
                server.RegisterMBean(server1Counter, name);
                server.RegisterMBean(server2Counter, name2);
                server.RegisterMBean(server3Counter, name3);
                Uri serviceUrl = new Uri(Global.Server.MBeansServer);
                connectorServer = NetMXConnectorServerFactory.NewNetMXConnectorServer(serviceUrl, server);
                connectorServer.Start();
                initializedServerMBean = true;
            }
            return true;

        }
コード例 #10
0
        public void SetUp()
        {
            _server = MBeanServerFactory.CreateMBeanServer();
            SimpleStandard o = new SimpleStandard();
            ObjectName name = new ObjectName("Tests:key=value");
            _server.RegisterMBean(o, name);
            Uri serviceUrl = GetUri();

            _connectorServer = GetConnectorServerFactory().NewNetMXConnectorServer(serviceUrl, _server);
            _connectorServer.Start();
            _connector = GetConnectorFactory().Connect(serviceUrl, null);
            _remoteServer = _connector.MBeanServerConnection;
        }
コード例 #11
0
 public void Initialize()
 {
     _firstBean = new Sample()
     {
         IntAttribute     = 1,
         LongAttribute    = 2,
         DoubleAttribute  = 3,
         DecimalAttribute = 4,
         StringAttribute  = "5"
     };
     _secondBean = new Sample()
     {
         IntAttribute     = 10,
         LongAttribute    = 20,
         DoubleAttribute  = 30,
         DecimalAttribute = 40,
         StringAttribute  = "50"
     };
     _server = new MBeanServer();
     _server.RegisterMBean(_firstBean, "sample:id=1");
     _server.RegisterMBean(_secondBean, "sample:id=2");
 }
コード例 #12
0
ファイル: Monitor.cs プロジェクト: yuzukwok/NetMX
        public ObjectName PreRegister(IMBeanServer server, ObjectName name)
        {
            _server = server;
            var timer = new Timer.Timer();
            IDictionary <string, string> props = name.KeyPropertyList;

            props.Add("EmbeddedTimer", "true");
            var timerName = new ObjectName(name.Domain, props);

            server.RegisterMBean(timer, timerName);
            _timer = _server.CreateDynamicProxy(timerName);
            _server.AddNotificationListener(timerName, OnTimerEvent, null, null);
            return(name);
        }
コード例 #13
0
        public void SetUp()
        {
            _server = MBeanServerFactory.CreateMBeanServer();
            SimpleStandard o    = new SimpleStandard();
            ObjectName     name = new ObjectName("Tests:key=value");

            _server.RegisterMBean(o, name);
            Uri serviceUrl = GetUri();

            _connectorServer = GetConnectorServerFactory().NewNetMXConnectorServer(serviceUrl, _server);
            _connectorServer.Start();
            _connector    = GetConnectorFactory().Connect(serviceUrl, null);
            _remoteServer = _connector.MBeanServerConnection;
        }
コード例 #14
0
        static void Main(string[] args)
        {
            IMBeanServer server = MBeanServerFactory.CreateMBeanServer();
            Counter      o      = new Counter();
            ObjectName   name   = new ObjectName("QuickStart:type=counter");

            server.RegisterMBean(o, name);

            Console.WriteLine("******");
            MBeanInfo info = server.GetMBeanInfo(name);

            Console.WriteLine("MBean description: {0}", info.Description);
            Console.WriteLine("MBean class name: {0}", info.ClassName);
            foreach (MBeanAttributeInfo attributeInfo in info.Attributes)
            {
                Console.WriteLine("Attribute {0} ({1}) [{2}{3}]: {4}", attributeInfo.Name, attributeInfo.Description,
                                  attributeInfo.Readable ? "r" : "", attributeInfo.Writable ? "w" : "", attributeInfo.Type);
            }
            foreach (MBeanOperationInfo operationInfo in info.Operations)
            {
                Console.WriteLine("Operation {0} ({1}) [{2}]", operationInfo.Name, operationInfo.Description,
                                  operationInfo.Impact);
            }
            Console.WriteLine("******");

            server.AddNotificationListener(name, CounterChanged, null, null);

            object counter = server.GetAttribute(name, "Value");

            Console.WriteLine("Counter value is {0}", counter);

            server.SetAttribute(name, "Value", 5);
            counter = server.GetAttribute(name, "Value");

            Console.WriteLine("Now, counter value is {0}", counter);

            counter = server.Invoke(name, "Add", new object[] { 5 });
            counter = server.GetAttribute(name, "Value");

            Console.WriteLine("Now, counter value is {0}", counter);

            counter = server.Invoke(name, "Reset", new object[] { });
            counter = server.GetAttribute(name, "Value");

            Console.WriteLine("Now, counter value is {0}", counter);

            server.RemoveNotificationListener(name, CounterChanged, null, null);

            Console.ReadKey();
        }
コード例 #15
0
        private void MapBean(ObjectName originalBeanName)
        {
            Dictionary <string, string> props = new Dictionary <string, string>(originalBeanName.KeyPropertyList);

            props.Add(_proxyIndicatorProperty, "true");
            ObjectName proxyName = new ObjectName(originalBeanName.Domain, props);

            MBeanInfo originalInfo = _server.GetMBeanInfo(originalBeanName);

            if (!(originalInfo is NetMX.OpenMBean.IOpenMBeanInfo))
            {
                ProxyBean proxyBean = new ProxyBean(originalInfo, originalBeanName, _typeCache);
                _server.RegisterMBean(proxyBean, proxyName);
            }
        }
コード例 #16
0
ファイル: Global.asax.cs プロジェクト: yuzukwok/NetMX
        private static void InitializeMBeanServer()
        {
            _beanServer = MBeanServerFactory.CreateMBeanServer();

            _beanServer.RegisterMBean(new RelationService(), RelationService.ObjectName);

            Sample sample1 = new Sample();
            Sample sample2 = new Sample();
            Sample sample3 = new Sample();

            _beanServer.RegisterMBean(sample1, "Sample:type=Sample,id=1");
            _beanServer.RegisterMBean(sample2, "Sample:type=Sample,id=2");
            _beanServer.RegisterMBean(sample3, "Sample:type=Sample,id=3");

            RelationServiceMBean relationSerice = NetMXProxyExtensions.NewMBeanProxy <RelationServiceMBean>(_beanServer, RelationService.ObjectName);

            relationSerice.CreateRelationType("Binding", new RoleInfo[] {
                new RoleInfo("Source", typeof(SampleMBean), true, false, 1, 1, "Source"),
                new RoleInfo("Destination", typeof(SampleMBean), true, false, 1, 1, "Destination")
            });

            relationSerice.CreateRelation("Rel1", "Binding", new Role[] {
                new Role("Source", new ObjectName("Sample:type=Sample,id=1")),
                new Role("Destination", new ObjectName("Sample:type=Sample,id=2"))
            });

            relationSerice.CreateRelation("Rel2", "Binding", new Role[] {
                new Role("Source", new ObjectName("Sample:type=Sample,id=1")),
                new Role("Destination", new ObjectName("Sample:type=Sample,id=3"))
            });

            Uri serviceUrl = new Uri("net.pipe://localhost/MBeanServer");

            _connectorServer = NetMXConnectorServerFactory.NewNetMXConnectorServer(serviceUrl, _beanServer);
            _connectorServer.Start();
        }
コード例 #17
0
ファイル: Program.cs プロジェクト: yuzukwok/NetMX
        static void Main(string[] args)
        {
            IMBeanServer server = MBeanServerFactory.CreateMBeanServer();
            Timer        timer  = new Timer();
            ObjectName   name   = new ObjectName("Timer:");

            server.RegisterMBean(timer, name);

            var timerBean = server.CreateDynamicProxy(name);

            timerBean.Start();
            server.AddNotificationListener(name, OnTimerEvent, null, null);

            Console.WriteLine("******");
            timerBean.AddNotification2("Type1", "Message1", 4, DateTime.Now.AddSeconds(2), new TimeSpan(0, 0, 0, 1));
            //timerBean.AddNotification4("Type1", "Message1", 4, DateTime.Now.AddSeconds(2), new TimeSpan(0,0,0,1),3,true);
            timerBean.SendPastNotifications = true;
            bool exit = false;

            while (!exit)
            {
                ConsoleKeyInfo info = Console.ReadKey();
                switch (char.ToUpper(info.KeyChar))
                {
                case 'X':
                    exit = true;
                    break;

                case 'S':
                    if (timerBean.IsActive)
                    {
                        timerBean.Stop();
                    }
                    else
                    {
                        timerBean.Start();
                    }
                    break;
                }
            }
        }
コード例 #18
0
ファイル: Program.cs プロジェクト: yuzukwok/NetMX
        static void Main(string[] args)
        {
            //Server side
            IMBeanServer     server       = MBeanServerFactory.CreateMBeanServer("PlatformMBeanServer");
            PerfCounterMBean processMBean = new PerfCounterMBean("Process", true, new[] { "% Processor Time" });

            server.RegisterMBean(processMBean, "CLR:type=Process");

            //Client side
            Console.WriteLine("Attributes of 'CLR:type=Process' MBean:");
            foreach (AttributeValue v in server.GetAttributes("CLR:type=Process", server.GetMBeanInfo("CLR:type=Process").Attributes.Select(x => x.Name).ToArray()))
            {
                Console.WriteLine("{0}: {1}", v.Name, v.Value);
            }
            Console.WriteLine();
            Console.WriteLine("Attributes of 'CLR:type=Memory' MBean:");
            foreach (AttributeValue v in server.GetAttributes("CLR:type=Memory", server.GetMBeanInfo("CLR:type=Memory").Attributes.Select(x => x.Name).ToArray()))
            {
                Console.WriteLine("{0}: {1}", v.Name, v.Value);
            }
            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
コード例 #19
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
            IMBeanServer server = MBeanServerFactory.CreateMBeanServer();
            Sample       o      = new Sample();
            ObjectName   name   = new ObjectName("Sample:");

            server.RegisterMBean(o, name);
            Uri serviceUrl = new Uri("http://localhost:1010/MBeanServer");

            using (INetMXConnectorServer connectorServer = NetMXConnectorServerFactory.NewNetMXConnectorServer(serviceUrl, server))
            {
                connectorServer.Start();

                using (INetMXConnector connector = NetMXConnectorFactory.Connect(serviceUrl, null))
                {
                    IMBeanServerConnection remoteServer = connector.MBeanServerConnection;
                    //MBeanInfo metadata = remoteServer.GetMBeanInfo(name);
                    object counter = remoteServer.GetAttribute(name, "Counter");
                    Console.WriteLine("Counter value is {0}", counter);
                    //remoteServer.SetAttribute(name, "Counter", 1);
                    //counter = remoteServer.GetAttribute(name, "Counter");
                    //Console.WriteLine("Counter value is {0}", counter);
                    //int beanCount = remoteServer.GetMBeanCount();
                    //Console.WriteLine("MBean count is {0}", beanCount);
                    //string defaultDomain = remoteServer.GetDefaultDomain();
                    //Console.WriteLine("Default domain is {0}", defaultDomain);
                    //string domains = string.Join(", ", remoteServer.GetDomains().ToArray());
                    //Console.WriteLine("Registered domains: {0}", domains);
                    //Console.WriteLine("Is {0} instance of {1}: {2}", name, typeof(SampleMBean).FullName, remoteServer.IsInstanceOf(name,typeof(SampleMBean).AssemblyQualifiedName));
                    //Console.WriteLine("Is {0} registered: {1}", name, remoteServer.IsRegistered(name));
                    //string beans = string.Join(", ", remoteServer.QueryNames(null, null).Select(x => x.ToString()).ToArray());
                    //Console.WriteLine("Registered MBeans: {0}", beans);
                    //Console.ReadKey();
                }
            }
        }
コード例 #20
0
 public void Initialize()
 {
     _firstBean = new Sample()
                     {
                         IntAttribute = 1,
                         LongAttribute = 2,
                         DoubleAttribute = 3,
                         DecimalAttribute = 4,
                         StringAttribute = "5"
                     };
     _secondBean = new Sample()
     {
         IntAttribute = 10,
         LongAttribute = 20,
         DoubleAttribute = 30,
         DecimalAttribute = 40,
         StringAttribute = "50"
     };
     _server = new MBeanServer();
     _server.RegisterMBean(_firstBean, "sample:id=1");
     _server.RegisterMBean(_secondBean, "sample:id=2");
 }
コード例 #21
0
ファイル: Program.cs プロジェクト: yuzukwok/NetMX
        static void Main(string[] args)
        {
            var connectorServerFactory = new Jsr262ConnectorServerFactory();
            var connectorFactory       = new Jsr262ConnectorFactory();

            IMBeanServer server = MBeanServerFactory.CreateMBeanServer();
            Sample       o      = new Sample();
            ObjectName   name   = new ObjectName("Sample:a=b");

            server.RegisterMBean(o, name);
            Uri serviceUrl = new Uri("http://localhost:12345/MBeanServer");

            using (INetMXConnectorServer connectorServer = connectorServerFactory.NewNetMXConnectorServer(serviceUrl, server))
            {
                connectorServer.Start();

                using (INetMXConnector connector = connectorFactory.Connect(new Uri("http://localhost:12345/MBeanServer"), null))
                {
                    IMBeanServerConnection remoteServer = connector.MBeanServerConnection;

                    string defaultDomain = remoteServer.GetDefaultDomain();
                    Console.WriteLine("Default domain is {0}", defaultDomain);

                    IEnumerable <string> domains = remoteServer.GetDomains();
                    Console.WriteLine("Following domains are registereds:");
                    foreach (string domain in domains)
                    {
                        Console.WriteLine(" * {0}", domain);
                    }

                    IEnumerable <ObjectName> names = remoteServer.QueryNames(null, new EqualExp(new AttributeExp("Counter"), new ConstantExp <Number>(0)));
                    Console.WriteLine("Following MBeans have attribute counter with value 0:");
                    foreach (ObjectName objectName in names)
                    {
                        Console.WriteLine(" * {0}", objectName);
                    }

                    //remoteServer.AddNotificationListener(name, CounterChanged, null, null);

                    Console.WriteLine("******");
                    MBeanInfo info = remoteServer.GetMBeanInfo(name);
                    Console.WriteLine("MBean description: {0}", info.Description);
                    Console.WriteLine("MBean class name: {0}", info.ClassName);
                    foreach (MBeanAttributeInfo attributeInfo in info.Attributes)
                    {
                        Console.WriteLine("Attribute {0} ({1}) [{2}{3}]: {4}", attributeInfo.Name, attributeInfo.Description,
                                          attributeInfo.Readable ? "r" : "", attributeInfo.Writable ? "w" : "", attributeInfo.Type);
                    }
                    foreach (MBeanOperationInfo operationInfo in info.Operations)
                    {
                        Console.WriteLine("Operation {0} ({1}) [{2}]", operationInfo.Name, operationInfo.Description,
                                          operationInfo.Impact);
                    }
                    Console.WriteLine("******");

                    object counter = remoteServer.GetAttribute(name, "Counter");

                    Console.WriteLine("Counter value is {0}", counter);

                    remoteServer.SetAttribute(name, "Counter", 5);
                    counter = remoteServer.GetAttribute(name, "Counter");

                    Console.WriteLine("Now, counter value is {0}", counter);

                    counter = remoteServer.Invoke(name, "AddAmount", new object[] { 5 });
                    counter = remoteServer.GetAttribute(name, "Counter");

                    Console.WriteLine("Now, counter value is {0}. Press <enter>", counter);
                    Console.ReadLine();

                    counter = remoteServer.Invoke(name, "ResetCounter", new object[] { });
                    counter = remoteServer.GetAttribute(name, "Counter");

                    Console.WriteLine("Now, counter value is {0}", counter);

                    Console.WriteLine("Press <enter> to exit.");
                    Console.ReadLine();
                }
            }
        }
コード例 #22
0
        static void Main(string[] args)
        {
            IMBeanServer server = MBeanServerFactory.CreateMBeanServer();

            server.RegisterMBean(new RelationService(), RelationService.ObjectName);

            Sample sample1 = new Sample();
            Sample sample2 = new Sample();
            Sample sample3 = new Sample();

            server.RegisterMBean(sample1, "Sample:type=Sample,id=1");
            server.RegisterMBean(sample2, "Sample:type=Sample,id=2");
            server.RegisterMBean(sample3, "Sample:type=Sample,id=3");
            SampleDynamicMBean dynSample = new SampleDynamicMBean();

            dynSample.AddRow(1, "First row");
            dynSample.AddRow(2, "Second row");

            dynSample.AddNestedRow(1, 3, "First nested row");
            dynSample.AddNestedRow(2, 4, "Second nested row");
            server.RegisterMBean(dynSample, "Sample:type=SampleDynamicMBean");

            var relationSerice = server.CreateDynamicProxy(RelationService.ObjectName);

            relationSerice.CreateRelationType("Binding", new[] {
                new RoleInfo("Source", typeof(SampleMBean), true, false, 1, 1, "Source"),
                new RoleInfo("Destination", typeof(SampleMBean), true, false, 1, 1, "Destination")
            });

            relationSerice.CreateRelation("Rel1", "Binding", new Role[] {
                new Role("Source", new ObjectName("Sample:type=Sample,id=1")),
                new Role("Destination", new ObjectName("Sample:type=Sample,id=2"))
            });

            relationSerice.CreateRelation("Rel2", "Binding", new Role[] {
                new Role("Source", new ObjectName("Sample:type=Sample,id=1")),
                new Role("Destination", new ObjectName("Sample:type=Sample,id=3"))
            });

            OpenMBeanMapperService mapperService = new OpenMBeanMapperService(new ObjectName[] { "Sample:type=SampleMappedMBean" });

            server.RegisterMBean(mapperService, ":type=OpenMBeanMapperService");

            SampleMapped      mappedMBean = new SampleMapped();
            CollectionElement firstColEl  = new CollectionElement();

            firstColEl.Elements.Add(new NestedCollectionElement(1, "Name1"));
            firstColEl.Elements.Add(new NestedCollectionElement(2, "Name2"));
            CollectionElement secondColEl = new CollectionElement();

            secondColEl.Elements.Add(new NestedCollectionElement(3, "Name3"));
            secondColEl.Elements.Add(new NestedCollectionElement(4, "Name4"));
            mappedMBean.Add(firstColEl);
            mappedMBean.Add(secondColEl);
            server.RegisterMBean(mappedMBean, "Sample:type=SampleMappedMBean");


            Uri serviceUrl             = new Uri("tcp://localhost:1234/MBeanServer.tcp");
            var connectorServerFactory = new RemotingConnectorServerFactory(100, new NullSecurityProvider());

            using (INetMXConnectorServer connectorServer = connectorServerFactory.NewNetMXConnectorServer(serviceUrl, server))
            {
                connectorServer.Start();
                Console.WriteLine("Press any key to quit");
                Console.ReadKey();
            }
        }
コード例 #23
0
ファイル: CASPermissionsTests.cs プロジェクト: yuzukwok/NetMX
 public void PostRegister(bool registrationDone)
 {
     _server.RegisterMBean(new Dummy(), new ObjectName("dummy:"));
 }
コード例 #24
0
        static void Main(string[] args)
        {
            var connectorServerFactory = new RemotingConnectorServerFactory(100, new NullSecurityProvider());
            var connectorFactory       = new RemotingConnectorFactory(new NotificationFetcherConfig(true, TimeSpan.FromSeconds(1)));

            IMBeanServer server = MBeanServerFactory.CreateMBeanServer();
            Sample       o      = new Sample();
            ObjectName   name   = new ObjectName("Sample:a=b");

            server.RegisterMBean(o, name);
            Uri serviceUrl = new Uri("tcp://localhost:1234/MBeanServer.tcp");

            using (INetMXConnectorServer connectorServer = connectorServerFactory.NewNetMXConnectorServer(serviceUrl, server))
            {
                connectorServer.Start();

                using (INetMXConnector connector = connectorFactory.Connect(serviceUrl, null))
                {
                    IMBeanServerConnection remoteServer = connector.MBeanServerConnection;

                    remoteServer.AddNotificationListener(name, CounterChanged, null, null);

                    Console.WriteLine("******");
                    MBeanInfo info = remoteServer.GetMBeanInfo(name);
                    Console.WriteLine("MBean description: {0}", info.Description);
                    Console.WriteLine("MBean class name: {0}", info.ClassName);
                    foreach (MBeanAttributeInfo attributeInfo in info.Attributes)
                    {
                        Console.WriteLine("Attribute {0} ({1}) [{2}{3}]: {4}", attributeInfo.Name, attributeInfo.Description,
                                          attributeInfo.Readable ? "r" : "", attributeInfo.Writable ? "w" : "", attributeInfo.Type);
                    }
                    foreach (MBeanOperationInfo operationInfo in info.Operations)
                    {
                        Console.WriteLine("Operation {0} ({1}) [{2}]", operationInfo.Name, operationInfo.Description,
                                          operationInfo.Impact);
                    }
                    Console.WriteLine("******");

                    object counter = remoteServer.GetAttribute(name, "Counter");

                    Console.WriteLine("Counter value is {0}", counter);

                    remoteServer.SetAttribute(name, "Counter", 5);
                    counter = remoteServer.GetAttribute(name, "Counter");

                    Console.WriteLine("Now, counter value is {0}", counter);

                    counter = remoteServer.Invoke(name, "AddAmount", new object[] { 5 });
                    counter = remoteServer.GetAttribute(name, "Counter");

                    Console.WriteLine("Now, counter value is {0}", counter);

                    counter = remoteServer.Invoke(name, "ResetCounter", new object[] { });
                    counter = remoteServer.GetAttribute(name, "Counter");

                    Console.WriteLine("Now, counter value is {0}", counter);

                    Console.ReadKey();
                }
            }
        }
コード例 #25
0
        public void SetUp()
        {
            _bean1 = new Test();
            _server1 = MBeanServerFactory.CreateMBeanServer("1");
            _server1.RegisterMBean(_bean1, "someDomain:t=test");

            _bean2 = new Test();
            _server2 = MBeanServerFactory.CreateMBeanServer("2");
            _server2.RegisterMBean(_bean2, "someDomain:t=test");

            _bean3 = new Test();
            _server3 = MBeanServerFactory.CreateMBeanServer("3");
            _server3.RegisterMBean(_bean3, "someDomain:t=test");
            _server3.RegisterMBean(_bean3, "invalidPrefix.someDomain:t=test");

            _aggregateConnection = new AggregateMBeanServerConnection(_server3);
            _aggregateConnection.AddChildServer("one", _server1);
            _aggregateConnection.AddChildServer("two", _server2);
        }