private ObjectInstance RegisterMBeanExternal(object bean, ObjectName name) { IDynamicMBean dynBean = bean as IDynamicMBean; if (dynBean != null) { return(RegisterMBeanInternal(name, dynBean)); } else { Type beanType = bean.GetType(); Type intfType = null; while (beanType != null) { intfType = beanType.GetInterface(beanType.Name + "MBean", false); if (intfType != null) { break; } beanType = beanType.BaseType; } if (intfType == null) { throw new NotCompliantMBeanException(beanType.AssemblyQualifiedName); } StandardMBean stdBean = new StandardMBean(bean, intfType); return(RegisterMBeanInternal(name, stdBean)); } }
public void SetAttribute(ObjectName name, string attributeName, object value) { name = GetNameWithDomain(name); IDynamicMBean bean = GetMBean(name); TestPermissions(bean.GetMBeanInfo().ClassName, attributeName, name, MBeanPermissionAction.SetAttribute); bean.SetAttribute(attributeName, value); }
public object GetAttribute(ObjectName name, string attributeName) { name = GetNameWithDomain(name); IDynamicMBean bean = GetMBean(name); TestPermissions(bean.GetMBeanInfo().ClassName, attributeName, name, MBeanPermissionAction.GetAttribute); return(bean.GetAttribute(attributeName)); }
public bool IsInstanceOf(ObjectName name, string className) { name = GetNameWithDomain(name); IDynamicMBean bean = GetMBean(name); MBeanInfo info = bean.GetMBeanInfo(); TestPermissions(info.ClassName, null, name, MBeanPermissionAction.IsInstanceOf); return(info.ClassName == className); }
public MBeanInfo GetMBeanInfo(ObjectName name) { name = GetNameWithDomain(name); IDynamicMBean bean = GetMBean(name); MBeanInfo info = bean.GetMBeanInfo(); TestPermissions(info.ClassName, null, name, MBeanPermissionAction.GetMBeanInfo); return(info); }
private INotificationListener GetListenerMBean(ObjectName name, out IDynamicMBean bean) { bean = GetMBean(name); INotificationListener listner = bean as INotificationListener; if (listner != null) { return(listner); } throw new OperationsException(string.Format("Bean \"{0}\" is not a notification listener.", name)); }
public object Invoke(ObjectName name, string operationName, object[] arguments) { name = GetNameWithDomain(name); IDynamicMBean bean = GetMBean(name); TestPermissions(bean.GetMBeanInfo().ClassName, operationName, name, MBeanPermissionAction.Invoke); try { return(bean.Invoke(operationName, arguments)); } catch (Exception e) { throw new MBeanException("Exception during 'invoke' operation.", e); } }
public void UnregisterMBean(ObjectName name) { name = GetNameWithDomain(name); IDynamicMBean bean = GetMBean(name); MBeanInfo info = bean.GetMBeanInfo(); TestPermissions(info.ClassName, null, name, MBeanPermissionAction.UnregisterMBean); IMBeanRegistration registration = new MBeanRegistrationHelper(bean as IMBeanRegistration); registration.PreDeregister(); _beans.Remove(name); registration.PostDeregister(); _delegate.SendNotification(new MBeanServerNotification(MBeanServerNotification.UnregistrationNotification, null, -1, name)); _domainSet.Remove(name.Domain); }
public IList <AttributeValue> GetAttributes(ObjectName name, string[] attributeNames) { name = GetNameWithDomain(name); IDynamicMBean bean = GetMBean(name); string className = bean.GetMBeanInfo().ClassName; List <AttributeValue> results = new List <AttributeValue>(); foreach (string attributeName in attributeNames) { TestPermissions(className, attributeName, name, MBeanPermissionAction.GetAttribute); try { results.Add(new AttributeValue(attributeName, bean.GetAttribute(attributeName))); } catch (AttributeNotFoundException) { } } return(results); }
private ObjectInstance RegisterMBeanInternal(ObjectName name, IDynamicMBean bean) { IMBeanRegistration registration = new MBeanRegistrationHelper(bean as IMBeanRegistration); name = registration.PreRegister(this, name); string className = bean.GetMBeanInfo().ClassName; TestPermissions(className, null, name, MBeanPermissionAction.RegisterMBean); if (_beans.ContainsKey(name)) { registration.PostRegister(false); throw new InstanceAlreadyExistsException(name.ToString()); } _beans[name] = bean; registration.PostRegister(true); _delegate.SendNotification(new MBeanServerNotification(MBeanServerNotification.RegistrationNotification, null, -1, name)); _domainSet[name.Domain] = true; return(new ObjectInstance(name, bean.GetMBeanInfo().ClassName)); }
public IList <AttributeValue> SetAttributes(ObjectName name, IEnumerable <AttributeValue> namesAndValues) { name = GetNameWithDomain(name); IDynamicMBean bean = GetMBean(name); string className = bean.GetMBeanInfo().ClassName; List <AttributeValue> results = new List <AttributeValue>(); foreach (AttributeValue nameAndValue in namesAndValues) { TestPermissions(className, nameAndValue.Name, name, MBeanPermissionAction.SetAttribute); try { bean.SetAttribute(nameAndValue.Name, nameAndValue.Value); results.Add(new AttributeValue(nameAndValue.Name, nameAndValue.Value)); } catch (AttributeNotFoundException) { //Best-effort } } return(results); }
public EvaluationContext(ObjectName name, IDynamicMBean bean) { _name = name; _bean = bean; }
private ObjectInstance RegisterMBeanInternal(ObjectName name, IDynamicMBean bean) { IMBeanRegistration registration = new MBeanRegistrationHelper(bean as IMBeanRegistration); name = registration.PreRegister(this, name); string className = bean.GetMBeanInfo().ClassName; TestPermissions(className, null, name, MBeanPermissionAction.RegisterMBean); if (_beans.ContainsKey(name)) { registration.PostRegister(false); throw new InstanceAlreadyExistsException(name.ToString()); } _beans[name] = bean; registration.PostRegister(true); _delegate.SendNotification(new MBeanServerNotification(MBeanServerNotification.RegistrationNotification, null, -1, name)); _domainSet[name.Domain] = true; return new ObjectInstance(name, bean.GetMBeanInfo().ClassName); }
private INotificationListener GetListenerMBean(ObjectName name, out IDynamicMBean bean) { bean = GetMBean(name); INotificationListener listner = bean as INotificationListener; if (listner != null) { return listner; } throw new OperationsException(string.Format("Bean \"{0}\" is not a notification listener.", name)); }