Java Code Examples for javax.management.MBeanAttributeInfo#getType()

The following examples show how to use javax.management.MBeanAttributeInfo#getType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JmxMetadata.java    From presto with Apache License 2.0 6 votes vote down vote up
private static Type getColumnType(MBeanAttributeInfo attribute)
{
    switch (attribute.getType()) {
        case "boolean":
        case "java.lang.Boolean":
            return BOOLEAN;
        case "byte":
        case "java.lang.Byte":
        case "short":
        case "java.lang.Short":
        case "int":
        case "java.lang.Integer":
        case "long":
        case "java.lang.Long":
            return BIGINT;
        case "java.lang.Number":
        case "float":
        case "java.lang.Float":
        case "double":
        case "java.lang.Double":
            return DOUBLE;
    }
    return createUnboundedVarcharType();
}
 
Example 2
Source File: ModuleMBean.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public MBeanAttributeInfo[] setSystemResourceNonEditable(MBeanAttributeInfo[] currentAttr){
    MBeanAttributeInfo[] updatedAttr = null;
    try{
        updatedAttr = new MBeanAttributeInfo[currentAttr.length];
        for ( int i=0; i<currentAttr.length; i++ ) {
            MBeanAttributeInfo currentAttrInfo = currentAttr[i];
            updatedAttr[i] = new MBeanAttributeInfo(currentAttrInfo.getName(), currentAttrInfo.getType(), currentAttrInfo.getDescription(), true, false, false);
        }    
    }catch(Exception ex){
        //System.out.println("Error in setSystemResourceNonEditable " + ex.getLocalizedMessage());
    }
    return updatedAttr;
}
 
Example 3
Source File: ArtemisMBeanServerGuard.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private void handleSetAttribute(MBeanServer proxy, ObjectName objectName, Attribute attribute) throws JMException, IOException {
   String dataType = null;
   MBeanInfo info = proxy.getMBeanInfo(objectName);
   for (MBeanAttributeInfo attr : info.getAttributes()) {
      if (attr.getName().equals(attribute.getName())) {
         dataType = attr.getType();
         break;
      }
   }

   if (dataType == null)
      throw new IllegalStateException("Attribute data type can not be found");

   handleInvoke(objectName, "set" + attribute.getName(), new Object[]{attribute.getValue()}, new String[]{dataType});
}
 
Example 4
Source File: Server.java    From ironjacamar with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Get MBean attribute result info
 * @param name The bean name
 * @param attrInfo The attribute information
 * @return The data
 * @exception JMException Thrown if an error occurs
 */
public static AttrResultInfo getMBeanAttributeResultInfo(String name, MBeanAttributeInfo attrInfo)
   throws JMException
{
   ClassLoader loader = SecurityActions.getThreadContextClassLoader();
   MBeanServer server = getMBeanServer();
   ObjectName objName = new ObjectName(name);
   String attrName = attrInfo.getName();
   String attrType = attrInfo.getType();
   Object value = null;
   Throwable throwable = null;

   if (attrInfo.isReadable())
   {
      try
      {
         value = server.getAttribute(objName, attrName);
      }
      catch (Throwable t)
      {
         throwable = t;
      }
   }

   Class typeClass = null;
   try
   {
      typeClass = Classes.getPrimitiveTypeForName(attrType);
      if (typeClass == null)
         typeClass = loader.loadClass(attrType);
   }
   catch (ClassNotFoundException cnfe)
   {
      // Ignore
   }

   PropertyEditor editor = null;
   if (typeClass != null)
      editor = PropertyEditorManager.findEditor(typeClass);

   return new AttrResultInfo(attrName, editor, value, throwable);
}