KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > beans > factory > wiring > BeanWiringInfo


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.wiring;
18
19 import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
20 import org.springframework.util.Assert;
21
22 /**
23  * Holder for bean wiring metadata information about a particular class. Used in
24  * conjunction with the {@link org.springframework.beans.factory.annotation.Configurable}
25  * annotation and the AspectJ <code>AnnotationBeanConfigurerAspect</code>.
26  *
27  * @author Rod Johnson
28  * @author Juergen Hoeller
29  * @since 2.0
30  * @see BeanWiringInfoResolver
31  * @see org.springframework.beans.factory.config.AutowireCapableBeanFactory
32  * @see org.springframework.beans.factory.annotation.Configurable
33  */

34 public class BeanWiringInfo {
35
36     /**
37      * Constant that indicates autowiring bean properties by name.
38      * @see #BeanWiringInfo(int, boolean)
39      * @see org.springframework.beans.factory.config.AutowireCapableBeanFactory#AUTOWIRE_BY_NAME
40      */

41     public static final int AUTOWIRE_BY_NAME = AutowireCapableBeanFactory.AUTOWIRE_BY_NAME;
42
43     /**
44      * Constant that indicates autowiring bean properties by type.
45      * @see #BeanWiringInfo(int, boolean)
46      * @see org.springframework.beans.factory.config.AutowireCapableBeanFactory#AUTOWIRE_BY_TYPE
47      */

48     public static final int AUTOWIRE_BY_TYPE = AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE;
49
50
51     private String JavaDoc beanName = null;
52
53     private int autowireMode = AutowireCapableBeanFactory.AUTOWIRE_NO;
54
55     private boolean dependencyCheck = false;
56
57
58     /**
59      * Create a new BeanWiringInfo that points to the given bean name.
60      * @param beanName the name of the bean definition to take the property values from
61      * @throws IllegalArgumentException if the supplied beanName is <code>null</code>,
62      * is empty, or consists wholly of whitespace
63      */

64     public BeanWiringInfo(String JavaDoc beanName) {
65         Assert.hasText(beanName, "'beanName' must not be empty");
66         this.beanName = beanName;
67     }
68
69     /**
70      * Create a new BeanWiringInfo that indicates autowiring.
71      * @param autowireMode one of the constants {@link #AUTOWIRE_BY_NAME} /
72      * {@link #AUTOWIRE_BY_TYPE}
73      * @param dependencyCheck whether to perform a dependency check for object
74      * references in the bean instance (after autowiring)
75      * @throws IllegalArgumentException if the supplied <code>autowireMode</code>
76      * is not one of the allowed values
77      * @see #AUTOWIRE_BY_NAME
78      * @see #AUTOWIRE_BY_TYPE
79      */

80     public BeanWiringInfo(int autowireMode, boolean dependencyCheck) {
81         if (autowireMode != AUTOWIRE_BY_NAME && autowireMode != AUTOWIRE_BY_TYPE) {
82             throw new IllegalArgumentException JavaDoc("Just constants AUTOWIRE_BY_NAME and AUTOWIRE_BY_TYPE allowed");
83         }
84         this.autowireMode = autowireMode;
85         this.dependencyCheck = dependencyCheck;
86     }
87
88
89     /**
90      * Return whether this BeanWiringInfo indicates autowiring.
91      */

92     public boolean indicatesAutowiring() {
93         return (this.beanName == null);
94     }
95
96     /**
97      * Return the specific bean name that this BeanWiringInfo points to, if any.
98      */

99     public String JavaDoc getBeanName() {
100         return this.beanName;
101     }
102
103     /**
104      * Return one of the constants {@link #AUTOWIRE_BY_NAME} /
105      * {@link #AUTOWIRE_BY_TYPE}, if autowiring is indicated.
106      */

107     public int getAutowireMode() {
108         return this.autowireMode;
109     }
110
111     /**
112      * Return whether to perform a dependency check for object references
113      * in the bean instance (after autowiring).
114      */

115     public boolean getDependencyCheck() {
116         return this.dependencyCheck;
117     }
118
119 }
120
Popular Tags