Class PerThreadServiceLifecycle

  • All Implemented Interfaces:
    ServiceLifecycle

    public class PerThreadServiceLifecycle
    extends java.lang.Object
    implements ServiceLifecycle
    Allows a service to exist "per thread" (in each thread). Creates a proxy that delegates to a per-thread instance. This scheme ensures that, although the service builder method will be invoked many times over the life of the application, the service decoration process occurs only once. The final calling chain is: Service Proxy --> Interceptor(s) (from Decorators) --> Advise Proxy (from Advisiors) --> PerThread Proxy --> (per thread) instance.
    • Method Detail

      • isSingleton

        public boolean isSingleton()
        Returns false; this lifecycle represents a service that will be created many times (by each thread).
        Specified by:
        isSingleton in interface ServiceLifecycle
        Returns:
        true for singletons, false for services that can be repeatedly constructed
      • createService

        public java.lang.Object createService​(ServiceResources resources,
                                              ObjectCreator creator)
        Description copied from interface: ServiceLifecycle
        Returns the same creator, or a new one, that encapsulates the creation of the core service implementation.
        Specified by:
        createService in interface ServiceLifecycle
        Parameters:
        resources - source of information about the service to be created, and source of additional services or other resources that may be needed when constructing the core service implementation
        creator - object capable of creating the service implementation on demand. This is a wrapper around the service's builder method.
        Returns:
        the service or equivalent service proxy