Beispiel #1
0
        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));
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        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));
        }
Beispiel #6
0
        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);
            }
        }
Beispiel #7
0
        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);
        }
Beispiel #8
0
        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);
        }
Beispiel #9
0
        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);
        }
Beispiel #10
0
 public bool HasAttribute(string attributeName)
 {
     return(_bean.GetMBeanInfo().Attributes.Any(x => x.Name == attributeName));
 }
Beispiel #11
0
        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);
        }