Package org.apache.tapestry5.ioc.internal

## 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 the `ObjectCreator` 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
    --- | --- | ---
    `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 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.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SingletonServiceLifecycle

          public SingletonServiceLifecycle()

  - ### Method Detail

    - #### 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

    - #### 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, the `ScopeConstants.PERTHREAD` scope}. A future version of Tapestry IoC may optimize for the later case.
      Specified by:
        `isSingleton` in interface `ServiceLifecycle`
      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 a `ServiceLifecycle` as a `ServiceLifecycle2` is to return true.
      Specified by:
        `requiresProxy` in interface `ServiceLifecycle2`
      Returns:
        true if proxying is necessary, false otherwise