public static <X extends RemoteEnvironment> void processMethodAnnotations(InjectionContainer container, Collection<InjectionHandler<X>> handlers, Set<String> visitedMethods, Class<?> clazz, Map<AccessibleObject, Injector> classInjectors) { if (clazz == null || clazz.equals(Object.class)) { return; } Method[] methods = clazz.getDeclaredMethods(); for (Method method : methods) { if (method.getParameterTypes().length != 1) continue; if (!Modifier.isPrivate(method.getModifiers())) { if (visitedMethods.contains(method.getName())) { continue; } visitedMethods.add(method.getName()); } if (handlers != null) { for (InjectionHandler<?> handler : handlers) { handler.handleMethodAnnotations(method, container, classInjectors); } } } // recursion needs to come last as the method could be overriden and we don't want the overriding method to be ignored processMethodAnnotations(container, handlers, visitedMethods, clazz.getSuperclass(), classInjectors); }
public static <X extends RemoteEnvironment> Map<AccessibleObject, Injector> processAnnotations(InjectionContainer container, Collection<InjectionHandler<X>> handlers, Class<?> clazz) { Map<AccessibleObject, Injector> classInjectors = new HashMap<AccessibleObject, Injector>(); HashSet<String> visitedMethods = new HashSet<String>(); collapseXmlMethodInjectors(visitedMethods, clazz, container.getEncInjections(), classInjectors); processClassAnnotations(container, handlers, clazz); visitedMethods = new HashSet<String>(); processMethodAnnotations(container, handlers, visitedMethods, clazz, classInjectors); processFieldAnnotations(container, handlers, clazz, classInjectors); return classInjectors; }