Exemple #1
0
        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));
            }
        }
Exemple #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);
        }
Exemple #3
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));
        }
Exemple #4
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);
        }
Exemple #5
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);
        }
Exemple #6
0
        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));
        }
Exemple #7
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);
            }
        }
Exemple #8
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);
        }
Exemple #9
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);
        }
Exemple #10
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));
        }
Exemple #11
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);
        }
Exemple #12
0
 public EvaluationContext(ObjectName name, IDynamicMBean bean)
 {
     _name = name;
     _bean = bean;
 }
Exemple #13
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);
        }
Exemple #14
0
 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 EvaluationContext(ObjectName name, IDynamicMBean bean)
 {
     _name = name;
      _bean = bean;
 }