/** * Gets list of methods in specified class annotated with specified annotation. * * @param dep Class deployment. * @param rsrcCls Class to find methods in. * @param annCls Annotation to find annotated methods with. * @return List of annotated methods. */ @Nullable public Collection<Method> getMethodsWithAnnotation(GridDeployment dep, Class<?> rsrcCls, Class<? extends Annotation> annCls) { assert dep != null; assert rsrcCls != null; assert annCls != null; List<GridResourceMethod> mtds = ioc.getMethodsWithAnnotation(dep, rsrcCls, annCls); assert mtds != null; if (!mtds.isEmpty()) { return F.viewReadOnly(mtds, new C1<GridResourceMethod, Method>() { @Override public Method apply(GridResourceMethod rsrcMtd) { return rsrcMtd.getMethod(); } }); } return null; }
/** * Checks if annotation is presented on a field or method of the specified object. * * @param target Target object. * @param annCls Annotation class to find on fields or methods of target object. * @param dep Deployment. * @return {@code true} if annotation is presented, {@code false} if it's not. */ boolean isAnnotationPresent(Object target, Class<? extends Annotation> annCls, @Nullable GridDeployment dep) { assert target != null; assert annCls != null; Class<?> targetCls = target.getClass(); Set<Class<?>> skipClss = skipCache.get(annCls); if (skipClss != null && skipClss.contains(targetCls)) return false; List<GridResourceField> fields = getFieldsWithAnnotation(dep, targetCls, annCls); if (!fields.isEmpty()) return true; List<GridResourceMethod> mtds = getMethodsWithAnnotation(dep, targetCls, annCls); if (mtds.isEmpty()) { if (skipClss == null) skipClss = F.addIfAbsent(skipCache, annCls, F.<Class<?>>newCSet()); skipClss.add(targetCls); return false; } return true; }
for (GridResourceMethod mtd : getMethodsWithAnnotation(dep, targetCls, annCls)) { injector.inject(mtd, target, depCls, dep);