/// <summary> /// Creates new RelationSupport object. /// /// This constructor has to be used when the user relation MBean implements the interfaces expected /// to be supported by a relation by delegating to a RelationSupport object. /// /// This object needs to know the Relation Service expected to handle the relation. So it has to know /// the MBean Server where the Relation Service is registered. /// /// According to a limitation, a relation MBean must be registered in the same MBean Server as the /// Relation Service expected to handle it. So the user relation MBean has to be created and /// registered, and then the wrapped RelationSupport object can be created with identified MBean Server. /// /// Nothing is done at the Relation Service level, i.e. the RelationSupport object is not added, /// and no check if the provided values are correct. The object is always created, EXCEPT if: /// <list type="bullet"> /// <item>one required parameter is not provided</item> /// <item>the same name is used for two roles.</item> /// </list> /// To be handled as a relation, the object has then to be added in the Relation Service using the Relation /// Service method <see cref="RelationServiceMBean.AddRelation"/>(). /// </summary> /// <param name="relationId">Relation identifier, to identify the relation in the Relation Service. Expected to be unique in the given Relation Service.</param> /// <param name="relationServiceName">ObjectName of the Relation Service where the relation will be registered. /// It is required as this is the Relation Service that is aware of the definition of the relation type /// of given relation, so that will be able to check update operations (set). /// </param> /// <param name="relationServiceMBeanServer">MBean Server where the wrapping MBean is or will be registered. /// Expected to be the MBean Server where the Relation Service is or will be registered. /// </param> /// <param name="relationType">Name of relation type. Expected to have been created in given Relation Service.</param> /// <param name="roles">Roles (Role objects) to initialised the relation. Can be null. Expected to conform to relation info in associated relation type.</param> public RelationSupport(string relationId, ObjectName relationServiceName, IMBeanServer relationServiceMBeanServer, string relationType, IEnumerable<Role> roles) { _relationId = relationId; if (relationServiceMBeanServer == null || relationServiceName.Domain != "") { _relationServiceName = relationServiceName; } else { _relationServiceName = new ObjectName(relationServiceMBeanServer.GetDefaultDomain(), relationServiceName.KeyPropertyList); } _relationServiceMBeanServer = relationServiceMBeanServer; _relationService = _relationServiceMBeanServer.CreateDynamicProxy(_relationServiceName); _relationTypeName = relationType; _roles = new Dictionary<string, Role>(); if (roles != null) { foreach (Role role in roles) { if (!_roles.ContainsKey(role.Name)) { _roles[role.Name] = role; } else { throw new InvalidRoleValueException(); } } } }
/// <summary> /// Creates new RelationSupport object. /// /// This constructor has to be used when the user relation MBean implements the interfaces expected /// to be supported by a relation by delegating to a RelationSupport object. /// /// This object needs to know the Relation Service expected to handle the relation. So it has to know /// the MBean Server where the Relation Service is registered. /// /// According to a limitation, a relation MBean must be registered in the same MBean Server as the /// Relation Service expected to handle it. So the user relation MBean has to be created and /// registered, and then the wrapped RelationSupport object can be created with identified MBean Server. /// /// Nothing is done at the Relation Service level, i.e. the RelationSupport object is not added, /// and no check if the provided values are correct. The object is always created, EXCEPT if: /// <list type="bullet"> /// <item>one required parameter is not provided</item> /// <item>the same name is used for two roles.</item> /// </list> /// To be handled as a relation, the object has then to be added in the Relation Service using the Relation /// Service method <see cref="RelationServiceMBean.AddRelation"/>(). /// </summary> /// <param name="relationId">Relation identifier, to identify the relation in the Relation Service. Expected to be unique in the given Relation Service.</param> /// <param name="relationServiceName">ObjectName of the Relation Service where the relation will be registered. /// It is required as this is the Relation Service that is aware of the definition of the relation type /// of given relation, so that will be able to check update operations (set). /// </param> /// <param name="relationServiceMBeanServer">MBean Server where the wrapping MBean is or will be registered. /// Expected to be the MBean Server where the Relation Service is or will be registered. /// </param> /// <param name="relationType">Name of relation type. Expected to have been created in given Relation Service.</param> /// <param name="roles">Roles (Role objects) to initialised the relation. Can be null. Expected to conform to relation info in associated relation type.</param> public RelationSupport(string relationId, ObjectName relationServiceName, IMBeanServer relationServiceMBeanServer, string relationType, IEnumerable <Role> roles) { _relationId = relationId; if (relationServiceMBeanServer == null || relationServiceName.Domain != "") { _relationServiceName = relationServiceName; } else { _relationServiceName = new ObjectName(relationServiceMBeanServer.GetDefaultDomain(), relationServiceName.KeyPropertyList); } _relationServiceMBeanServer = relationServiceMBeanServer; _relationService = _relationServiceMBeanServer.CreateDynamicProxy(_relationServiceName); _relationTypeName = relationType; _roles = new Dictionary <string, Role>(); if (roles != null) { foreach (Role role in roles) { if (!_roles.ContainsKey(role.Name)) { _roles[role.Name] = role; } else { throw new InvalidRoleValueException(); } } } }
public void SetUp() { _server = MBeanServerFactory.CreateMBeanServer(); _connectorServer = new Jsr262ConnectorServerFactory().NewNetMXConnectorServer(new Uri(_serviceUrl), _server); _connectorServer.Start(); }
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(); }
public ObjectName PreRegister(IMBeanServer server, ObjectName name) { base.Initialize(name, new MBeanNotificationInfo[] { new MBeanNotificationInfo(new string[] { MBeanServerNotification.RegistrationNotification, MBeanServerNotification.UnregistrationNotification }, typeof(MBeanServerNotification).AssemblyQualifiedName, null) }); return(name); }
public void Initialize() { _bean = new Sample { Attribute = "Text" }; _server = new MBeanServer(); _server.RegisterMBean(_bean, "sample:id=1"); }
public RemotingConnectionImpl(IMBeanServer server, INetMXSecurityProvider securityProvider, RemotingServerImpl remotingServer, string connectionId, object subject, int bufferSize) { _server = server; _securityProvider = securityProvider; _remotingServer = remotingServer; _connectionId = connectionId; _subject = subject; _buffer = new NotificationBuffer(bufferSize); _listenerProxys = new Dictionary<int, ListenerProxy>(); }
public ObjectName PreRegister(IMBeanServer server, ObjectName name) { _relationServiceMBeanServer = server; if (_relationServiceName.Domain == "") { _relationServiceName = new ObjectName(server.GetDefaultDomain(), _relationServiceName.KeyPropertyList); } _relationService = _relationServiceMBeanServer.CreateDynamicProxy(_relationServiceName); return(name); }
private static INetMXConnectorServer DoCreateJsr262Server(IMBeanServer server) { const string uri = "http://localhost:8888/MBeanServer"; Logger.InfoFormat("URI used to establish the JSR262 MBeanServer: {0}", uri); var serviceUrl = new Uri(uri); return(new Jsr262ConnectorServerProvider().NewNetMXConnectorServer(serviceUrl, server)); }
public RemotingConnectionImpl(IMBeanServer server, INetMXSecurityProvider securityProvider, RemotingServerImpl remotingServer, string connectionId, object subject, int bufferSize) { _server = server; _securityProvider = securityProvider; _remotingServer = remotingServer; _connectionId = connectionId; _subject = subject; _buffer = new NotificationBuffer(bufferSize); _listenerProxys = new Dictionary <int, ListenerProxy>(); }
public void SetUp() { _notificationFlag = new ManualResetEvent(false); _server = MockRepository.GenerateMock <IMBeanServer>(); Uri serviceUrl = GetUri(); _connectorServer = GetConnectorServerFactory().NewNetMXConnectorServer(serviceUrl, _server); _connectorServer.Start(); _connector = GetConnectorFactory().Connect(serviceUrl, null); _remoteServer = _connector.MBeanServerConnection; }
public RemotingConnectorServer(Uri serviceUrl, IMBeanServer server, INetMXSecurityProvider securityProvider, int bufferSize) { if (!serviceUrl.IsLoopback) { throw new ArgumentException("Cannot start server on remote host", "serviceUrl"); } _serviceUrl = serviceUrl; _server = server; _securityProvider = securityProvider; _bufferSize = bufferSize; }
public void SetUp() { _notificationFlag = new ManualResetEvent(false); _server = MockRepository.GenerateMock<IMBeanServer>(); Uri serviceUrl = GetUri(); _connectorServer = GetConnectorServerFactory().NewNetMXConnectorServer(serviceUrl, _server); _connectorServer.Start(); _connector = GetConnectorFactory().Connect(serviceUrl, null); _remoteServer = _connector.MBeanServerConnection; }
public void TestMBeanServer() { IMBeanServer mbeanServer = mbeanServerExtension.MBeanServer; var name = new ObjectName("MBeanServer:component=ValidMBean"); MBeanInfo info = mbeanServer.GetMBeanInfo(name); Assert.AreEqual("MBean", info.Description); Assert.AreEqual("CrimsonLogic.Common.Library.Tests.ValidInstanceMBean, CrimsonLogic.Common.Library.Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5fb9aab394206ec1", info.ClassName); foreach (MBeanAttributeInfo attributeInfo in info.Attributes) { string attribute = string.Format("Attribute {0} ({1}) [{2}{3}]: {4}", attributeInfo.Name, attributeInfo.Description, attributeInfo.Readable ? "r" : "", attributeInfo.Writable ? "w" : "", attributeInfo.Type); Assert.AreEqual("Attribute Counter (Counter value) [rw]: System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", attribute); } int index = 0; foreach (MBeanOperationInfo operationInfo in info.Operations) { string operation = string.Format("Operation {0} ({1}) [{2}]", operationInfo.Name, operationInfo.Description, operationInfo.Impact); Assert.AreEqual( index == 0 ? "Operation AddAmount (Adds specified value to value of the counter) [Unknown]" : "Operation ResetCounter (Sets counter value to 0) [Unknown]", operation); index++; } object counter = mbeanServer.GetAttribute(name, "Counter"); Assert.AreEqual(0, counter); mbeanServer.SetAttribute(name, "Counter", 5); counter = mbeanServer.GetAttribute(name, "Counter"); Assert.AreEqual(5, counter); mbeanServer.Invoke(name, "AddAmount", new object[] { 5 }); counter = mbeanServer.GetAttribute(name, "Counter"); Assert.AreEqual(10, counter); mbeanServer.Invoke(name, "ResetCounter", new object[] { }); counter = mbeanServer.GetAttribute(name, "Counter"); Assert.AreEqual(0, counter); Logger.Debug("Completed testing the MBeanServer!"); }
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; }
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(); }
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); }
public void SetAttributePermissionTest() { IMBeanServer server = null; DoPermissionTest( delegate() { server = new MBeanServer(); server.RegisterMBean(new Dummy(), new ObjectName("dummy:")); }, delegate() { server.SetAttribute(new ObjectName("dummy:"), "IntValue", 5); }, "IntValue", "DoSomething", MBeanPermissionAction.SetAttribute, MBeanPermissionAction.GetAttribute); }
public void UnregisterMBeanPermissionTest() { IMBeanServer server = null; DoPermissionTest( delegate() { server = new MBeanServer(); server.RegisterMBean(new Dummy(), new ObjectName("dummy:")); }, delegate() { server.UnregisterMBean(new ObjectName("dummy:")); }, null, null, MBeanPermissionAction.UnregisterMBean, MBeanPermissionAction.RegisterMBean); }
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(); }
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(); }
public ObjectName PreRegister(IMBeanServer server, ObjectName name) { _server = server; _ownName = name; MBeanNotificationInfo info = new MBeanNotificationInfo(new string[] { RelationNotification.RelationBasicCreation, RelationNotification.RelationBasicRemoval, RelationNotification.RelationBasicUpdate, RelationNotification.RelationMBeanCreation, RelationNotification.RelationMBeanRemoval, RelationNotification.RelationMBeanUpdate }, typeof(RelationNotification).AssemblyQualifiedName, "Relation notification"); this.Initialize(name, new MBeanNotificationInfo[] { info }); return(name); }
public ObjectName PreRegister(IMBeanServer server, ObjectName name) { ObjectName newName = name; if (_registration != null) { newName = _registration.PreRegister(server, name); } _objectName = newName; if (_notifEmitter == null) { _notificationSupport = new NotificationEmitterSupport(); _notificationSupport.Initialize(newName.ToString(), _info.Notifications); _notifEmitter = _notificationSupport; AttachNotifications(); } return(newName); }
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") }); }
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); }
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") }); }
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; } } }
public ObjectName PreRegister(IMBeanServer server, ObjectName name) { if (_inner != null) { try { return(_inner.PreRegister(server, name)); } catch (Exception ex) { if (ex is SecurityException) { throw; } throw new MBeanRegistrationException("PreRegister.", ex); } } else { return(name); } }
public ObjectName PreRegister(IMBeanServer server, ObjectName name) { if (_inner != null) { try { return _inner.PreRegister(server, name); } catch (Exception ex) { if (ex is SecurityException) { throw; } throw new MBeanRegistrationException("PreRegister.", ex); } } else { return name; } }
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"); }
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; }
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(); }
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(); } } }
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(); }
public Jsr262ExtensionMethodHandler(IMBeanServer server) { _server = server; }
public Jsr262ConnectorServer(string serviceUrl, IMBeanServer server) { _serviceUrl = serviceUrl; _server = server; }
///<summary> ///</summary> ///<param name="mbeanServer"></param> public MBeanServerJsr262Exporter(IMBeanServer mbeanServer) { this.mbeanServer = mbeanServer; }
public INetMXConnectorServer NewNetMXConnectorServer(Uri serviceUrl, IMBeanServer server) { return(new ServiceModelConnectorServer(serviceUrl, server)); }
public ObjectName PreRegister(IMBeanServer server, ObjectName name) { _server = server; return(name); }
public QueryNamesEnumerationRequestHandler(IMBeanServer server) { _server = server; }
public ObjectName PreRegister(IMBeanServer server, ObjectName name) { _server = server; _ownName = name; return name; }
public RemotingServerImpl(IMBeanServer server, INetMXSecurityProvider securityProvider, int bufferSize) { _server = server; _securityProvider = securityProvider; _bufferSize = bufferSize; }
public INetMXConnectorServer NewNetMXConnectorServer(Uri serviceUrl, IMBeanServer server) { return new ServiceModelConnectorServer(serviceUrl, server); }
private static INetMXConnectorServer DoCreateJsr262Server(IMBeanServer server) { const string uri = "http://localhost:8888/MBeanServer"; Logger.InfoFormat("URI used to establish the JSR262 MBeanServer: {0}", uri); var serviceUrl = new Uri(uri); return new Jsr262ConnectorServerProvider().NewNetMXConnectorServer(serviceUrl, server); }
public ServiceModelConnectorServer(Uri serviceUrl, IMBeanServer beanServer) { _beanServer = beanServer; _serviceUrl = serviceUrl; _serviceHost = new ServiceHost(new MBeanServerService(beanServer), _serviceUrl); }
public MBeanServerManagementRequestHandler(IMBeanServer beanServer) { _server = beanServer; }
public ObjectName PreRegister(IMBeanServer server, ObjectName name) { _thisName = name; return name; }
public INetMXConnectorServer NewNetMXConnectorServer(Uri serviceUrl, IMBeanServer server) { return new RemotingConnectorServer(serviceUrl, server, _securityProvider, _bufferSize); }
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(); } }
public ObjectName PreRegister(IMBeanServer server, ObjectName name) { ObjectName newName = name; if (_registration != null) { newName = _registration.PreRegister(server, name); } _objectName = newName; if (_notifEmitter == null) { _notificationSupport = new NotificationEmitterSupport(); _notificationSupport.Initialize(newName.ToString(), _info.Notifications); _notifEmitter = _notificationSupport; AttachNotifications(); } return newName; }
public ObjectName PreRegister(IMBeanServer server, ObjectName name) { base.Initialize(name, new MBeanNotificationInfo[] { new MBeanNotificationInfo(new string[] { MBeanServerNotification.RegistrationNotification, MBeanServerNotification.UnregistrationNotification }, typeof(MBeanServerNotification).AssemblyQualifiedName, null)}); return name; }
public IsRegisteredEnumerationRequestHandler(IMBeanServer server) { _server = server; }
public ObjectName PreRegister(IMBeanServer server, ObjectName name) { _server = server; _ownName = name; MBeanNotificationInfo info = new MBeanNotificationInfo(new string[] { RelationNotification.RelationBasicCreation, RelationNotification.RelationBasicRemoval, RelationNotification.RelationBasicUpdate, RelationNotification.RelationMBeanCreation, RelationNotification.RelationMBeanRemoval, RelationNotification.RelationMBeanUpdate }, typeof(RelationNotification).AssemblyQualifiedName, "Relation notification"); this.Initialize(name, new MBeanNotificationInfo[] { info }); return name; }
public INetMXConnectorServer NewNetMXConnectorServer(Uri serviceUrl, IMBeanServer server) { return new Jsr262ConnectorServer(serviceUrl+"/", server); }