Thanks it works.
Still I wanted to split logging aspect class and pointcuts class. I've created base class for pointacuts as follows:
Code:
// tried interface as well to no avail
public abstract class LoggingPointcuts {
@Pointcut("")
public abstract void pointcuts();
}
and derived concrete aspect class like this:
Code:
@Aspect
public class Module1LoggingPointcuts extends LoggingPointcuts {
@Pointcut("execution(public * com.xyz.modul1.pkg1.ResultController.*(javax.servl et.http.HttpServletRequest, ..))"
public void pointcuts() {}
}
Logging aspect is using the base LoggingPointcuts class:
Code:
@Aspect
public class LoggingAspect {
public static final Logger logger = LoggerFactory.getLogger(LoggingAspect.class);
// tried full import path to LoggingPointcuts to no avail
@Around("LoggingPointcuts.pointcuts()")
public void logAround(ProceedingJoinPoint joinPoint) throws Throwable {
logger.debug("logAround() is running!");
logger.debug("hijacked method : " + joinPoint.getSignature().getName());
logger.debug("hijacked arguments : "
+ Arrays.toString(joinPoint.getArgs()));
logger.debug("Around before is running!");
joinPoint.proceed(); // continue on the intercepted method
logger.debug("Around after is running!");
logger.debug("******");
}
}
Unfortunately it seems to fail during Spring wiring with the following exception:
java.lang.IllegalStateException: Failed to load ApplicationContext
...
Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name ...
Caused by: java.lang.IllegalArgumentException: Pointcut is not well-formed: expecting 'identifier' at character position 0
^
at org.aspectj.weaver.tools.PointcutParser.resolvePoi ntcutExpression(PointcutParser.java:316)
Spring wiring configuration:
Code:
@Configuration
@EnableAspectJAutoProxy
public class LoggingAspectTestConfig {
//...
@Bean
public LoggingAspect loggingAspect() {
return new LoggingAspect();
}
@Bean
public Module1LoggingPointcuts module1LoggingPointcuts() {
return new Module1LoggingPointcuts();
}
}