001// Licensed under the Apache License, Version 2.0 (the "License");
002// you may not use this file except in compliance with the License.
003// You may obtain a copy of the License at
005//     http://www.apache.org/licenses/LICENSE-2.0
007// Unless required by applicable law or agreed to in writing, software
008// distributed under the License is distributed on an "AS IS" BASIS,
009// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
010// See the License for the specific language governing permissions and
011// limitations under the License.
013package org.apache.tapestry5.annotations;
015import org.apache.tapestry5.ioc.annotations.UseWith;
017import java.lang.annotation.Documented;
018import java.lang.annotation.Retention;
019import java.lang.annotation.Target;
021import static java.lang.annotation.ElementType.FIELD;
022import static java.lang.annotation.RetentionPolicy.RUNTIME;
023import static org.apache.tapestry5.ioc.annotations.AnnotationUseContext.*;
026 * Marker annotation for a field that is a <em>session state object</em> (SSO) as controlled by the {@link
027 * org.apache.tapestry5.services.ApplicationStateManager}. An SSO stored as global session object (i.e., in the {@link
028 * javax.servlet.ServletContext}); every page or component. In fact, the built-in strategies for ASO management are
029 * <em>very</em> user specific, ultimately storing data in the {@link org.apache.tapestry5.services.Session}.
030 *
031 * An SSO field may have a companion field, of type boolean, used to see if the SSO has been created yet. If another
032 * field exists with the same name, suffixed with "Exists" (i.e., "sso" for the SSO field, and "ssoExists" for the
033 * companion field) and the type of that field is boolean, then access to the field will determine whether the SSO has
034 * already been created. This is necessary because even a null check ("sso != null") may force the SSO to be created.
035 * Instead, check the companion boolean field ("asoExists").
036 *
037 * Note: Tapestry 5.0 called these objects "Application State Objects"; thus many of the underlying services have a
038 * confusing name (ApplicationStateManager, which really should be SessionStateManager ... but can't be renamed for
039 * backwards compatibility reasons).
040 *
041 * @since
042 */
047public @interface SessionState
049    /**
050     * If true (the default), then referencing an field marked with the annotation will create the SSO.  If false, then
051     * accessing the field will not create the SSO, it will only allow access to it if it already exists.
052     */
053    boolean create() default true;