Following aspect would achieve the same
@Component
@Aspect
public class DummyAspect {
@Before(value = "@target(dummy) && within(com.your.package..*)")
public void before(JoinPoint jp, Dummy dummy) {
System.out.println(dummy.value());
}
}
within()
- is a scoping designator to narrow the scope of classes to be advised. Without this designator the run could have undesired outcome as it could target framework classes as well.
Do go through this answer from @kriegaex to understand the designator in detail.
References : https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#aop-pointcuts-designators