templates.decorator.mbeaninfo.class.vm Maven / Gradle / Ivy
The newest version!
#parse( "${include}/header.include.vm" )
#parse("${include}/generic.include.vm")
#set ( $methods = $sourceinfo.getMethodsNeedGenerated(true) )
#set ( $properties = $sourceinfo.properties )
#set ( $interfaceName = "${sourceinfo.interfaceClass.simpleName}")
#set ( $className ="${interfaceName}MBeanInfo")
$codewriter.setCurrentJavaFilename("$pkg", "${className}.java")
## 读取源码注释
#set ($interfaceDoc = $JavadocReader.read(${sourceinfo.interfaceClass}))
package $pkg;
#outputImports()
import javax.management.MBeanInfo;
import javax.management.MBeanAttributeInfo;
import javax.management.MBeanOperationInfo;
import javax.management.MBeanParameterInfo;
/**
* {@link #typeName(${sourceinfo.interfaceClass})}接口的{@link MBeanInfo}
* $GENERAED_BY
* @author guyadong
*
*/
public class ${className}{
private static MBeanOperationInfo
makeMBeanOperationInfo(String methodName,
String methodDesc,
String returnType,
String[] paramNames,
String[] paramTypes,
String[] paramDescs){
MBeanParameterInfo[] parameterInfos = new MBeanParameterInfo[paramNames.length];
for(int i = 0; i < parameterInfos.length; ++i){
parameterInfos[i] = new MBeanParameterInfo(paramNames[i],paramTypes[i],paramDescs[i]);
}
return new MBeanOperationInfo(methodName,
methodDesc,
parameterInfos,
returnType,
MBeanOperationInfo.INFO
);
}
private static MBeanOperationInfo[] makeOperationsInfo(){
MBeanOperationInfo[] operations = new MBeanOperationInfo[${methods.size()}];
#foreach ($method in $TOOL.sortBySignature($methods))
operations[$foreach.index] = makeMBeanOperationInfo("$method.name",
$TOOL.asJavaString($interfaceDoc.commentTextOf(${method.delegate()})),
"#fullTypeName($method.genericReturnType)",
new String[]{#join($method.parameters """$e.name""" ',')},
new String[]{#join($method.parameters """#fullTypeName($e.genericType)""" ',')},
new String[]{#join($method.parameters "$TOOL.asJavaString($interfaceDoc.parameterCommentOf(${method.delegate()},$e.name))" ',')}
);
#end##foreach
return operations;
}
private static MBeanAttributeInfo[] makeAttributesInfo(){
MBeanAttributeInfo[] operations = new MBeanAttributeInfo[${properties.size()}];
#foreach ($descriptor in $TOOL.sortByName(${properties.values()}))
#set ($methodComment = ${interfaceDoc.commentTextOf($descriptor.readMethod)})
#if(! $methodComment)
#set ($methodComment = ${interfaceDoc.commentTextOf($descriptor.writeMethod)})
#end
operations[$foreach.index] = new MBeanAttributeInfo("$descriptor.name",
"#typeName($descriptor.propertyType)",
$TOOL.asJavaString($methodComment),
${sourceinfo.isReadable($descriptor)},
${sourceinfo.isWritable($descriptor)},
${sourceinfo.isIs($descriptor.readMethod)},
null
);
#end##foreach
return operations;
}
public static final MBeanInfo MBEANINFO = new MBeanInfo(
"${sourceinfo.interfaceClass.name}",
$TOOL.asJavaString($!{interfaceDoc.commentText()}),
makeAttributesInfo(),
null,
makeOperationsInfo(),
null);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy