ServiceInjector
Resolves injection points using the org.apache.causeway.applib.services.registry.ServiceRegistry (in other words provides a domain service instance to all fields and setters that are annotated with jakarta.inject.Inject ).
API
ServiceInjector.java
interface ServiceInjector {
T injectServicesInto(T domainObject) (1)
}
1 | injectServicesInto(T)
Injects domain services into the object. |
Implementation
The framework provides a default implementation of o.a.c.core.metamodel.services.ServiceInjectorDefault
.
Under the covers this delegates to Spring Framework’s injection mechanism.
Usage
The primary use case is to instantiate domain objects using a regular constructor, and then using the service to set up any dependencies.
For example:
Customer cust = serviceInjector.injectServicesInto(
new Customer("Freddie", "Mercury"));
repositoryService.persist(cust);