001 // Copyright 2004, 2005 The Apache Software Foundation 002 // 003 // Licensed under the Apache License, Version 2.0 (the "License"); 004 // you may not use this file except in compliance with the License. 005 // You may obtain a copy of the License at 006 // 007 // http://www.apache.org/licenses/LICENSE-2.0 008 // 009 // Unless required by applicable law or agreed to in writing, software 010 // distributed under the License is distributed on an "AS IS" BASIS, 011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 012 // See the License for the specific language governing permissions and 013 // limitations under the License. 014 015 package org.apache.tapestry.spec; 016 017 /** 018 * An enumeration of the different possible lifecycles for a JavaBean. 019 * 020 * @author Howard Lewis Ship 021 * @since 1.0.4 022 */ 023 024 public final class BeanLifecycle 025 { 026 /** 027 * No lifecycle; the bean is created fresh on each reference and not retained. 028 */ 029 030 public static final BeanLifecycle NONE = new BeanLifecycle("NONE"); 031 032 /** 033 * The standard lifecycle; the bean is retained for the duration of the request cycle and is 034 * discarded at the end of the request cycle. 035 */ 036 037 public static final BeanLifecycle REQUEST = new BeanLifecycle("REQUEST"); 038 039 /** 040 * The bean is created once and reused for the lifespan of the page containing the component. 041 */ 042 043 public static final BeanLifecycle PAGE = new BeanLifecycle("PAGE"); 044 045 /** 046 * The bean is create and reused until the end of the current render, at which point it is 047 * discarded. 048 * 049 * @since 2.2 050 */ 051 052 public static final BeanLifecycle RENDER = new BeanLifecycle("RENDER"); 053 054 private final String _name; 055 056 private BeanLifecycle(String name) 057 { 058 _name = name; 059 } 060 061 public String toString() 062 { 063 return "BeanLifecycle[" + _name + "]"; 064 } 065 066 public String getName() 067 { 068 return _name; 069 } 070 071 }