Package org.apache.tapestry5.services

## Interface ApplicationStateManager

- All Known Implementing Classes:
    `ApplicationStateManagerImpl`

      @UsesMappedConfiguration(key=java.lang.Class.class,
                               value=ApplicationStateContribution.class)
      public interface ApplicationStateManager

  Responsible for managing Session State Objects (SSO), objects which persist between requests but are not tied to any individual page or component. SSOs are typically stored in the session, so that they are specific to a particular user.

  SSOs are created on demand.

  Tapestry has a built-in default strategy for storing SSOs (in the session) and instantiating them. If desired, contributions to the service configuration can override the default behavior, either specifying an alternate storage strategy, or an alternate creation strategy.

  NOTE: The term "Application" here is a hold-over from Tapestry 5.0, which used the @ApplicationState (deprecated and deleted) annotation, and called them "ASOs" (Application State Objects). This service would be better named "SessionStateManager" (but renaming it would cause backwards compatibility issues).

  See Also:
    `SessionState`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `<T> boolean` | `exists​(java.lang.Class<T> ssoClass)` | Returns true if the SSO already exists, false if it has not yet been created.
    `<T> T` | `get​(java.lang.Class<T> ssoClass)` | For a given class, find the SSO for the class, creating it if necessary.
    `<T> T` | `getIfExists​(java.lang.Class<T> ssoClass)` | For a given class, find the SSO for the class.
    `<T> void` | `set​(java.lang.Class<T> ssoClass, T SSO)` | Stores a new SSO, replacing the existing SSO (if any).

- - ### Method Detail

    - #### get

          <T> T get​(java.lang.Class<T> ssoClass)

      For a given class, find the SSO for the class, creating it if necessary. The manager has a configuration that determines how an instance is stored and created as needed. The default (when there is no configuration for a SSO type) is to instantiate the object with injected dependencies, via `ObjectLocator.autobuild(Class)`. This allows an SSO to keep references to Tapestry IoC services or other objects that can be injected.
      Parameters:
        `ssoClass` - identifies the SSO to access or create
      Returns:
        the SSO instance

    - #### getIfExists

          <T> T getIfExists​(java.lang.Class<T> ssoClass)

      For a given class, find the SSO for the class. The manager has a configuration that determines how an instance is stored.
      Parameters:
        `ssoClass` - identifies the SSO to access or create
      Returns:
        the SSO instance or null if it does not already exist

    - #### exists

          <T> boolean exists​(java.lang.Class<T> ssoClass)

      Returns true if the SSO already exists, false if it has not yet been created.
      Parameters:
        `ssoClass` - used to select the SSO
      Returns:
        true if SSO exists, false if null

    - #### set

          <T> void set​(java.lang.Class<T> ssoClass,
                       T SSO)

      Stores a new SSO, replacing the existing SSO (if any). Storing the value null will delete the SSO so that it may be re-created later.
      Parameters:
        `ssoClass` - the type of SSO
        `SSO` - the SSO instance