org.apache.tapestry5.ioc.internal.services
Class PerThreadServiceLifecycle
java.lang.Object
org.apache.tapestry5.ioc.internal.services.PerThreadServiceLifecycle
- All Implemented Interfaces:
- ServiceLifecycle
public class PerThreadServiceLifecycle
- extends java.lang.Object
- implements ServiceLifecycle
Allows a service to exist "per thread" (in each thread). This involves an inner proxy, which caches an object derived
from a ObjectCreator as a key in the PerthreadManager.
Method invocations are delegated to the per-thread service 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 -->
Decorator(s) --> PerThread Proxy --> (per thread) instance.
|
Method Summary |
java.lang.Object |
createService(ServiceResources resources,
ObjectCreator creator)
Returns the same creator, or a new one, that encapsulates the creation of the core service implementation. |
boolean |
isSingleton()
Returns false; this lifecycle represents a service that will be created many times (by each thread). |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PerThreadServiceLifecycle
public PerThreadServiceLifecycle(@Builtin
PerthreadManager perthreadManager,
@Builtin
ClassFactory classFactory)
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 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
Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.