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.parsing;
18:
19: import org.springframework.beans.BeanMetadataElement;
20: import org.springframework.util.Assert;
21:
22: /**
23: * Representation of an alias that has been registered during the parsing process.
24: *
25: * @author Juergen Hoeller
26: * @since 2.0
27: * @see ReaderEventListener#aliasRegistered(AliasDefinition)
28: */
29: public class AliasDefinition implements BeanMetadataElement {
30:
31: private final String beanName;
32:
33: private final String alias;
34:
35: private final Object source;
36:
37: /**
38: * Create a new AliasDefinition.
39: * @param beanName the canonical name of the bean
40: * @param alias the alias registered for the bean
41: */
42: public AliasDefinition(String beanName, String alias) {
43: this (beanName, alias, null);
44: }
45:
46: /**
47: * Create a new AliasDefinition.
48: * @param beanName the canonical name of the bean
49: * @param alias the alias registered for the bean
50: * @param source the source object (may be <code>null</code>)
51: */
52: public AliasDefinition(String beanName, String alias, Object source) {
53: Assert.notNull(beanName, "Bean name must not be null");
54: Assert.notNull(alias, "Alias must not be null");
55: this .beanName = beanName;
56: this .alias = alias;
57: this .source = source;
58: }
59:
60: /**
61: * Return the canonical name of the bean.
62: */
63: public String getBeanName() {
64: return this .beanName;
65: }
66:
67: /**
68: * Return the alias registered for the bean.
69: */
70: public String getAlias() {
71: return this .alias;
72: }
73:
74: public Object getSource() {
75: return this.source;
76: }
77:
78: }
|