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}, but
069: * 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
075: * an entirely background role and has no relevance to the end-user. This
076: * hint is used when registering beans that are completely part of the internal
077: * workings of a {@link org.springframework.beans.factory.parsing.ComponentDefinition}.
078: */
079: int ROLE_INFRASTRUCTURE = 2;
080:
081: /**
082: * Return the current bean class name of this bean definition.
083: * <p>Note that this does not have to be the actual class name used at runtime,
084: * in case of a child definition overriding/inheriting the class name from its parent.
085: * Hence, do <i>not</i> consider this to be the definitive bean type at runtime but
086: * rather only use it for parsing purposes at the individual bean definition level.
087: */
088: String getBeanClassName();
089:
090: /**
091: * Override the bean class name of this bean definition.
092: * <p>The class name can be modified during bean factory post-processing,
093: * typically replacing the original class name with a parsed variant of it.
094: */
095: void setBeanClassName(String beanClassName);
096:
097: /**
098: * Return the constructor argument values for this bean.
099: * <p>The returned instance can be modified during bean factory post-processing.
100: * @return the ConstructorArgumentValues object (never <code>null</code>)
101: */
102: ConstructorArgumentValues getConstructorArgumentValues();
103:
104: /**
105: * Return the property values to be applied to a new instance of the bean.
106: * <p>The returned instance can be modified during bean factory post-processing.
107: * @return the MutablePropertyValues object (never <code>null</code>)
108: */
109: MutablePropertyValues getPropertyValues();
110:
111: /**
112: * Return the name of the current target scope for this bean.
113: */
114: String getScope();
115:
116: /**
117: * Override the target scope of this bean, specifying a new scope name.
118: * @see #SCOPE_SINGLETON
119: * @see #SCOPE_PROTOTYPE
120: */
121: void setScope(String scope);
122:
123: /**
124: * Return whether this a <b>Singleton</b>, with a single, shared instance
125: * returned on all calls.
126: */
127: boolean isSingleton();
128:
129: /**
130: * Return whether this bean is "abstract", that is, not meant to be instantiated.
131: */
132: boolean isAbstract();
133:
134: /**
135: * Return whether this bean should be lazily initialized, that is, not
136: * eagerly instantiated on startup.
137: */
138: boolean isLazyInit();
139:
140: /**
141: * Return a description of the resource that this bean definition
142: * came from (for the purpose of showing context in case of errors).
143: */
144: String getResourceDescription();
145:
146: /**
147: * Get the role hint for this <code>BeanDefinition</code>. The role hint
148: * provides tools with an indication of the importance of a particular
149: * <code>BeanDefinition</code>.
150: * @see #ROLE_APPLICATION
151: * @see #ROLE_INFRASTRUCTURE
152: * @see #ROLE_SUPPORT
153: */
154: int getRole();
155:
156: }
|