KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > beans > factory > config > RuntimeBeanNameReference


1 /*
2  * Copyright 2002-2006 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.config;
18
19 import org.springframework.util.Assert;
20
21 /**
22  * Immutable placeholder class used for a property value object when it's a
23  * reference to another bean name in the factory, to be resolved at runtime.
24  *
25  * @author Juergen Hoeller
26  * @since 2.0
27  * @see RuntimeBeanReference
28  * @see BeanDefinition#getPropertyValues()
29  * @see org.springframework.beans.factory.BeanFactory#getBean
30  */

31 public class RuntimeBeanNameReference implements BeanReference {
32     
33     private final String JavaDoc beanName;
34
35     private Object JavaDoc source;
36
37
38     /**
39      * Create a new RuntimeBeanNameReference to the given bean name.
40      * @param beanName name of the target bean
41      */

42     public RuntimeBeanNameReference(String JavaDoc beanName) {
43         Assert.hasText(beanName, "'beanName' must not be empty");
44         this.beanName = beanName;
45     }
46
47     public String JavaDoc getBeanName() {
48         return beanName;
49     }
50
51     /**
52      * Set the configuration source <code>Object</code> for this metadata element.
53      * <p>The exact type of the object will depend on the configuration mechanism used.
54      */

55     public void setSource(Object JavaDoc source) {
56         this.source = source;
57     }
58
59     public Object JavaDoc getSource() {
60         return source;
61     }
62
63
64     public boolean equals(Object JavaDoc other) {
65         if (this == other) {
66             return true;
67         }
68         if (!(other instanceof RuntimeBeanNameReference)) {
69             return false;
70         }
71         RuntimeBeanNameReference that = (RuntimeBeanNameReference) other;
72         return this.beanName.equals(that.beanName);
73     }
74
75     public int hashCode() {
76         return this.beanName.hashCode();
77     }
78
79     public String JavaDoc toString() {
80        return '<' + getBeanName() + '>';
81     }
82
83 }
84
Popular Tags