Let's see some recipes on how to use AOP with the domain object to solve the concurrency of aspects and the mixin of configurations.
Spring instantiates and configures beans contained in application context configuration files. If you use Domain-Driven Design, you can ask a bean factory to configure your domain object.
The spring-aspects.jar
contains an annotation-driven aspect that exploits this capability to allow dependency injection of any object with @Configurable
annotation, and with AnnotationBeanConfigurerAspect
behind the scenes. In this way, you can apply dependency injection with objects created outside the control of any IoC container using the new operator.
An example of a domain class:
package org.springaop.chapter.four.configurable; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Configurable; @Configurable() public class User { public String getName(){ return name...