Skip to content

Commit 9f07b15

Browse files
committed
Added Javadoc where necessary; polishing.
1 parent 2e12907 commit 9f07b15

File tree

8 files changed

+279
-242
lines changed

8 files changed

+279
-242
lines changed

org.springframework.context/src/main/java/org/springframework/context/annotation/Bean.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,32 +29,32 @@
2929
* names and semantics of the attributes to this annotation are intentionally similar
3030
* to those of the {@literal <bean/>} element in the Spring XML schema. Deviations are
3131
* as follows:
32-
*
32+
*
3333
* <p>The Bean annotation does not provide attributes for scope, primary or lazy. Rather,
3434
* it should be used in conjunction with {@link Scope &#064;Scope},
3535
* {@link Primary &#064;Primary}, and {@link Lazy &#064;Lazy} annotations to achieve the
3636
* same semantics.
37-
*
37+
*
3838
* <p>While a {@link #name()} attribute is available, the default strategy for determining
3939
* the name of a bean is to use the name of the Bean method. This is convenient and
4040
* intuitive, but if explicit naming is desired, the {@link #name()} attribute may be used.
4141
* Also note that {@link #name()} accepts an array of strings. This is in order to allow
4242
* for specifying multiple names (i.e., aliases) for a single bean.
43-
*
43+
*
4444
* <h3>Constraints</h3>
4545
* <ul>
4646
* <li>Bean methods are valid only when declared within an {@link Configuration &#064;Configuration}-annotated class
47-
* <li>Bean methods must be non-void, non-final, non-private
48-
* <li>Bean methods may not accept any arguments
47+
* <li>Bean methods must be non-void, non-final, non-private
48+
* <li>Bean methods may not accept any arguments
4949
* <li>Bean methods may throw any exception, which will be caught and handled
5050
* by the Spring container on processing of the declaring {@link Configuration &#064;Configuration} class.
5151
* </ul>
52-
*
52+
*
5353
* <h3>Usage</h3>
5454
* <p>Bean methods may reference other Bean methods by calling them directly. This ensures
5555
* that references between beans are strongly typed and navigable. So called 'inter-bean
5656
* references' are guaranteed to respect scoping and AOP semantics.
57-
*
57+
*
5858
* @author Rod Johnson
5959
* @author Costin Leau
6060
* @author Chris Beams

org.springframework.context/src/main/java/org/springframework/context/annotation/Configuration.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,32 +31,32 @@
3131
* Indicates that a class declares one or more {@link Bean} methods and may be processed
3232
* by the Spring container to generate bean definitions and service requests for those beans
3333
* at runtime.
34-
*
34+
*
3535
* <p>Configuration is meta-annotated as a {@link Component}, therefore Configuration
3636
* classes are candidates for component-scanning and may also take advantage of
3737
* {@link Autowired} at the field and method but not at the constructor level.
3838
* Externalized values may be wired into Configuration classes using the {@link Value}
3939
* annotation.
40-
*
40+
*
4141
* <p>May be used in conjunction with the {@link Lazy} annotation to indicate that all Bean
4242
* methods declared within this class are by default lazily initialized.
43-
*
43+
*
4444
* <h3>Constraints</h3>
4545
* <ul>
4646
* <li>Configuration classes must be non-final
4747
* <li>Configuration classes must be non-local (may not be declared within a method)
4848
* <li>Configuration classes must have a default/no-arg constructor and may not use
4949
* {@link Autowired} constructor parameters
5050
* </ul>
51-
*
51+
*
5252
* @author Rod Johnson
5353
* @author Chris Beams
5454
* @since 3.0
5555
* @see Import
5656
* @see Lazy
5757
* @see Bean
58-
* @see ConfigurationClassPostProcessor;
59-
* @see AnnotationConfigApplicationContext ;
58+
* @see ConfigurationClassPostProcessor
59+
* @see AnnotationConfigApplicationContext
6060
*/
6161
@Target({ElementType.TYPE})
6262
@Retention(RetentionPolicy.RUNTIME)
@@ -68,15 +68,15 @@
6868
* Explicitly specify the name of the Spring bean definition associated
6969
* with this Configuration class. If left unspecified (the common case),
7070
* a bean name will be automatically generated.
71-
*
71+
*
7272
* <p>The custom name applies only if the Configuration class is picked up via
7373
* component scanning or supplied directly to a {@link AnnotationConfigApplicationContext}.
7474
* If the Configuration class is registered as a traditional XML bean definition,
7575
* the name/id of the bean element will take precedence.
76-
*
76+
*
7777
* @return the specified bean name, if any
7878
* @see org.springframework.beans.factory.support.DefaultBeanNameGenerator
7979
*/
8080
String value() default "";
81-
81+
8282
}

org.springframework.context/src/main/java/org/springframework/context/annotation/ConfigurationClass.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ final class ConfigurationClass {
4848

4949
private final Resource resource;
5050

51-
private String beanName;
52-
5351
private final Map<String, Class> importedResources = new LinkedHashMap<String, Class>();
5452

5553
private final Set<ConfigurationClassMethod> methods = new LinkedHashSet<ConfigurationClassMethod>();
5654

5755
private final Map<String, Integer> overloadedMethodMap = new LinkedHashMap<String, Integer>();
5856

57+
private String beanName;
58+
5959

6060
public ConfigurationClass(MetadataReader metadataReader, String beanName) {
6161
this.metadata = metadataReader.getAnnotationMetadata();
@@ -102,11 +102,11 @@ public ConfigurationClass addMethod(ConfigurationClassMethod method) {
102102
}
103103
return this;
104104
}
105-
105+
106106
public Set<ConfigurationClassMethod> getMethods() {
107107
return this.methods;
108108
}
109-
109+
110110
public void addImportedResource(String importedResource, Class readerClass) {
111111
this.importedResources.put(importedResource, readerClass);
112112
}

org.springframework.context/src/main/java/org/springframework/context/annotation/ConfigurationClassBeanDefinitionReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ private void loadBeanDefinitionsFromImportedResources(Map<String, Class> importe
233233
reader.loadBeanDefinitions(resource);
234234
}
235235
}
236-
236+
237237
/**
238238
* {@link RootBeanDefinition} marker subclass used to signify that a bean definition
239239
* created from a configuration class as opposed to any other configuration source.

org.springframework.context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@
3737
import org.springframework.util.StringUtils;
3838

3939
/**
40-
* Parses a {@link Configuration} class definition, populating a model (collection) of
40+
* Parses a {@link Configuration} class definition, populating a collection of
4141
* {@link ConfigurationClass} objects (parsing a single Configuration class may result in
4242
* any number of ConfigurationClass objects because one Configuration class may import
4343
* another using the {@link Import} annotation).
44-
*
44+
*
4545
* <p>This class helps separate the concern of parsing the structure of a Configuration
4646
* class from the concern of registering {@link BeanDefinition} objects based on the
4747
* content of that model.
@@ -61,7 +61,7 @@ class ConfigurationClassParser {
6161
private final ProblemReporter problemReporter;
6262

6363
private final Stack<ConfigurationClass> importStack = new ImportStack();
64-
64+
6565
private final Set<ConfigurationClass> configurationClasses =
6666
new LinkedHashSet<ConfigurationClass>();
6767

org.springframework.context/src/main/java/org/springframework/context/annotation/Import.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,32 @@
1818

1919
import java.lang.annotation.Documented;
2020
import java.lang.annotation.ElementType;
21-
import java.lang.annotation.Inherited;
2221
import java.lang.annotation.Retention;
2322
import java.lang.annotation.RetentionPolicy;
2423
import java.lang.annotation.Target;
2524

2625
/**
27-
* Annotation that allows one {@link Configuration} class to import another Configuration,
28-
* and thereby all its {@link Bean} definitions.
29-
*
26+
* Indicates one or more {@link Configuration} classes to import.
27+
*
3028
* <p>Provides functionality equivalent to the {@literal <import/>} element in Spring XML.
31-
* Only supported for actual {@link Configuration} classes.
29+
* Only supported for actual {@literal @Configuration}-annotated classes.
30+
*
31+
* <p>{@literal @Bean} definitions declared in imported {@literal @Configuration} classes
32+
* should be accessed by using {@link Autowired @Autowired} injection. Either the bean
33+
* itself can be autowired, or the configuration class instance declaring the bean can be
34+
* autowired. The latter approach allows for explicit, IDE-friendly navigation between
35+
* {@literal @Configuration} class methods.
36+
*
37+
* <p>If XML or other non-{@literal @Configuration} bean definition resources need to be
38+
* imported, use {@link ImportResource @ImportResource}
3239
*
3340
* @author Chris Beams
3441
* @since 3.0
3542
* @see Configuration
43+
* @see ImportResource
3644
*/
3745
@Target({ElementType.TYPE})
3846
@Retention(RetentionPolicy.RUNTIME)
39-
@Inherited
4047
@Documented
4148
public @interface Import {
4249

org.springframework.context/src/main/java/org/springframework/context/annotation/ImportResource.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,43 @@
2525
import org.springframework.beans.factory.support.BeanDefinitionReader;
2626
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
2727

28+
29+
/**
30+
* Indicates one or more resources containing bean definitions to import.
31+
*
32+
* <p>Like {@link Import @Import}, this annotation provides functionality similar to the
33+
* {@literal <import/>} element in Spring XML. It is typically used when
34+
* designing {@link Configuration @Configuration} classes to be bootstrapped by
35+
* {@link AnnotationConfigApplicationContext}, but where some XML functionality such as
36+
* namespaces is still necessary.
37+
*
38+
* <p>By default, arguments to the {@link #value()} attribute will be processed using
39+
* an {@link XmlBeanDefinitionReader}, i.e. it is assumed that resources are Spring
40+
* {@literal <beans/>} XML files. Optionally, the {@link #reader()} attribute may be
41+
* supplied, allowing the user to specify a different {@link BeanDefinitionReader}
42+
* implementation, such as
43+
* {@link org.springframework.beans.factory.support.PropertiesBeanDefinitionReader}.
44+
*
45+
* @author Chris Beams
46+
* @since 3.0
47+
* @see Configuration
48+
* @see Import
49+
*/
2850
@Retention(RetentionPolicy.RUNTIME)
2951
@Target(ElementType.TYPE)
3052
@Documented
3153
public @interface ImportResource {
3254

55+
/**
56+
* Resource paths to import. Resource-loading prefixes such as {@literal classpath:} and
57+
* {@literal file:}, etc may be used.
58+
*/
3359
String[] value();
3460

61+
/**
62+
* {@link BeanDefinitionReader} implementation to use when processing resources specified
63+
* by the {@link #value()} attribute.
64+
*/
3565
Class<? extends BeanDefinitionReader> reader() default XmlBeanDefinitionReader.class;
3666

3767
}

0 commit comments

Comments
 (0)