Coverage Report - org.apache.tapestry5.services.ApplicationStateManager
 
Classes in this File Line Coverage Branch Coverage Complexity
ApplicationStateManager
N/A
N/A
0
 
 1  
 // Copyright 2007, 2008 The Apache Software Foundation
 2  
 //
 3  
 // Licensed under the Apache License, Version 2.0 (the "License");
 4  
 // you may not use this file except in compliance with the License.
 5  
 // You may obtain a copy of the License at
 6  
 //
 7  
 //     http://www.apache.org/licenses/LICENSE-2.0
 8  
 //
 9  
 // Unless required by applicable law or agreed to in writing, software
 10  
 // distributed under the License is distributed on an "AS IS" BASIS,
 11  
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12  
 // See the License for the specific language governing permissions and
 13  
 // limitations under the License.
 14  
 
 15  
 package org.apache.tapestry5.services;
 16  
 
 17  
 import org.apache.tapestry5.ioc.annotations.UsesMappedConfiguration;
 18  
 
 19  
 /**
 20  
  * Responsible for managing <em>session state objects</em>, objects which persist between requests, but are not tied to
 21  
  * any individual page or component. SSOs are also created on demand. SSOs are typically stored in the session, so that
 22  
  * they are specific to a particular client.
 23  
  * <p/>
 24  
  * The term "Application" is a hold-over from Tapestry 5.0, which used the {@link ApplicationState} annotation, and
 25  
  * called them "ASOs" (Application State Objects).
 26  
  * <p/>
 27  
  * Tapestry has a built-in default strategy for storing SSOs (in the session) and instantiating them. If desired,
 28  
  * contributions to the service configuration can override the default behavior, either specifying an alternate storage
 29  
  * strategy, or an alternate {@linkplain org.apache.tapestry5.services.ApplicationStateCreator creation strategy}.
 30  
  *
 31  
  * @see org.apache.tapestry5.annotations.ApplicationState
 32  
  */
 33  
 @UsesMappedConfiguration(key = Class.class, value = ApplicationStateContribution.class)
 34  
 public interface ApplicationStateManager
 35  
 {
 36  
     /**
 37  
      * For a given class, find the SSO for the class, creating it if necessary. The manager has a configuration that
 38  
      * determines how an instance is stored and created as needed. A requested SSO not in the configuration is assumed
 39  
      * to be created via a no-args constructor, and stored in the session.
 40  
      *
 41  
      * @param <T>
 42  
      * @param ssoClass identifies the SSO to access or create
 43  
      * @return the SSO instance
 44  
      */
 45  
     <T> T get(Class<T> ssoClass);
 46  
 
 47  
     /**
 48  
      * For a given class, find the SSO for the class. The manager has a configuration that determines how an instance is
 49  
      * stored.
 50  
      *
 51  
      * @param <T>
 52  
      * @param ssoClass identifies the SSO to access or create
 53  
      * @return the SSO instance or null if it does not already exist
 54  
      */
 55  
     <T> T getIfExists(Class<T> ssoClass);
 56  
 
 57  
     /**
 58  
      * Returns true if the SSO already exists, false if it has not yet been created.
 59  
      *
 60  
      * @param ssoClass used to select the SSO
 61  
      * @return true if SSO exists, false if null
 62  
      */
 63  
     <T> boolean exists(Class<T> ssoClass);
 64  
 
 65  
     /**
 66  
      * Stores a new SSO, replacing the existing SSO (if any). Storing the value null will delete the SSO so that it may
 67  
      * be re-created later.
 68  
      *
 69  
      * @param <T>
 70  
      * @param ssoClass the type of SSO
 71  
      * @param SSO      the SSO instance
 72  
      */
 73  
     <T> void set(Class<T> ssoClass, T SSO);
 74  
 }