Package javax.management

Examples of javax.management.Descriptor


      setMbeanInfoDb((MbeanInfoDb) mbean.getResource());
      if(!loadedFromFs())
      {

         // get mbi db root from descriptor
         Descriptor d = ((ModelMBeanInfo) info).getMBeanDescriptor();
         String dir = (String) d.getFieldValue(
                         ModelMBeanConstants.PERSIST_LOCATION);
         if((dir != null) && (!dir.equals("")))
         {

            setMbiDbRoot(new File(dir));
View Full Code Here


         {

            ObjectName curName = (ObjectName) names.nextElement();
            logger().debug("curName: " + curName);
            ModelMBeanInfo curInfo = (ModelMBeanInfo) infos.nextElement();
            Descriptor mbeanDescriptor = curInfo.getMBeanDescriptor();
            String fieldName = ModelMBeanConstants.RESOURCE_CLASS;
            String className = (String) mbeanDescriptor.getFieldValue(fieldName);
            logger().debug("className: " + className);
            Object resource = getMBeanServer().instantiate(className);
            ModelMBean modelmbean = new RequiredModelMBean();
            modelmbean.setModelMBeanInfo(curInfo);
            modelmbean.setManagedResource(resource, "ObjectReference");
View Full Code Here

      {
         HashMap properties = new HashMap();

         if (resourceType.equals(DESCRIPTOR))
         {
            Descriptor d = (Descriptor)resource;

            // get the actual resource type from the descriptor
            resourceType = (String)d.getFieldValue(RESOURCE_TYPE);
  
            // and the resource reference
            resource = d.getFieldValue(RESOURCE_REFERENCE);
           
            // extract builder configuration fields
            String[] fields = d.getFieldNames();
           
            for (int i = 0; i < fields.length; ++i)
            {
               // extract all the fields starting with the METADATA_DESCRIPTOR_PREFIX
               // prefix to a property map that is passed to the builder implementations
               if (fields[i].startsWith(METADATA_DESCRIPTOR_PREFIX))
                  properties.put(fields[i], d.getFieldValue(fields[i]));
            }
         }

         if (resourceType.equals(STANDARD_MBEAN) && resource instanceof StandardMBean)
            setManagedResource(((StandardMBean)resource).getImplementation(), resourceType);
View Full Code Here

      if (resourceType.equals(DESCRIPTOR))
      {
         if (!(resource instanceof Descriptor))
            return false;
           
         Descriptor d = (Descriptor)resource;
        
         if (d.getFieldValue(RESOURCE_REFERENCE) == null)
            return false;
        
         if (d.getFieldValue(RESOURCE_TYPE) == null)
            return false;
           
         return true;
      }
      if (resourceType.endsWith(".xml"))
View Full Code Here

         List constructors = root.getChildren("constructor");
         List operations = root.getChildren("operation");
         List attributes = root.getChildren("attribute");
         List notifications = root.getChildren("notifications");

         Descriptor descr = getDescriptor(root, resourceClassName, "mbean");

         ModelMBeanInfo info = buildMBeanMetaData(
            description, constructors, operations,
            attributes, notifications, descr
         );
View Full Code Here

  
   // Protected -----------------------------------------------------
  
   protected Descriptor getDescriptor(final Element parent, final String infoName, final String type) throws NotCompliantMBeanException
   {
      Descriptor descr = new DescriptorSupport();
      descr.setField(NAME, infoName);
      descr.setField(DESCRIPTOR_TYPE, type);

      Element descriptors = parent.getChild("descriptors");
      if (descriptors == null)
      {
         return descr;
      } // end of if ()
      for (Iterator i = descriptors.getChildren().iterator(); i.hasNext();)
      {
         Element descriptor = (Element)i.next();
         String name = descriptor.getName();
         if (name.equals("persistence"))
         {
            Attribute persistPolicy = descriptor.getAttribute(PERSIST_POLICY);
            Attribute persistPeriod = descriptor.getAttribute(PERSIST_PERIOD);
            Attribute persistLocation = descriptor.getAttribute(PERSIST_LOCATION);
            Attribute persistName = descriptor.getAttribute(PERSIST_NAME);
            if (persistPolicy != null)
            {
               String value = persistPolicy.getValue();
               validate(value, PERSIST_POLICY_LIST);
               descr.setField(PERSIST_POLICY, value);
            }
            if (persistPeriod != null)
            {
               descr.setField(PERSIST_PERIOD, persistPeriod.getValue());
            }
            if (persistLocation != null)
            {
               descr.setField(PERSIST_LOCATION, persistLocation.getValue());
            }
            if (persistName != null)
            {
               descr.setField(PERSIST_NAME, persistName.getValue());
            }
         }
         else if (name.equals(CURRENCY_TIME_LIMIT))
         {
            descr.setField(CURRENCY_TIME_LIMIT, descriptor.getAttributeValue("value"));
         } // end of else
         else if (name.equals(STATE_ACTION_ON_UPDATE))
         {
            String value = descriptor.getAttributeValue("value");
            validate(value, STATE_ACTION_ON_UPDATE_LIST);
            descr.setField(STATE_ACTION_ON_UPDATE, value);
         } // end of else
         else if (name.equals(DEFAULT))
         {
            String value = descriptor.getAttributeValue("value");
            descr.setField(DEFAULT, value);
         }
         else if (name.equals("display-name"))
         {
            String value = descriptor.getAttributeValue("value");
            descr.setField(DISPLAY_NAME, value);
         }
         else if (name.equals(VALUE))
         {
            String value = descriptor.getAttributeValue("value");
            descr.setField(VALUE, value);
         }
         else if (name.equals(PERSISTENCE_MANAGER))
         {
            descr.setField(PERSISTENCE_MANAGER, descriptor.getAttributeValue("value"));
         } // end of else
         else if (name.equals(DESCRIPTOR))
         {
            descr.setField(descriptor.getAttributeValue("name"), descriptor.getAttributeValue("value"));
         } // end of else
      } // end of for ()
      return descr;
   }
View Full Code Here

         List params = constr.getChildren("parameter");

         MBeanParameterInfo[] paramInfo =
            buildParameterInfo(params);

         Descriptor descr = getDescriptor(constr, name, CONSTRUCTOR_DESCRIPTOR);

         ModelMBeanConstructorInfo info =
            new ModelMBeanConstructorInfo(name, description, paramInfo, descr);

         infos.add(info);
View Full Code Here

         List params = oper.getChildren("parameter");

         MBeanParameterInfo[] paramInfo =
            buildParameterInfo(params);

         Descriptor descr = getDescriptor(oper, name, OPERATION_DESCRIPTOR);

         // defaults to ACTION_INFO
         int operImpact = MBeanOperationInfo.ACTION_INFO;

         if (impact != null)
         {
            if (impact.equals(INFO))
               operImpact = MBeanOperationInfo.INFO;
            else if (impact.equals(ACTION))
               operImpact = MBeanOperationInfo.ACTION;
            else if (impact.equals(ACTION_INFO))
               operImpact = MBeanOperationInfo.ACTION_INFO;
         }

         // default return-type is void
         if (type == null)
            type = "void";

         // Possible getter?
         if (paramInfo.length == 0 && type.equals("void") == false)
            getters.put(name, type);

         // Possible setter?
         if (paramInfo.length == 1)
         {
            HashSet types = (HashSet) setters.get(name);
            if (types == null)
            {
                types = new HashSet();
                setters.put(name, types);
            }
            types.add(paramInfo[0].getType());
         }

         ModelMBeanOperationInfo info = new ModelMBeanOperationInfo(
            name, description, paramInfo, type, operImpact, descr);

         infos.add(info);
      }

      // Add operations for get/setMethod that aren't already present

      for (Iterator it = attributes.iterator(); it.hasNext();)
      {
         Element attr = (Element) it.next();
         String name = attr.getChildTextTrim("name");
         String type = attr.getChildTextTrim("type");
         String getMethod = attr.getAttributeValue(GET_METHOD);
         String setMethod = attr.getAttributeValue(SET_METHOD);
         // Fabricate a getter operation
         if (getMethod != null)
         {

            Object getterOpType = getters.get(getMethod);
            if (getterOpType == null || getterOpType.equals(type) == false)
            {     
               Descriptor getterDescriptor = new DescriptorSupport();
               getterDescriptor.setField(NAME, getMethod);
               getterDescriptor.setField(DESCRIPTOR_TYPE, OPERATION_DESCRIPTOR);
               getterDescriptor.setField(ROLE, GETTER);
               ModelMBeanOperationInfo info = new ModelMBeanOperationInfo
               (
                  getMethod,
                  "getMethod operation for '" + name + "' attribute.",
                  new MBeanParameterInfo[0],
                  type,
                  MBeanOperationInfo.INFO,
                  getterDescriptor
               );
               infos.add(info);
            }
         }

         // Fabricate a setter operation
        
         if (setMethod != null)
         {
            HashSet setterOpTypes = (HashSet) setters.get(setMethod);
            if (setterOpTypes == null || setterOpTypes.contains(type) == false)
            {     
               Descriptor setterDescriptor = new DescriptorSupport();
               setterDescriptor.setField(NAME, setMethod);
               setterDescriptor.setField(DESCRIPTOR_TYPE, OPERATION_DESCRIPTOR);
               setterDescriptor.setField(ROLE, SETTER);
               ModelMBeanOperationInfo info = new ModelMBeanOperationInfo
               (
                  setMethod,
                  "setMethod operation for '" + name + "' attribute.",
                  new MBeanParameterInfo[]
View Full Code Here

      {
         Element notif = (Element) it.next();
         String name = notif.getChildTextTrim("name");
         String description = notif.getChildTextTrim("description");
         List notifTypes = notif.getChildren("notification-type");
         Descriptor descr = getDescriptor(notif, name, NOTIFICATION_DESCRIPTOR);

         List types = new ArrayList();

         for (Iterator iterator = notifTypes.iterator(); iterator.hasNext();)
         {
View Full Code Here

         String description = attr.getChildTextTrim("description");
         String type = attr.getChildTextTrim("type");
         String access = attr.getAttributeValue("access");
         String getMethod = attr.getAttributeValue("getMethod");
         String setMethod = attr.getAttributeValue("setMethod");
         Descriptor descr = getDescriptor(attr, name, ATTRIBUTE_DESCRIPTOR);
         //Convert types here from string to specified type
         String unconvertedValue = (String)descr.getFieldValue(VALUE);
         if (unconvertedValue != null && !"java.lang.String".equals(type))
         {
            descr.setField(VALUE, convertValue(unconvertedValue, type));
         }
         String unconvertedDefault = (String)descr.getFieldValue(DEFAULT);
         if (unconvertedDefault != null && !"java.lang.String".equals(type))
         {
            descr.setField(DEFAULT, convertValue(unconvertedDefault, type));
         }
         if (getMethod != null)
         {
            descr.setField(GET_METHOD, getMethod);
         } // end of if ()
        
         if (setMethod != null)
         {
            descr.setField(SET_METHOD, setMethod);
         } // end of if ()
        

         // defaults read-write
         boolean isReadable = true;
View Full Code Here

TOP

Related Classes of javax.management.Descriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.