Search in sources :

Example 1 with MethodInjectionPoint

use of jodd.petite.MethodInjectionPoint in project jodd by oblac.

the class MethodResolver method resolve.

public MethodInjectionPoint[] resolve(Class type) {
    // lookup methods
    ClassDescriptor cd = ClassIntrospector.lookup(type);
    List<MethodInjectionPoint> list = new ArrayList<>();
    MethodDescriptor[] allMethods = cd.getAllMethodDescriptors();
    for (MethodDescriptor methodDescriptor : allMethods) {
        Method method = methodDescriptor.getMethod();
        if (ReflectUtil.isBeanPropertySetter(method)) {
            // ignore setters
            continue;
        }
        if (method.getParameterTypes().length == 0) {
            // ignore methods with no argument
            continue;
        }
        PetiteInject ref = method.getAnnotation(PetiteInject.class);
        if (ref == null) {
            continue;
        }
        String[][] references = PetiteUtil.convertAnnValueToReferences(ref.value());
        list.add(injectionPointFactory.createMethodInjectionPoint(method, references));
    }
    MethodInjectionPoint[] methods;
    if (list.isEmpty()) {
        methods = MethodInjectionPoint.EMPTY;
    } else {
        methods = list.toArray(new MethodInjectionPoint[list.size()]);
    }
    return methods;
}
Also used : ClassDescriptor(jodd.introspector.ClassDescriptor) ArrayList(java.util.ArrayList) PetiteInject(jodd.petite.meta.PetiteInject) Method(java.lang.reflect.Method) MethodDescriptor(jodd.introspector.MethodDescriptor) MethodInjectionPoint(jodd.petite.MethodInjectionPoint)

Aggregations

Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 ClassDescriptor (jodd.introspector.ClassDescriptor)1 MethodDescriptor (jodd.introspector.MethodDescriptor)1 MethodInjectionPoint (jodd.petite.MethodInjectionPoint)1 PetiteInject (jodd.petite.meta.PetiteInject)1