01: /*
02: * Copyright 2002-2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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.factory.config.BeanDefinition;
20:
21: /**
22: * GenericBeanDefinition is a one-stop shop for standard bean definition purposes.
23: * Like any bean definition, it allows for specifying a class plus optionally
24: * constructor argument values and property values. Additionally, deriving from a
25: * parent bean definition can be flexibly configured through the "parentName" property.
26: *
27: * <p>In general, use this <code>GenericBeanDefinition</code> class for the purpose of
28: * registering user-visible bean definitions (which a post-processor might operate on,
29: * potentially even reconfiguring the parent name). Use <code>RootBeanDefinition</code> /
30: * <code>ChildBeanDefinition</code> where parent/child relationships happen to be pre-determined.
31: *
32: * @author Juergen Hoeller
33: * @since 2.5
34: * @see #setParentName
35: * @see RootBeanDefinition
36: * @see ChildBeanDefinition
37: */
38: public class GenericBeanDefinition extends AbstractBeanDefinition {
39:
40: private String parentName;
41:
42: /**
43: * Create a new GenericBeanDefinition, to be configured through its bean
44: * properties and configuration methods.
45: * @see #setBeanClass
46: * @see #setBeanClassName
47: * @see #setSingleton
48: * @see #setAutowireMode
49: * @see #setDependencyCheck
50: * @see #setConstructorArgumentValues
51: * @see #setPropertyValues
52: */
53: public GenericBeanDefinition() {
54: super ();
55: }
56:
57: /**
58: * Create a new GenericBeanDefinition as deep copy of the given
59: * bean definition.
60: * @param original the original bean definition to copy from
61: */
62: public GenericBeanDefinition(BeanDefinition original) {
63: super (original);
64: }
65:
66: public void setParentName(String parentName) {
67: this .parentName = parentName;
68: }
69:
70: public String getParentName() {
71: return this .parentName;
72: }
73:
74: public AbstractBeanDefinition cloneBeanDefinition() {
75: return new GenericBeanDefinition(this );
76: }
77:
78: public boolean equals(Object other) {
79: return (this == other || (other instanceof GenericBeanDefinition && super
80: .equals(other)));
81: }
82:
83: public String toString() {
84: return "Generic bean: " + super.toString();
85: }
86:
87: }
|