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.context.annotation;
18:
19: import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
20: import org.springframework.beans.factory.support.GenericBeanDefinition;
21: import org.springframework.core.type.AnnotationMetadata;
22: import org.springframework.core.type.classreading.MetadataReader;
23: import org.springframework.util.Assert;
24:
25: /**
26: * Extension of the {@link org.springframework.beans.factory.support.GenericBeanDefinition}
27: * class, based on an ASM ClassReader, with support for annotation metadata exposed
28: * through the {@link AnnotatedBeanDefinition} interface.
29: *
30: * <p>This class does <i>not</i> load the bean <code>Class</code> early.
31: * It rather retrieves all relevant metadata from the ".class" file itself,
32: * parsed with the ASM ClassReader.
33: *
34: * @author Juergen Hoeller
35: * @since 2.5
36: * @see #getMetadata()
37: * @see #getBeanClassName()
38: * @see org.springframework.core.type.classreading.MetadataReaderFactory
39: */
40: public class ScannedGenericBeanDefinition extends GenericBeanDefinition
41: implements AnnotatedBeanDefinition {
42:
43: private final AnnotationMetadata metadata;
44:
45: /**
46: * Create a new ScannedGenericBeanDefinition for the class that the
47: * given MetadataReader describes.
48: * @param metadataReader the MetadataReader for the scanned target class
49: */
50: public ScannedGenericBeanDefinition(MetadataReader metadataReader) {
51: Assert.notNull(metadataReader,
52: "MetadataReader must not be null");
53: this .metadata = metadataReader.getAnnotationMetadata();
54: setBeanClassName(this .metadata.getClassName());
55: }
56:
57: public final AnnotationMetadata getMetadata() {
58: return this.metadata;
59: }
60:
61: }
|