Search in sources :

Example 1 with DuckTyped

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));
        }
    }
}
Also used : Method(java.lang.reflect.Method) DuckTyped(org.jvnet.hk2.config.DuckTyped)

Example 2 with DuckTyped

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;
}
Also used : DescriptorSupport(javax.management.modelmbean.DescriptorSupport) DuckTyped(org.jvnet.hk2.config.DuckTyped)

Example 3 with DuckTyped

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;
}
Also used : PropertiesDesc(org.glassfish.api.admin.config.PropertiesDesc) Attribute(org.jvnet.hk2.config.Attribute) AnnotationVisitor(org.glassfish.hk2.external.org.objectweb.asm.AnnotationVisitor) PropertyDesc(org.glassfish.api.admin.config.PropertyDesc)

Aggregations

DuckTyped (org.jvnet.hk2.config.DuckTyped)2 Method (java.lang.reflect.Method)1 DescriptorSupport (javax.management.modelmbean.DescriptorSupport)1 PropertiesDesc (org.glassfish.api.admin.config.PropertiesDesc)1 PropertyDesc (org.glassfish.api.admin.config.PropertyDesc)1 AnnotationVisitor (org.glassfish.hk2.external.org.objectweb.asm.AnnotationVisitor)1 Attribute (org.jvnet.hk2.config.Attribute)1