/** * @param dep Deployment. * @param target Target object. * @param annCls Annotation class. * @throws GridException If failed to execute annotated methods. */ public void invokeAnnotated(GridDeployment dep, Object target, Class<? extends Annotation> annCls) throws GridException { if (target != null) { Collection<Method> mtds = getMethodsWithAnnotation(dep, target.getClass(), annCls); if (mtds != null) { for (Method mtd : mtds) { try { mtd.setAccessible(true); mtd.invoke(target); } catch (IllegalArgumentException | InvocationTargetException | IllegalAccessException e) { throw new GridException("Failed to invoke annotated method [job=" + target + ", mtd=" + mtd + ", ann=" + annCls + ']', e); } } } } }