use of org.glassfish.api.admin.config.PropertyDesc in project Payara by payara.
the class HtmlFormat method printPropertyData.
private void printPropertyData(final ClassDef def) {
final Set<PropertyDesc> properties = def.getProperties();
if (properties != null && !properties.isEmpty()) {
println(detail, "<tr><td colspan=\"2\">");
println(detail, "<table>");
println(detail, "<tr class=\"TableHeadingColor\">");
println(detail, "<th colspan=\"4\">Properties</th>");
println(detail, "</tr>");
println(detail, "<tr class=\"TableHeadingColor\">");
println(detail, "<th>name</th>");
println(detail, "<th>default</th>");
println(detail, "<th>values</th>");
println(detail, "<th>description</th>");
println(detail, "</tr>");
for (PropertyDesc property : properties) {
println(detail, "<tr>");
println(detail, String.format("<td class=\"TableSubHeadingColor\">%s</td>", property.name()));
println(detail, String.format("<td class=\"nobreak\">%s</td>", property.defaultValue()));
println(detail, String.format("<td>%s</td>", property.values().length == 0 ? "" : Arrays.toString(property.values())));
println(detail, String.format("<td>%s</td>", property.description()));
println(detail, "</tr>");
}
println(detail, "</table>");
println(detail, "</td></tr>");
}
}
use of org.glassfish.api.admin.config.PropertyDesc in project Payara by payara.
the class ConfigBeanJMXSupport method elementToMBeanAttributeInfo.
/**
* @Elements are represented as Attributes: getters for sub-elements are presented
* as ObjectName, Collection<String> presented as String[], Collection<? extends ConfigBeanProxy>
* represented as ObjectName[].
*/
public MBeanAttributeInfo elementToMBeanAttributeInfo(final Method m) {
// we assume that all getters are writeable for now, not true for sub-elements (ObjectName)
boolean isWriteable = true;
final ElementMethodInfo info = ElementMethodInfo.get(m);
if (info == null || info.anonymous()) {
return null;
}
// eg strip the "get"
final String name = info.attrName();
final String xmlName = info.xmlName();
// debug( m.getName() + " => " + name + " => " + xmlName );
final Class methodReturnType = info.returnType();
Class<?> returnType = null;
if (info.intf() != null) {
// some sub-type, which we must represent as an ObjectName
returnType = ObjectName.class;
isWriteable = false;
} else if (Collection.class.isAssignableFrom(methodReturnType)) {
final Type genericReturnType = m.getGenericReturnType();
if (genericReturnType instanceof ParameterizedType) {
final ParameterizedType pt = (ParameterizedType) genericReturnType;
final Type[] argTypes = pt.getActualTypeArguments();
if (argTypes.length == 1) {
final Type argType = argTypes[0];
if ((argType instanceof Class) && (Class) argType == String.class) {
returnType = String[].class;
} else {
returnType = ObjectName[].class;
isWriteable = false;
}
}
}
} else {
// some unknown type we cannot handle
}
MBeanAttributeInfo attrInfo = null;
if (returnType != null) {
final DescriptorSupport descriptor = descriptor(info.element());
descriptor.setField(DESC_ELEMENT_CLASS, returnType.getName());
descriptor.setField(DESC_XML_NAME, xmlName);
final ToDo toDo = info.method().getAnnotation(ToDo.class);
if (toDo != null) {
descriptor.setField(DESC_CONFIG_PREFIX + "toDo", toDo.priority() + ", " + toDo.details());
}
final PropertiesDesc props = info.method().getAnnotation(PropertiesDesc.class);
if (props != null) {
final String propType = props.systemProperties() ? "system-property" : "property";
for (final PropertyDesc p : props.props()) {
final String value = p.defaultValue() + " | " + p.dataType().getName() + " | " + p.description();
descriptor.setField(DESC_CONFIG_PREFIX + propType + "." + p.name(), value);
}
}
String description = "@Element " + name + " of interface " + mIntf.getName();
final boolean isReadable = true;
final boolean isIs = false;
attrInfo = new MBeanAttributeInfo(name, returnType.getName(), description, isReadable, isWriteable, isIs, descriptor);
}
return attrInfo;
}
use of org.glassfish.api.admin.config.PropertyDesc in project Payara by payara.
the class AttributeMethodVisitor method visitAnnotation.
/**
* Visits an annotation of this method.
*
* @param desc the class descriptor of the annotation class.
* @param visible <tt>true</tt> if the annotation is visible at runtime.
*
* @return a visitor to visit the annotation values, or <tt>null</tt> if this visitor is not interested in visiting
* this annotation.
*/
@Override
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
duckTyped |= "Lorg/jvnet/hk2/config/DuckTyped;".equals(desc);
AnnotationVisitor visitor = null;
if ("Lorg/jvnet/hk2/config/Attribute;".equals(desc) || "Lorg/jvnet/hk2/config/Element;".equals(desc)) {
try {
final Class<?> configurable = Thread.currentThread().getContextClassLoader().loadClass(def.getDef());
final Attribute annotation = configurable.getMethod(name).getAnnotation(Attribute.class);
def.addAttribute(name, annotation);
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
} else if ("Lorg/glassfish/api/admin/config/PropertiesDesc;".equals(desc)) {
try {
final Class<?> configurable = Thread.currentThread().getContextClassLoader().loadClass(def.getDef());
final PropertiesDesc annotation = configurable.getMethod(name).getAnnotation(PropertiesDesc.class);
final PropertyDesc[] propertyDescs = annotation.props();
for (PropertyDesc prop : propertyDescs) {
def.addProperty(prop);
}
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
}
return visitor;
}
Aggregations