use of io.vertigo.core.component.aop.Aspect in project vertigo by KleeGroup.
the class ComponentLoader method createAspect.
private static Aspect createAspect(final Container container, final AspectConfig aspectConfig) {
// création de l'instance du composant
final Aspect aspect = DIInjector.newInstance(aspectConfig.getAspectClass(), container);
// ---
Assertion.checkNotNull(aspect.getAnnotationType());
return aspect;
}
use of io.vertigo.core.component.aop.Aspect in project vertigo by KleeGroup.
the class ComponentAspectUtil method createAspectsByMethod.
/**
* create all "join points" for a component.
* Join points are identifed by a method
*
* @return Map des aspects par méthode
*/
static Map<Method, List<Aspect>> createAspectsByMethod(final Class<?> implClass, final Collection<Aspect> aspects) {
Assertion.checkNotNull(implClass);
Assertion.checkNotNull(aspects);
// -----
// 1 - Annotated class
final List<Aspect> classBasedInterceptors = Stream.of(implClass.getAnnotations()).filter(annotation -> annotation.annotationType().isAnnotationPresent(AspectAnnotation.class)).map(annotation -> findAspect(annotation, aspects)).collect(Collectors.toList());
// 2 - Annotated methods
final Map<Method, List<Aspect>> joinPoints = new HashMap<>();
for (final Method method : implClass.getMethods()) {
final List<Aspect> methodBasedInterceptors = Stream.of(method.getAnnotations()).filter(annotation -> annotation.annotationType().isAnnotationPresent(AspectAnnotation.class)).map(annotation -> findAspect(annotation, aspects)).collect(Collectors.toList());
if (!classBasedInterceptors.isEmpty() && !Object.class.equals(method.getDeclaringClass())) {
// we add all class based interceptors on "no-object" methods
methodBasedInterceptors.addAll(classBasedInterceptors);
}
if (!methodBasedInterceptors.isEmpty()) {
// there is at least on aspect on this method
joinPoints.put(method, methodBasedInterceptors);
}
}
return joinPoints;
}
Aggregations