Class SingletonServiceLifecycle
- java.lang.Object
-
- org.apache.tapestry5.ioc.internal.SingletonServiceLifecycle
-
- All Implemented Interfaces:
ServiceLifecycle
,ServiceLifecycle2
public class SingletonServiceLifecycle extends Object implements ServiceLifecycle2
The basic implementation of a service lifecycle, which simply uses theObjectCreator
to 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 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 true if the lifecycle is a singleton (a service that will only be created once).boolean
requiresProxy()
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 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 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:ServiceLifecycle
Returns 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.PERTHREAD
scope}. A future version of Tapestry IoC may optimize for the later case.- Specified by:
isSingleton
in interfaceServiceLifecycle
- Returns:
- true for singletons, false for services that can be repeatedly constructed
-
requiresProxy
public boolean requiresProxy()
Description copied from interface:ServiceLifecycle2
If 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 aServiceLifecycle
as aServiceLifecycle2
is to return true.- Specified by:
requiresProxy
in interfaceServiceLifecycle2
- Returns:
- true if proxying is necessary, false otherwise
-
-