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 /** 036 * A List of {@link IBeanInitializer}. 037 */ 038 039 protected List _initializers; 040 041 /** @since 1.0.9 * */ 042 private String _description; 043 044 /** @since 4.0 */ 045 046 private String _propertyName; 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 }