/** * Creates an instance of {@code ModelMBeanOperationInfo} for the * given method. Populates the parameter info for the operation. * @param method the {@code Method} to create a {@code ModelMBeanOperationInfo} for * @param name the logical name for the operation (method name or property name); * not used by the default implementation but possibly by subclasses * @param beanKey the key associated with the MBean in the beans map * of the {@code MBeanExporter} * @return the {@code ModelMBeanOperationInfo} */ protected ModelMBeanOperationInfo createModelMBeanOperationInfo(Method method, String name, String beanKey) { MBeanParameterInfo[] params = getOperationParameters(method, beanKey); if (params.length == 0) { return new ModelMBeanOperationInfo(getOperationDescription(method, beanKey), method); } else { return new ModelMBeanOperationInfo(method.getName(), getOperationDescription(method, beanKey), getOperationParameters(method, beanKey), method.getReturnType().getName(), MBeanOperationInfo.UNKNOWN); } }
/** * Creates an instance of {@code ModelMBeanOperationInfo} for the * given method. Populates the parameter info for the operation. * @param method the {@code Method} to create a {@code ModelMBeanOperationInfo} for * @param name the logical name for the operation (method name or property name); * not used by the default implementation but possibly by subclasses * @param beanKey the key associated with the MBean in the beans map * of the {@code MBeanExporter} * @return the {@code ModelMBeanOperationInfo} */ protected ModelMBeanOperationInfo createModelMBeanOperationInfo(Method method, String name, String beanKey) { MBeanParameterInfo[] params = getOperationParameters(method, beanKey); if (params.length == 0) { return new ModelMBeanOperationInfo(getOperationDescription(method, beanKey), method); } else { return new ModelMBeanOperationInfo(method.getName(), getOperationDescription(method, beanKey), getOperationParameters(method, beanKey), method.getReturnType().getName(), MBeanOperationInfo.UNKNOWN); } }
visibility = 4; ModelMBeanOperationInfo info = new ModelMBeanOperationInfo(m.getName(), description, extractParameterInfo(m),
private ModelMBeanOperationInfo getMBeanOperation(JmxOperation operation) { String name = operation.getName(); String description = operation.getDescription(); MBeanParameterInfo[] signature = getSignature(operation.getParameters()); String type = getType(operation.getOutputType()); int impact = getImpact(operation.getType()); return new ModelMBeanOperationInfo(name, description, signature, type, impact); }
public MBeanOperation(Method operation, String exportName, String description, MBeanParameterInfo... parameters) { this.operation = operation; this.signature = new Signature(operation); this.operationInfo = new ModelMBeanOperationInfo( exportName, description, parameters, operation.getReturnType().getName(), MBeanOperationInfo.UNKNOWN); }
public void addModelMBeanMethod(String name, String[] paramTypes, String[] paramNames, String[] paramDescs, String description, String rtype, Descriptor desc) { MBeanParameterInfo[] params = null; if (paramTypes != null) { params = new MBeanParameterInfo[ paramTypes.length ]; for (int i = 0; i < paramTypes.length; i++) { params[i] = new MBeanParameterInfo(paramNames[i], paramTypes[i], paramDescs[i]); } } operations.put(name, new ModelMBeanOperationInfo(name, description, params, rtype, MBeanOperationInfo.ACTION, desc)); }
public void addModelMBeanMethod(String name, String[] paramTypes, String[] paramNames, String[] paramDescs, String description, String rtype, Descriptor desc) { MBeanParameterInfo[] params = null; if (paramTypes != null) { params = new MBeanParameterInfo[ paramTypes.length ]; for (int i = 0; i < paramTypes.length; i++) { params[i] = new MBeanParameterInfo(paramNames[i], paramTypes[i], paramDescs[i]); } } operations.put(name, new ModelMBeanOperationInfo(name, description, params, rtype, MBeanOperationInfo.ACTION, desc)); }
@Override protected void addExtraOperations(List<ModelMBeanOperationInfo> operations) { operations.add(new ModelMBeanOperationInfo("findSessions", "findSessions", new MBeanParameterInfo[] { new MBeanParameterInfo("ognlQuery", String.class.getName(), "a boolean OGNL expression") }, Set.class.getName(), MBeanOperationInfo.INFO)); operations.add(new ModelMBeanOperationInfo("findAndRegisterSessions", "findAndRegisterSessions", new MBeanParameterInfo[] { new MBeanParameterInfo("ognlQuery", String.class.getName(), "a boolean OGNL expression") }, Set.class.getName(), MBeanOperationInfo.ACTION_INFO)); operations.add(new ModelMBeanOperationInfo("findAndProcessSessions", "findAndProcessSessions", new MBeanParameterInfo[] { new MBeanParameterInfo("ognlQuery", String.class.getName(), "a boolean OGNL expression"), new MBeanParameterInfo("ognlCommand", String.class.getName(), "an OGNL expression that modifies the state of the sessions in the match result") }, Set.class.getName(), MBeanOperationInfo.ACTION_INFO)); }
public MBeanInfo getMBeanInfo() { Descriptor lastLoadDateDesc = new DescriptorSupport(new String[] {"name=LastLoadDate", "descriptorType=attribute", "default=0", "displayName=Last Load Date", "getMethod=getLastLoadDate"}); Descriptor lastLoadTimeDesc = new DescriptorSupport(new String[] {"name=LastLoadTime", "descriptorType=attribute", "default=0", "displayName=Last Load Time", "getMethod=getLoadTime"}); ModelMBeanAttributeInfo[] mmbai = new ModelMBeanAttributeInfo[2]; mmbai[0] = new ModelMBeanAttributeInfo("LastLoadDate", "java.util.Date", "Last Load Date", true, false, false, lastLoadDateDesc); mmbai[1] = new ModelMBeanAttributeInfo("LastLoadTime", "java.lang.Long", "Last Load Time", true, false, false, lastLoadTimeDesc); ModelMBeanOperationInfo[] mmboi = new ModelMBeanOperationInfo[7]; mmboi[0] = new ModelMBeanOperationInfo("start", "Start DSpace Kernel", null, "void", ModelMBeanOperationInfo.ACTION); mmboi[1] = new ModelMBeanOperationInfo("stop", "Stop DSpace Kernel", null, "void", ModelMBeanOperationInfo.ACTION); mmboi[2] = new ModelMBeanOperationInfo("getManagedBean", "Get the Current Kernel", null, DSpaceKernel.class.getName(), ModelMBeanOperationInfo.INFO); return new ModelMBeanInfoSupport(this.getClass().getName(), "DSpace Kernel", mmbai, null, mmboi, null); }
public MBeanInfo getMBeanInfo() { Descriptor lastLoadDateDesc = new DescriptorSupport(new String[] {"name=LastLoadDate", "descriptorType=attribute", "default=0", "displayName=Last Load Date", "getMethod=getLastLoadDate"}); Descriptor lastLoadTimeDesc = new DescriptorSupport(new String[] {"name=LastLoadTime", "descriptorType=attribute", "default=0", "displayName=Last Load Time", "getMethod=getLoadTime" }); ModelMBeanAttributeInfo[] mmbai = new ModelMBeanAttributeInfo[2]; mmbai[0] = new ModelMBeanAttributeInfo("LastLoadDate", "java.util.Date", "Last Load Date", true, false, false, lastLoadDateDesc); mmbai[1] = new ModelMBeanAttributeInfo("LastLoadTime", "java.lang.Long", "Last Load Time", true, false, false, lastLoadTimeDesc); ModelMBeanOperationInfo[] mmboi = new ModelMBeanOperationInfo[7]; mmboi[0] = new ModelMBeanOperationInfo("start", "Start DSpace Kernel", null, "void", ModelMBeanOperationInfo.ACTION); mmboi[1] = new ModelMBeanOperationInfo("stop", "Stop DSpace Kernel", null, "void", ModelMBeanOperationInfo.ACTION); mmboi[2] = new ModelMBeanOperationInfo("getManagedBean", "Get the Current Kernel", null, DSpaceKernel.class.getName(), ModelMBeanOperationInfo.INFO); return new ModelMBeanInfoSupport(this.getClass().getName(), "DSpace Kernel", mmbai, null, mmboi, null); }
private MBeanInfo createModelMBeanInfo(T source) { String className = source.getClass().getName(); String description = ""; ModelMBeanConstructorInfo[] constructors = new ModelMBeanConstructorInfo[0]; ModelMBeanNotificationInfo[] notifications = new ModelMBeanNotificationInfo[0]; List<ModelMBeanAttributeInfo> attributes = new ArrayList<ModelMBeanAttributeInfo>(); List<ModelMBeanOperationInfo> operations = new ArrayList<ModelMBeanOperationInfo>(); addAttributes(attributes, source); addExtraAttributes(attributes); addOperations(operations, source); addExtraOperations(operations); operations.add(new ModelMBeanOperationInfo("unregisterMBean", "unregisterMBean", new MBeanParameterInfo[0], void.class.getName(), ModelMBeanOperationInfo.ACTION)); return new ModelMBeanInfoSupport(className, description, attributes.toArray(new ModelMBeanAttributeInfo[attributes.size()]), constructors, operations.toArray(new ModelMBeanOperationInfo[operations.size()]), notifications); }
public MBeanInfo getMBeanInfo() { Descriptor lastLoadDateDesc = new DescriptorSupport(new String[] {"name=LastLoadDate", "descriptorType=attribute", "default=0", "displayName=Last Load Date", "getMethod=getLastLoadDate"}); Descriptor lastLoadTimeDesc = new DescriptorSupport(new String[] {"name=LastLoadTime", "descriptorType=attribute", "default=0", "displayName=Last Load Time", "getMethod=getLoadTime" }); ModelMBeanAttributeInfo[] mmbai = new ModelMBeanAttributeInfo[2]; mmbai[0] = new ModelMBeanAttributeInfo("LastLoadDate", "java.util.Date", "Last Load Date", true, false, false, lastLoadDateDesc); mmbai[1] = new ModelMBeanAttributeInfo("LastLoadTime", "java.lang.Long", "Last Load Time", true, false, false, lastLoadTimeDesc); ModelMBeanOperationInfo[] mmboi = new ModelMBeanOperationInfo[7]; mmboi[0] = new ModelMBeanOperationInfo("start", "Start DSpace Kernel", null, "void", ModelMBeanOperationInfo.ACTION); mmboi[1] = new ModelMBeanOperationInfo("stop", "Stop DSpace Kernel", null, "void", ModelMBeanOperationInfo.ACTION); mmboi[2] = new ModelMBeanOperationInfo("getManagedBean", "Get the Current Kernel", null, DSpaceKernel.class.getName(), ModelMBeanOperationInfo.INFO); return new ModelMBeanInfoSupport(this.getClass().getName(), "DSpace Kernel", mmbai, null, mmboi, null); }
/** * Creates an instance of {@code ModelMBeanOperationInfo} for the * given method. Populates the parameter info for the operation. * @param method the {@code Method} to create a {@code ModelMBeanOperationInfo} for * @param name the logical name for the operation (method name or property name); * not used by the default implementation but possibly by subclasses * @param beanKey the key associated with the MBean in the beans map * of the {@code MBeanExporter} * @return the {@code ModelMBeanOperationInfo} */ protected ModelMBeanOperationInfo createModelMBeanOperationInfo(Method method, String name, String beanKey) { MBeanParameterInfo[] params = getOperationParameters(method, beanKey); if (params.length == 0) { return new ModelMBeanOperationInfo(getOperationDescription(method, beanKey), method); } else { return new ModelMBeanOperationInfo(method.getName(), getOperationDescription(method, beanKey), getOperationParameters(method, beanKey), method.getReturnType().getName(), MBeanOperationInfo.UNKNOWN); } }
private MBeanInfo createModelMBeanInfo(T source) { String className = source.getClass().getName(); String description = ""; ModelMBeanConstructorInfo[] constructors = new ModelMBeanConstructorInfo[0]; ModelMBeanNotificationInfo[] notifications = new ModelMBeanNotificationInfo[0]; List<ModelMBeanAttributeInfo> attributes = new ArrayList<>(); List<ModelMBeanOperationInfo> operations = new ArrayList<>(); addAttributes(attributes, source); addExtraAttributes(attributes); addOperations(operations, source); addExtraOperations(operations); operations.add(new ModelMBeanOperationInfo( "unregisterMBean", "unregisterMBean", new MBeanParameterInfo[0], void.class.getName(), ModelMBeanOperationInfo.ACTION)); return new ModelMBeanInfoSupport( className, description, attributes.toArray(new ModelMBeanAttributeInfo[attributes.size()]), constructors, operations.toArray(new ModelMBeanOperationInfo[operations.size()]), notifications); }
@Override protected void addExtraOperations(List<ModelMBeanOperationInfo> operations) { operations.add(new ModelMBeanOperationInfo( "findSessions", "findSessions", new MBeanParameterInfo[] { new MBeanParameterInfo( "ognlQuery", String.class.getName(), "a boolean OGNL expression") }, Set.class.getName(), MBeanOperationInfo.INFO)); operations.add(new ModelMBeanOperationInfo( "findAndRegisterSessions", "findAndRegisterSessions", new MBeanParameterInfo[] { new MBeanParameterInfo( "ognlQuery", String.class.getName(), "a boolean OGNL expression") }, Set.class.getName(), MBeanOperationInfo.ACTION_INFO)); operations.add(new ModelMBeanOperationInfo( "findAndProcessSessions", "findAndProcessSessions", new MBeanParameterInfo[] { new MBeanParameterInfo( "ognlQuery", String.class.getName(), "a boolean OGNL expression"), new MBeanParameterInfo( "ognlCommand", String.class.getName(), "an OGNL expression that modifies the state of the sessions in the match result") }, Set.class.getName(), MBeanOperationInfo.ACTION_INFO)); }
private static ModelMBeanOperationInfo doOperation(Method methods[], int i, boolean isGetterOrSetter) throws JMException { Descriptor desc = new DescriptorSupport(); desc.setField("name", methods[i].getName()); desc.setField("descriptorType", "operation"); // MAKE SURE THAT THE AGENT DOESN'T READ FROM CACHE (0 does not work // with JMX RI) // desc.setField("currencyTimeLimit", "1"); //!!! desc.setField("currencyTimeLimit", CURRENCY_TIME_LIMIT); // IF THE METHOD STARTS WITH "get" or "is" TREAT IT AS A GETTER. // IF IT STARTS WITH A "set" TREAT IT AS A SETTER. if (isGetterOrSetter) { if ((methods[i].getName().startsWith("get") || methods[i].getName().startsWith("is")) && (methods[i].getParameterTypes().length == 0)) { desc.setField("role", "getter"); } else if (methods[i].getName().startsWith("set") && (methods[i].getParameterTypes().length == 1)) { desc.setField("role", "setter"); } } else { desc.setField("role", "operation"); } ModelMBeanOperationInfo mmoi = new ModelMBeanOperationInfo(methods[i].getName(), methods[i], desc); return mmoi; }
public Object instantiate() { MBeanParameterInfo[] sig = new MBeanParameterInfo[params.size()]; params.toArray(sig); if( descriptor != null ) { if( descriptor.getFieldValue(ModelMBeanConstants.NAME) == null ) descriptor.setField(ModelMBeanConstants.NAME, name); if( descriptor.getFieldValue(ModelMBeanConstants.DESCRIPTOR_TYPE) == null ) descriptor.setField(ModelMBeanConstants.DESCRIPTOR_TYPE, ModelMBeanConstants.OPERATION_DESCRIPTOR); if( descriptor.getFieldValue(ModelMBeanConstants.ROLE) == null ) descriptor.setField(ModelMBeanConstants.ROLE, ModelMBeanConstants.ROLE_OPERATION); } int operImpact = MBeanOperationInfo.ACTION_INFO; if (impact != null) { if (impact.equals(ModelMBeanConstants.INFO)) operImpact = MBeanOperationInfo.INFO; else if (impact.equals(ModelMBeanConstants.ACTION)) operImpact = MBeanOperationInfo.ACTION; else if (impact.equals(ModelMBeanConstants.ACTION_INFO)) operImpact = MBeanOperationInfo.ACTION_INFO; } ModelMBeanOperationInfo info = new ModelMBeanOperationInfo(name, description, sig, returnType, operImpact, descriptor); return info; } public void addChild(QName name, Object value)
protected void doCollectOperations(Class<?> clazz, BeanInfo beanInfo) { for (MethodDescriptor methodInfo : beanInfo.getMethodDescriptors()) { if (methodInfo.isHidden()) { continue; } Descriptor descriptor = doGetDescriptor(methodInfo, "operation"); String name = methodInfo.getName(); Method method = methodInfo.getMethod(); ParameterDescriptor[] parameters = methodInfo.getParameterDescriptors(); boolean hasParameters = parameters != null && parameters.length > 0; Class<?> returnType = method.getReturnType(); boolean returnValue = returnType != null && !void.class.equals(returnType); if ((name.startsWith("get") && hasParameters && returnValue) || (name.startsWith("is") && !hasParameters && boolean.class.equals(returnType))) { descriptor.setField("role", "getter"); } else if (methodInfo.getName().startsWith("set") && void.class.equals(returnType) && hasParameters && parameters.length == 1) { // doFixAttribute(clazz, methodInfo.getName()); descriptor.setField("role", "setter"); } else { descriptor.setField("role", "operation"); } ModelMBeanOperationInfo operationInfo = new ModelMBeanOperationInfo(methodInfo.getShortDescription(), methodInfo.getMethod(), descriptor); operationsInfo.put(operationInfo.getName(), operationInfo); } }
public ModelMBeanBuilder operation( String name, String description, String returnType, int impact, MBeanParameterInfo... parameters) { Descriptor stateDesc = new DescriptorSupport(); stateDesc.setField( "name", name ); stateDesc.setField( "descriptorType", "operation" ); stateDesc.setField( "class", className ); stateDesc.setField( "role", "operation" ); stateDesc.setField( "targetType", "objectReference" ); ModelMBeanOperationInfo operationInfo = new ModelMBeanOperationInfo( name, description, parameters, returnType, impact, stateDesc); operations.add( operationInfo ); return this; }
public ModelMBeanBuilder operation( String name, String description, String returnType, int impact, MBeanParameterInfo... parameters) { Descriptor stateDesc = new DescriptorSupport(); stateDesc.setField( "name", name ); stateDesc.setField( "descriptorType", "operation" ); stateDesc.setField( "class", className ); stateDesc.setField( "role", "operation" ); stateDesc.setField( "targetType", "objectReference" ); ModelMBeanOperationInfo operationInfo = new ModelMBeanOperationInfo( name, description, parameters, returnType, impact, stateDesc); operations.add( operationInfo ); return this; }