ServiceInjector (interface)

Resolves injection points using the org.apache.isis.applib.services.registry.ServiceRegistry (in other words provides a domain service instance to all fields and setters that are annotated with javax.inject.Inject ).

API

ServiceInjector.java
interface ServiceInjector {
  T injectServicesInto(final T domainObject)     (1)
}
1 injectServicesInto(T)

Injects domain services into the object.

Members

injectServicesInto(T)

Injects domain services into the object.

Implementation

The framework provides a default implementation of o.a.i.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);