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.annotation;
18:
19: import org.springframework.beans.factory.support.GenericBeanDefinition;
20: import org.springframework.core.type.AnnotationMetadata;
21: import org.springframework.core.type.StandardAnnotationMetadata;
22:
23: /**
24: * Extension of the {@link org.springframework.beans.factory.support.GenericBeanDefinition}
25: * class, adding support for annotation metadata exposed through the
26: * {@link AnnotatedBeanDefinition} interface.
27: *
28: * <p>This RootBeanDefinition variant is mainly useful for testing code that expects
29: * to operate on an AnnotatedBeanDefinition, for example strategy implementations
30: * in Spring's component scanning support (where the default definition class is
31: * {@link org.springframework.context.annotation.ScannedGenericBeanDefinition},
32: * which also implements the AnnotatedBeanDefinition interface).
33: *
34: * @author Juergen Hoeller
35: * @since 2.5
36: * @see AnnotatedBeanDefinition#getMetadata()
37: * @see org.springframework.core.type.StandardAnnotationMetadata
38: */
39: public class AnnotatedGenericBeanDefinition extends
40: GenericBeanDefinition implements AnnotatedBeanDefinition {
41:
42: private final AnnotationMetadata annotationMetadata;
43:
44: /**
45: * Create a new AnnotatedGenericBeanDefinition for the given bean class.
46: * @param beanClass the loaded bean class
47: */
48: public AnnotatedGenericBeanDefinition(Class beanClass) {
49: setBeanClass(beanClass);
50: this .annotationMetadata = new StandardAnnotationMetadata(
51: beanClass);
52: }
53:
54: public final AnnotationMetadata getMetadata() {
55: return this.annotationMetadata;
56: }
57:
58: }
|