KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > beans > factory > support > RootBeanDefinition


1 /*
2  * Copyright 2002-2007 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.springframework.beans.factory.support;
18
19 import org.springframework.beans.MutablePropertyValues;
20 import org.springframework.beans.factory.config.ConstructorArgumentValues;
21
22 /**
23  * Root bean definitions are the most common type of bean definition.
24  * They do not derive from a parent bean definition, and usually have a
25  * class plus optionally constructor argument values and property values.
26  *
27  * <p>Note that root bean definitions do not have to specify a bean class:
28  * This can be useful for deriving childs from such definitions, each with
29  * its own bean class but inheriting common property values and other settings.
30  *
31  * @author Rod Johnson
32  * @author Juergen Hoeller
33  * @see ChildBeanDefinition
34  */

35 public class RootBeanDefinition extends AbstractBeanDefinition {
36
37     /**
38      * Create a new RootBeanDefinition, to be configured through its bean
39      * properties and configuration methods.
40      * @see #setBeanClass
41      * @see #setBeanClassName
42      * @see #setSingleton
43      * @see #setAutowireMode
44      * @see #setDependencyCheck
45      * @see #setConstructorArgumentValues
46      * @see #setPropertyValues
47      */

48     public RootBeanDefinition() {
49         super();
50     }
51
52     /**
53      * Create a new RootBeanDefinition for a singleton.
54      * @param beanClass the class of the bean to instantiate
55      */

56     public RootBeanDefinition(Class JavaDoc beanClass) {
57         super();
58         setBeanClass(beanClass);
59     }
60
61     /**
62      * Create a new RootBeanDefinition with the given singleton status.
63      * @param beanClass the class of the bean to instantiate
64      * @param singleton the singleton status of the bean
65      */

66     public RootBeanDefinition(Class JavaDoc beanClass, boolean singleton) {
67         super();
68         setBeanClass(beanClass);
69         setSingleton(singleton);
70     }
71
72     /**
73      * Create a new RootBeanDefinition for a singleton,
74      * using the given autowire mode.
75      * @param beanClass the class of the bean to instantiate
76      * @param autowireMode by name or type, using the constants in this interface
77      */

78     public RootBeanDefinition(Class JavaDoc beanClass, int autowireMode) {
79         super();
80         setBeanClass(beanClass);
81         setAutowireMode(autowireMode);
82     }
83
84     /**
85      * Create a new RootBeanDefinition for a singleton,
86      * using the given autowire mode.
87      * @param beanClass the class of the bean to instantiate
88      * @param autowireMode by name or type, using the constants in this interface
89      * @param dependencyCheck whether to perform a dependency check for objects
90      * (not applicable to autowiring a constructor, thus ignored there)
91      */

92     public RootBeanDefinition(Class JavaDoc beanClass, int autowireMode, boolean dependencyCheck) {
93         super();
94         setBeanClass(beanClass);
95         setAutowireMode(autowireMode);
96         if (dependencyCheck && getResolvedAutowireMode() != AUTOWIRE_CONSTRUCTOR) {
97             setDependencyCheck(RootBeanDefinition.DEPENDENCY_CHECK_OBJECTS);
98         }
99     }
100
101     /**
102      * Create a new RootBeanDefinition for a singleton,
103      * providing property values.
104      * @param beanClass the class of the bean to instantiate
105      * @param pvs the property values to apply
106      */

107     public RootBeanDefinition(Class JavaDoc beanClass, MutablePropertyValues pvs) {
108         super(null, pvs);
109         setBeanClass(beanClass);
110     }
111
112     /**
113      * Create a new RootBeanDefinition with the given singleton status,
114      * providing property values.
115      * @param beanClass the class of the bean to instantiate
116      * @param pvs the property values to apply
117      * @param singleton the singleton status of the bean
118      */

119     public RootBeanDefinition(Class JavaDoc beanClass, MutablePropertyValues pvs, boolean singleton) {
120         super(null, pvs);
121         setBeanClass(beanClass);
122         setSingleton(singleton);
123     }
124
125     /**
126      * Create a new RootBeanDefinition for a singleton,
127      * providing constructor arguments and property values.
128      * @param beanClass the class of the bean to instantiate
129      * @param cargs the constructor argument values to apply
130      * @param pvs the property values to apply
131      */

132     public RootBeanDefinition(Class JavaDoc beanClass, ConstructorArgumentValues cargs, MutablePropertyValues pvs) {
133         super(cargs, pvs);
134         setBeanClass(beanClass);
135     }
136
137     /**
138      * Create a new RootBeanDefinition for a singleton,
139      * providing constructor arguments and property values.
140      * <p>Takes a bean class name to avoid eager loading of the bean class.
141      * @param beanClassName the name of the class to instantiate
142      * @param cargs the constructor argument values to apply
143      * @param pvs the property values to apply
144      */

145     public RootBeanDefinition(String JavaDoc beanClassName, ConstructorArgumentValues cargs, MutablePropertyValues pvs) {
146         super(cargs, pvs);
147         setBeanClassName(beanClassName);
148     }
149
150     /**
151      * Create a new RootBeanDefinition as deep copy of the given
152      * bean definition.
153      * @param original the original bean definition to copy from
154      */

155     public RootBeanDefinition(RootBeanDefinition original) {
156         super(original);
157     }
158
159
160     public boolean equals(Object JavaDoc other) {
161         return (this == other || (other instanceof RootBeanDefinition && super.equals(other)));
162     }
163
164     public String JavaDoc toString() {
165         return "Root bean: " + super.toString();
166     }
167
168 }
169
Popular Tags