Example #1
0
        public MBeanServer(string instanceName)
        {
            if (instanceName == null)
            {
                instanceName = Guid.NewGuid().ToString();
            }
            _delegate = new MBeanServerDelegate(instanceName, "", "http://netmx.eu",
                                                typeof(MBeanServer).Assembly.GetName().Version.ToString());
            RegisterMBean(_delegate, MBeanServerDelegate.ObjectName);
            object section1 = System.Configuration.ConfigurationManager.GetSection(instanceName);

            if (section1 == null && false)
            {
                throw new ArgumentException("Section not found");
            }
            MBeanServerConfigurationSection section = (MBeanServerConfigurationSection)section1;

            if (section != null)
            {
                foreach (MBeanElement beanConfig in section.Beans)
                {
                    List <object> args = new List <object>();
                    foreach (MBeanConstructorArgument arg in beanConfig.Arguments)
                    {
                        Type          valueType = Type.GetType(arg.Type);
                        TypeConverter tc        = TypeDescriptor.GetConverter(valueType);
                        args.Add(tc.ConvertFromString(arg.Value));
                    }
                    CreateMBean(beanConfig.ClassName, beanConfig.ObjectName, args.ToArray());
                }
            }
        }
Example #2
0
 public MBeanServer(string instanceName)
 {
     if (instanceName == null)
     {
         instanceName = Guid.NewGuid().ToString();
     }
     _delegate = new MBeanServerDelegate(instanceName, "", "http://netmx.eu",
                                         typeof(MBeanServer).Assembly.GetName().Version.ToString());
     RegisterMBean(_delegate, MBeanServerDelegate.ObjectName);
     object section1 = System.Configuration.ConfigurationManager.GetSection(instanceName);
     if (section1 == null && false)
     {
         throw new ArgumentException("Section not found");
     }
     MBeanServerConfigurationSection section = (MBeanServerConfigurationSection)section1;
     if (section != null)
     {
         foreach (MBeanElement beanConfig in section.Beans)
         {
             List<object> args = new List<object>();
             foreach (MBeanConstructorArgument arg in beanConfig.Arguments)
             {
                 Type valueType = Type.GetType(arg.Type);
                 TypeConverter tc = TypeDescriptor.GetConverter(valueType);
                 args.Add(tc.ConvertFromString(arg.Value));
             }
             CreateMBean(beanConfig.ClassName, beanConfig.ObjectName, args.ToArray());
         }
     }
 }