Class PerThreadServiceLifecycle
java.lang.Object
org.apache.tapestry5.ioc.internal.services.PerThreadServiceLifecycle
- All Implemented Interfaces:
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.
-
Constructor Summary
ConstructorsConstructorDescriptionPerThreadServiceLifecycle
(PerthreadManager perthreadManager, PlasticProxyFactory proxyFactory) -
Method Summary
Modifier and TypeMethodDescriptioncreateService
(ServiceResources resources, ObjectCreator creator) Returns the same creator, or a new one, that encapsulates the creation of the core service implementation.boolean
Returns false; this lifecycle represents a service that will be created many times (by each thread).
-
Constructor Details
-
PerThreadServiceLifecycle
public PerThreadServiceLifecycle(@Builtin PerthreadManager perthreadManager, @Builtin PlasticProxyFactory proxyFactory)
-
-
Method Details
-
isSingleton
Returns false; this lifecycle represents a service that will be created many times (by each thread).- Specified by:
isSingleton
in interfaceServiceLifecycle
- Returns:
- true for singletons, false for services that can be repeatedly constructed
-
createService
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 interfaceServiceLifecycle
- 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 implementationcreator
- 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
-