001: /*
002: * Copyright 2002-2007 the original author or authors.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.springframework.beans.factory.config;
018:
019: import org.springframework.beans.BeanMetadataElement;
020: import org.springframework.beans.MutablePropertyValues;
021: import org.springframework.core.AttributeAccessor;
022:
023: /**
024: * A BeanDefinition describes a bean instance, which has property values,
025: * constructor argument values, and further information supplied by
026: * concrete implementations.
027: *
028: * <p>This is just a minimal interface: The main intention is to allow a
029: * {@link BeanFactoryPostProcessor} such as {@link PropertyPlaceholderConfigurer}
030: * to introspect and modify property values and other bean metadata.
031: *
032: * @author Juergen Hoeller
033: * @author Rob Harrop
034: * @since 19.03.2004
035: * @see ConfigurableListableBeanFactory#getBeanDefinition
036: * @see org.springframework.beans.factory.support.RootBeanDefinition
037: * @see org.springframework.beans.factory.support.ChildBeanDefinition
038: */
039: public interface BeanDefinition extends AttributeAccessor,
040: BeanMetadataElement {
041:
042: /**
043: * Scope identifier for the standard singleton scope: "singleton".
044: * <p>Note that extended bean factories might support further scopes.
045: * @see #setScope
046: */
047: String SCOPE_SINGLETON = ConfigurableBeanFactory.SCOPE_SINGLETON;
048:
049: /**
050: * Scope identifier for the standard prototype scope: "prototype".
051: * <p>Note that extended bean factories might support further scopes.
052: * @see #setScope
053: */
054: String SCOPE_PROTOTYPE = ConfigurableBeanFactory.SCOPE_PROTOTYPE;
055:
056: /**
057: * Role hint indicating that a <code>BeanDefinition</code> is a major part
058: * of the application. Typically corresponds to a user-defined bean.
059: */
060: int ROLE_APPLICATION = 0;
061:
062: /**
063: * Role hint indicating that a <code>BeanDefinition</code> is a supporting
064: * part of some larger configuration, typically an outer
065: * {@link org.springframework.beans.factory.parsing.ComponentDefinition}.
066: * <code>SUPPORT</code> beans are considered important enough to be aware
067: * of when looking more closely at a particular
068: * {@link org.springframework.beans.factory.parsing.ComponentDefinition},
069: * but not when looking at the overall configuration of an application.
070: */
071: int ROLE_SUPPORT = 1;
072:
073: /**
074: * Role hint indicating that a <code>BeanDefinition</code> is providing an
075: * entirely background role and has no relevance to the end-user. This hint is
076: * used when registering beans that are completely part of the internal workings
077: * of a {@link org.springframework.beans.factory.parsing.ComponentDefinition}.
078: */
079: int ROLE_INFRASTRUCTURE = 2;
080:
081: /**
082: * Return the name of the parent definition of this bean definition, if any.
083: */
084: String getParentName();
085:
086: /**
087: * Set the name of the parent definition of this bean definition, if any.
088: */
089: void setParentName(String parentName);
090:
091: /**
092: * Return the current bean class name of this bean definition.
093: * <p>Note that this does not have to be the actual class name used at runtime, in
094: * case of a child definition overriding/inheriting the class name from its parent.
095: * Hence, do <i>not</i> consider this to be the definitive bean type at runtime but
096: * rather only use it for parsing purposes at the individual bean definition level.
097: */
098: String getBeanClassName();
099:
100: /**
101: * Override the bean class name of this bean definition.
102: * <p>The class name can be modified during bean factory post-processing,
103: * typically replacing the original class name with a parsed variant of it.
104: */
105: void setBeanClassName(String beanClassName);
106:
107: /**
108: * Return the factory bean name, if any.
109: */
110: String getFactoryBeanName();
111:
112: /**
113: * Specify the factory bean to use, if any.
114: */
115: void setFactoryBeanName(String factoryBeanName);
116:
117: /**
118: * Return a factory method, if any.
119: */
120: String getFactoryMethodName();
121:
122: /**
123: * Specify a factory method, if any. This method will be invoked with
124: * constructor arguments, or with no arguments if none are specified.
125: * The method will be invoked on the specifed factory bean, if any,
126: * or as static method on the local bean class else.
127: * @param factoryMethodName static factory method name,
128: * or <code>null</code> if normal constructor creation should be used
129: * @see #getBeanClassName()
130: */
131: void setFactoryMethodName(String factoryMethodName);
132:
133: /**
134: * Return the name of the current target scope for this bean.
135: */
136: String getScope();
137:
138: /**
139: * Override the target scope of this bean, specifying a new scope name.
140: * @see #SCOPE_SINGLETON
141: * @see #SCOPE_PROTOTYPE
142: */
143: void setScope(String scope);
144:
145: /**
146: * Return whether this bean is a candidate for getting autowired into some other bean.
147: */
148: boolean isAutowireCandidate();
149:
150: /**
151: * Set whether this bean is a candidate for getting autowired into some other bean.
152: */
153: void setAutowireCandidate(boolean autowireCandidate);
154:
155: /**
156: * Return the constructor argument values for this bean.
157: * <p>The returned instance can be modified during bean factory post-processing.
158: * @return the ConstructorArgumentValues object (never <code>null</code>)
159: */
160: ConstructorArgumentValues getConstructorArgumentValues();
161:
162: /**
163: * Return the property values to be applied to a new instance of the bean.
164: * <p>The returned instance can be modified during bean factory post-processing.
165: * @return the MutablePropertyValues object (never <code>null</code>)
166: */
167: MutablePropertyValues getPropertyValues();
168:
169: /**
170: * Return whether this a <b>Singleton</b>, with a single, shared instance
171: * returned on all calls.
172: */
173: boolean isSingleton();
174:
175: /**
176: * Return whether this bean is "abstract", that is, not meant to be instantiated.
177: */
178: boolean isAbstract();
179:
180: /**
181: * Return whether this bean should be lazily initialized, that is, not
182: * eagerly instantiated on startup.
183: */
184: boolean isLazyInit();
185:
186: /**
187: * Return a description of the resource that this bean definition
188: * came from (for the purpose of showing context in case of errors).
189: */
190: String getResourceDescription();
191:
192: /**
193: * Get the role hint for this <code>BeanDefinition</code>. The role hint
194: * provides tools with an indication of the importance of a particular
195: * <code>BeanDefinition</code>.
196: * @see #ROLE_APPLICATION
197: * @see #ROLE_INFRASTRUCTURE
198: * @see #ROLE_SUPPORT
199: */
200: int getRole();
201:
202: }
|