Class SingletonServiceLifecycle
- java.lang.Object
-
- org.apache.tapestry5.ioc.internal.SingletonServiceLifecycle
-
- All Implemented Interfaces:
ServiceLifecycle,ServiceLifecycle2
public class SingletonServiceLifecycle extends java.lang.Object implements ServiceLifecycle2
The basic implementation of a service lifecycle, which simply uses theObjectCreatorto create an instance of the service when asked.
-
-
Constructor Summary
Constructors Constructor Description SingletonServiceLifecycle()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ObjectcreateService(ServiceResources resources, ObjectCreator creator)Returns the same creator, or a new one, that encapsulates the creation of the core service implementation.booleanisSingleton()Returns true if the lifecycle is a singleton (a service that will only be created once).booleanrequiresProxy()If true, then lifecycle requires a proxy, meaning it is only usable with services that properly define a service interface.
-
-
-
Constructor Detail
-
SingletonServiceLifecycle
public SingletonServiceLifecycle()
-
-
Method Detail
-
createService
public java.lang.Object createService(ServiceResources resources, ObjectCreator creator)
Description copied from interface:ServiceLifecycleReturns the same creator, or a new one, that encapsulates the creation of the core service implementation.- Specified by:
createServicein 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
-
isSingleton
public boolean isSingleton()
Description copied from interface:ServiceLifecycleReturns true if the lifecycle is a singleton (a service that will only be created once). Return false if the underlying service instance may be created multiple times (for example, theScopeConstants.PERTHREADscope}. A future version of Tapestry IoC may optimize for the later case.- Specified by:
isSingletonin interfaceServiceLifecycle- Returns:
- true for singletons, false for services that can be repeatedly constructed
-
requiresProxy
public boolean requiresProxy()
Description copied from interface:ServiceLifecycle2If true, then lifecycle requires a proxy, meaning it is only usable with services that properly define a service interface. The default (singleton) scope does not require a proxy, but most other service scopes do. The default (when wrapping aServiceLifecycleas aServiceLifecycle2is to return true.- Specified by:
requiresProxyin interfaceServiceLifecycle2- Returns:
- true if proxying is necessary, false otherwise
-
-