示例#1
0
文件: Program.cs 项目: yuzukwok/NetMX
        static void Main(string[] args)
        {
            const string address = "http://localhost:12345/adaptor/sample";

            var server = MBeanServerFactory.CreateMBeanServer("HttpAdaptorDemo");

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

            server.RegisterMBean(new Sample(), "sample:t=static");
            server.RegisterMBean(new Sample(), "d1.sample:t=static");
            server.RegisterMBean(new Sample(), "d1.sample2:t=static");
            server.RegisterMBean(new Sample(), "d1.d2.sample1:t=static");
            server.RegisterMBean(new Sample(), "d1.d2.sample2:t=static");
            server.RegisterMBean(new Sample(), "d1.d2.d3.sample1:t=static");

            var dynamicMBean = new SampleDynamicMBean();

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

            server.RegisterMBean(dynamicMBean, "sample:t=dynamic");

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

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

            relationSerice.CreateRelation("Rel1", "Binding",
                                          new[]
            {
                new Role("Source", new ObjectName("sample:t=static")),
                new Role("Destination", new ObjectName("sample:t=dynamic"))
            });

            var adaptor = new SelfHostingHttpAdaptor(server, address);

            adaptor.Start();

            Console.WriteLine("Http adaptor started at {0}. Press <enter> to exit.", address);
            Console.ReadLine();

            adaptor.Stop();
        }
示例#2
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();
        }
示例#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();
        }