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 import java.util.ArrayList;
018 import java.util.List;
019
020 import org.apache.tapestry.bean.IBeanInitializer;
021
022 /**
023 * A specification of a helper bean for a component.
024 *
025 * @author Howard Lewis Ship
026 * @since 1.0.4
027 */
028
029 public class BeanSpecification extends LocatablePropertyHolder implements IBeanSpecification
030 {
031 protected String className;
032
033 protected BeanLifecycle lifecycle;
034
035 /** @since 1.0.9 * */
036 private String description;
037
038 /** @since 4.0 */
039
040 private String _propertyName;
041
042 /**
043 * A List of {@link IBeanInitializer}.
044 */
045
046 protected List initializers;
047
048 public String getClassName()
049 {
050 return className;
051 }
052
053 public BeanLifecycle getLifecycle()
054 {
055 return lifecycle;
056 }
057
058 /**
059 * @since 1.0.5
060 */
061
062 public void addInitializer(IBeanInitializer initializer)
063 {
064 if (initializers == null)
065 initializers = new ArrayList();
066
067 initializers.add(initializer);
068 }
069
070 /**
071 * Returns the {@link List}of {@link IBeanInitializer}s. The caller should not modify this
072 * value!. May return null if there are no initializers.
073 *
074 * @since 1.0.5
075 */
076
077 public List getInitializers()
078 {
079 return initializers;
080 }
081
082 public String toString()
083 {
084 StringBuffer buffer = new StringBuffer("BeanSpecification[");
085
086 buffer.append(className);
087 buffer.append(", lifecycle ");
088 buffer.append(lifecycle.getName());
089
090 if (initializers != null && initializers.size() > 0)
091 {
092 buffer.append(", ");
093 buffer.append(initializers.size());
094 buffer.append(" initializers");
095 }
096
097 buffer.append(']');
098
099 return buffer.toString();
100 }
101
102 public String getDescription()
103 {
104 return description;
105 }
106
107 public void setDescription(String desc)
108 {
109 description = desc;
110 }
111
112 /** @since 3.0 * */
113
114 public void setClassName(String className)
115 {
116 this.className = className;
117 }
118
119 /** @since 3.0 * */
120
121 public void setLifecycle(BeanLifecycle lifecycle)
122 {
123 this.lifecycle = lifecycle;
124 }
125
126 /** @since 4.0 */
127 public String getPropertyName()
128 {
129 return _propertyName;
130 }
131
132 /** @since 4.0 */
133 public void setPropertyName(String propertyName)
134 {
135 _propertyName = propertyName;
136 }
137 }