Skip to content
Snippets Groups Projects

add new features

Merged Tucker Gary Siegel requested to merge addition into develop
21 files
+ 653
6
Compare changes
  • Side-by-side
  • Inline
Files
21
 
package edu.umd.dawn.common.annotations;
 
 
import java.lang.annotation.Annotation;
 
import org.aspectj.lang.ProceedingJoinPoint;
 
import org.aspectj.lang.annotation.Aspect;
 
import org.aspectj.lang.annotation.Pointcut;
 
import org.aspectj.lang.reflect.MethodSignature;
 
import org.springframework.stereotype.Component;
 
 
/**
 
* base class for custom aspects for annotations. includes some helper functions
 
*/
 
@Aspect
 
@Component
 
public class AspectBase<T extends Annotation> {
 
 
@Pointcut(value = "execution(* *.*(..))")
 
protected void allMethods() {}
 
 
protected String getFullDescriptor(ProceedingJoinPoint jointPoint) {
 
String className = ((MethodSignature) jointPoint.getSignature()).getDeclaringTypeName();
 
String methodName =
 
((MethodSignature) jointPoint.getSignature()).getMethod().getName();
 
return className + "." + methodName;
 
}
 
 
protected T grabAnnotation(ProceedingJoinPoint jointPoint, Class<T> clazz) {
 
return ((MethodSignature) jointPoint.getSignature()).getMethod().getAnnotation(clazz);
 
}
 
 
protected T grabAnnotationFromClass(ProceedingJoinPoint jointPoint, Class<T> clazz) {
 
return (T)
 
((MethodSignature) jointPoint.getSignature()).getDeclaringType().getAnnotation(clazz);
 
}
 
 
// protected T grabMethodArgument(ProceedingJoinPoint jointPoint, Class<T> clazz) {
 
// return (T)
 
// ((MethodSignature) jointPoint.getSignature()).getDeclaringType().getAnnotation(clazz);
 
// }
 
}
Loading