use of org.jvnet.hk2.config.DuckTyped in project Payara by payara.
the class ConfigBeanJMXSupport method findStuff.
private void findStuff(final Class<? extends ConfigBeanProxy> intf, final List<AttributeMethodInfo> attrs, final List<ElementMethodInfo> elements, final List<DuckTypedInfo> duckTyped) {
for (final Method m : intf.getMethods()) {
AttributeMethodInfo a;
// debug( "Method: " + m.getName() + " on " + m.getDeclaringClass() );
if ((a = AttributeMethodInfo.get(m)) != null) {
attrs.add(a);
if (a.returnType() != String.class) {
AMXLoggerInfo.getLogger().log(Level.INFO, AMXLoggerInfo.illegalNonstring, new Object[] { intf.getName(), m.getName(), a.returnType().getName() });
}
continue;
}
ElementMethodInfo e;
if ((e = ElementMethodInfo.get(m)) != null) {
elements.add(e);
continue;
}
final DuckTyped dt = m.getAnnotation(DuckTyped.class);
if (dt != null && isRemoteableDuckTyped(m, dt)) {
duckTyped.add(new DuckTypedInfo(m, dt));
}
}
}
use of org.jvnet.hk2.config.DuckTyped in project Payara by payara.
the class ConfigBeanJMXSupport method descriptor.
public static DescriptorSupport descriptor(final DuckTyped dt) {
final DescriptorSupport d = new DescriptorSupport();
d.setField(DESC_KIND, DuckTyped.class.getName());
return d;
}
use of org.jvnet.hk2.config.DuckTyped 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