I'm using CTW AspectJ and I'm trying to @inject a field into my Aspect. The injected field always returns null.
I'm using Java based configuration:
@Configuration
@EnableAspectJAutoProxy(proxyTargetClass=true)
public class ServicesConfig..
The Spring itself is loaded using org.springframework.web.context.support.AnnotationConfigWebApplicationContext
From what I gather the my Aspect isn't instancing using the Spring framework but via the aspectj. what is missing to make the Aspect load with Spring?
This is how My aspect looks like:
@Aspect
public class MyAspect {
@Inject
private SomeBean someBean;
@Around("execution(* com.mypackages..*(..))")
public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable {
Object result = null;
//some Aspect logic
return result;
}
}
This is how the bean is instantiated, If I try to @inject it anywhere else in the application I'm getting the bean.
@Named
@Scope(value = "prototype")
public class SomeBean{
//bean logic
}