Consistent license header

This commit is contained in:
Juergen Hoeller
2016-04-11 20:49:38 +02:00
parent d695f65e7c
commit 537193a4e0
76 changed files with 834 additions and 687 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,14 +27,16 @@ import org.springframework.context.annotation.Import;
import org.springframework.core.Ordered;
/**
* Enables Spring's annotation-driven cache management capability, similar to
* the support found in Spring's {@code <cache:*>} XML namespace. To be used together
* Enables Spring's annotation-driven cache management capability, similar to the
* support found in Spring's {@code <cache:*>} XML namespace. To be used together
* with @{@link org.springframework.context.annotation.Configuration Configuration}
* classes as follows:
*
* <pre class="code">
* &#064;Configuration
* &#064;EnableCaching
* public class AppConfig {
*
* &#064;Bean
* public MyService myService() {
* // configure and return a class having &#064;Cacheable methods
@@ -52,11 +54,15 @@ import org.springframework.core.Ordered;
*
* <p>For reference, the example above can be compared to the following Spring XML
* configuration:
*
* <pre class="code">
* {@code
* <beans>
*
* <cache:annotation-driven/>
*
* <bean id="myService" class="com.foo.MyService"/>
*
* <bean id="cacheManager" class="org.springframework.cache.support.SimpleCacheManager">
* <property name="caches">
* <set>
@@ -66,8 +72,10 @@ import org.springframework.core.Ordered;
* </set>
* </property>
* </bean>
*
* </beans>
* }</pre>
*
* In both of the scenarios above, {@code @EnableCaching} and {@code
* <cache:annotation-driven/>} are responsible for registering the necessary Spring
* components that power annotation-driven cache management, such as the
@@ -90,12 +98,14 @@ import org.springframework.core.Ordered;
*
* <p>For those that wish to establish a more direct relationship between
* {@code @EnableCaching} and the exact cache manager bean to be used,
* the {@link CachingConfigurer} callback interface may be implemented - notice the
* the {@code @Override}-annotated methods below:
* the {@link CachingConfigurer} callback interface may be implemented.
* Notice the the {@code @Override}-annotated methods below:
*
* <pre class="code">
* &#064;Configuration
* &#064;EnableCaching
* public class AppConfig extends CachingConfigurerSupport {
*
* &#064;Bean
* public MyService myService() {
* // configure and return a class having &#064;Cacheable methods
@@ -118,6 +128,7 @@ import org.springframework.core.Ordered;
* return new MyKeyGenerator();
* }
* }</pre>
*
* This approach may be desirable simply because it is more explicit, or it may be
* necessary in order to distinguish between two {@code CacheManager} beans present in the
* same container.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,7 +39,8 @@ import org.springframework.beans.factory.support.AbstractBeanDefinition;
* public MyBean myBean() {
* // instantiate and configure MyBean obj
* return obj;
* }</pre>
* }
* </pre>
*
* <h3>Bean Names</h3>
*
@@ -55,7 +56,8 @@ import org.springframework.beans.factory.support.AbstractBeanDefinition;
* public MyBean myBean() {
* // instantiate and configure MyBean obj
* return obj;
* }</pre>
* }
* </pre>
*
* <h3>Scope, DependsOn, Primary, and Lazy</h3>
*
@@ -70,7 +72,8 @@ import org.springframework.beans.factory.support.AbstractBeanDefinition;
* public MyBean myBean() {
* // instantiate and configure MyBean obj
* return obj;
* }</pre>
* }
* </pre>
*
* <h3>{@code @Bean} Methods in {@code @Configuration} Classes</h3>
*
@@ -87,14 +90,17 @@ import org.springframework.beans.factory.support.AbstractBeanDefinition;
* <pre class="code">
* &#064;Configuration
* public class AppConfig {
*
* &#064;Bean
* public FooService fooService() {
* return new FooService(fooRepository());
* }
*
* &#064;Bean
* public FooRepository fooRepository() {
* return new JdbcFooRepository(dataSource());
* }
*
* // ...
* }</pre>
*
@@ -152,7 +158,8 @@ import org.springframework.beans.factory.support.AbstractBeanDefinition;
* &#064;Bean
* public static PropertyPlaceholderConfigurer ppc() {
* // instantiate, configure and return ppc ...
* }</pre>
* }
* </pre>
*
* By marking this method as {@code static}, it can be invoked without causing instantiation of its
* declaring {@code @Configuration} class, thus avoiding the above-mentioned lifecycle conflicts.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,12 +27,14 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
/**
* Indicates that a class declares one or more {@link Bean @Bean} methods and may be processed
* by the Spring container to generate bean definitions and service requests for those
* beans at runtime, for example:
* Indicates that a class declares one or more {@link Bean @Bean} methods and
* may be processed by the Spring container to generate bean definitions and
* service requests for those beans at runtime, for example:
*
* <pre class="code">
* &#064;Configuration
* public class AppConfig {
*
* &#064;Bean
* public MyBean myBean() {
* // instantiate, configure and return bean ...
@@ -40,25 +42,28 @@ import org.springframework.stereotype.Component;
* }</pre>
*
* <h2>Bootstrapping {@code @Configuration} classes</h2>
*
* <h3>Via {@code AnnotationConfigApplicationContext}</h3>
*
* {@code @Configuration} classes are typically bootstrapped using either
* {@link AnnotationConfigApplicationContext} or its web-capable variant,
* {@link org.springframework.web.context.support.AnnotationConfigWebApplicationContext
* AnnotationConfigWebApplicationContext}.
* A simple example with the former follows:
* AnnotationConfigWebApplicationContext}. A simple example with the former follows:
*
* <pre class="code">
* AnnotationConfigApplicationContext ctx =
* new AnnotationConfigApplicationContext();
* AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
* ctx.register(AppConfig.class);
* ctx.refresh();
* MyBean myBean = ctx.getBean(MyBean.class);
* // use myBean ...</pre>
* // use myBean ...
* </pre>
*
* See {@link AnnotationConfigApplicationContext} Javadoc for further details and see
* {@link org.springframework.web.context.support.AnnotationConfigWebApplicationContext
* AnnotationConfigWebApplicationContext} for {@code web.xml} configuration instructions.
*
* <h3>Via Spring {@code <beans>} XML</h3>
*
* <p>As an alternative to registering {@code @Configuration} classes directly against an
* {@code AnnotationConfigApplicationContext}, {@code @Configuration} classes may be
* declared as normal {@code <bean>} definitions within Spring XML files:
@@ -74,6 +79,7 @@ import org.springframework.stereotype.Component;
* post processors that facilitate handling {@code @Configuration} classes.
*
* <h3>Via component scanning</h3>
*
* <p>{@code @Configuration} is meta-annotated with {@link Component @Component}, therefore
* {@code @Configuration} classes are candidates for component scanning (typically using
* Spring XML's {@code <context:component-scan/>} element) and therefore may also take
@@ -82,6 +88,7 @@ import org.springframework.stereotype.Component;
* <p>{@code @Configuration} classes may not only be bootstrapped using
* component scanning, but may also themselves <em>configure</em> component scanning using
* the {@link ComponentScan @ComponentScan} annotation:
*
* <pre class="code">
* &#064;Configuration
* &#064;ComponentScan("com.acme.app.services")
@@ -89,18 +96,20 @@ import org.springframework.stereotype.Component;
* // various &#064;Bean definitions ...
* }</pre>
*
* See {@link ComponentScan @ComponentScan} Javadoc for details.
*
* See the {@link ComponentScan @ComponentScan} javadoc for details.
*
* <h2>Working with externalized values</h2>
*
* <h3>Using the {@code Environment} API</h3>
*
* Externalized values may be looked up by injecting the Spring
* {@link org.springframework.core.env.Environment Environment} into a
* {@code @Configuration} class using the {@code @Autowired} or the {@code @Inject}
* annotation:
* {@link org.springframework.core.env.Environment} into a {@code @Configuration}
* class using the {@code @Autowired} or the {@code @Inject} annotation:
*
* <pre class="code">
* &#064;Configuration
* public class AppConfig {
*
* &#064Inject Environment env;
*
* &#064;Bean
@@ -115,10 +124,12 @@ import org.springframework.stereotype.Component;
* source" objects, and {@code @Configuration} classes may contribute property sources to
* the {@code Environment} object using
* the {@link org.springframework.core.env.PropertySources @PropertySources} annotation:
*
* <pre class="code">
* &#064;Configuration
* &#064;PropertySource("classpath:/com/acme/app.properties")
* public class AppConfig {
*
* &#064Inject Environment env;
*
* &#064;Bean
@@ -131,12 +142,15 @@ import org.springframework.stereotype.Component;
* and {@link PropertySource @PropertySource} Javadoc for further details.
*
* <h3>Using the {@code @Value} annotation</h3>
*
* Externalized values may be 'wired into' {@code @Configuration} classes using
* the {@link Value @Value} annotation:
*
* <pre class="code">
* &#064;Configuration
* &#064;PropertySource("classpath:/com/acme/app.properties")
* public class AppConfig {
*
* &#064Value("${bean.name}") String beanName;
*
* &#064;Bean
@@ -155,14 +169,18 @@ import org.springframework.stereotype.Component;
* {@code PropertySourcesPlaceholderConfigurer}.
*
* <h2>Composing {@code @Configuration} classes</h2>
*
* <h3>With the {@code @Import} annotation</h3>
*
* <p>{@code @Configuration} classes may be composed using the {@link Import @Import} annotation,
* not unlike the way that {@code <import>} works in Spring XML. Because
* {@code @Configuration} objects are managed as Spring beans within the container,
* imported configurations may be injected using {@code @Autowired} or {@code @Inject}:
*
* <pre class="code">
* &#064;Configuration
* public class DatabaseConfig {
*
* &#064;Bean
* public DataSource dataSource() {
* // instantiate, configure and return DataSource
@@ -172,6 +190,7 @@ import org.springframework.stereotype.Component;
* &#064;Configuration
* &#064;Import(DatabaseConfig.class)
* public class AppConfig {
*
* &#064Inject DatabaseConfig dataConfig;
*
* &#064;Bean
@@ -188,13 +207,15 @@ import org.springframework.stereotype.Component;
* new AnnotationConfigApplicationContext(AppConfig.class);</pre>
*
* <h3>With the {@code @Profile} annotation</h3>
*
* {@code @Configuration} classes may be marked with the {@link Profile @Profile} annotation to
* indicate they should be processed only if a given profile or profiles are
* <em>active</em>:
* indicate they should be processed only if a given profile or profiles are <em>active</em>:
*
* <pre class="code">
* &#064;Profile("embedded")
* &#064;Configuration
* public class EmbeddedDatabaseConfig {
*
* &#064;Bean
* public DataSource dataSource() {
* // instantiate, configure and return embedded DataSource
@@ -204,25 +225,29 @@ import org.springframework.stereotype.Component;
* &#064;Profile("production")
* &#064;Configuration
* public class ProductionDatabaseConfig {
*
* &#064;Bean
* public DataSource dataSource() {
* // instantiate, configure and return production DataSource
* }
* }</pre>
*
* See {@link Profile @Profile} and {@link org.springframework.core.env.Environment Environment}
* Javadoc for further details.
* See the {@link Profile @Profile} and {@link org.springframework.core.env.Environment}
* javadocs for further details.
*
* <h3>With Spring XML using the {@code @ImportResource} annotation</h3>
*
* As mentioned above, {@code @Configuration} classes may be declared as regular Spring
* {@code <bean>} definitions within Spring XML files. It is also possible to
* import Spring XML configuration files into {@code @Configuration} classes using
* the {@link ImportResource @ImportResource} annotation. Bean definitions imported from XML can be
* injected using {@code @Autowired} or {@code @Inject}:
*
* <pre class="code">
* &#064;Configuration
* &#064;ImportResource("classpath:/com/acme/database-config.xml")
* public class AppConfig {
*
* &#064Inject DataSource dataSource; // from XML
*
* &#064;Bean
@@ -233,10 +258,13 @@ import org.springframework.stereotype.Component;
* }</pre>
*
* <h3>With nested {@code @Configuration} classes</h3>
*
* {@code @Configuration} classes may be nested within one another as follows:
*
* <pre class="code">
* &#064;Configuration
* public class AppConfig {
*
* &#064;Inject DataSource dataSource;
*
* &#064;Bean
@@ -264,6 +292,7 @@ import org.springframework.stereotype.Component;
* enclosing {@code @Configuration} class.
*
* <h2>Configuring lazy initialization</h2>
*
* <p>By default, {@code @Bean} methods will be <em>eagerly instantiated</em> at container
* bootstrap time. To avoid this, {@code @Configuration} may be used in conjunction with
* the {@link Lazy @Lazy} annotation to indicate that all {@code @Bean} methods declared within
@@ -271,9 +300,11 @@ import org.springframework.stereotype.Component;
* individual {@code @Bean} methods as well.
*
* <h2>Testing support for {@code @Configuration} classes</h2>
*
* The Spring <em>TestContext framework</em> available in the {@code spring-test} module
* provides the {@code @ContextConfiguration} annotation, which as of Spring 3.1 can
* accept an array of {@code @Configuration} {@code Class} objects:
*
* <pre class="code">
* &#064;RunWith(SpringJUnit4ClassRunner.class)
* &#064;ContextConfiguration(classes={AppConfig.class, DatabaseConfig.class})
@@ -292,6 +323,7 @@ import org.springframework.stereotype.Component;
* See TestContext framework reference documentation for details.
*
* <h2>Enabling built-in Spring features using {@code @Enable} annotations</h2>
*
* Spring features such as asynchronous method execution, scheduled task execution,
* annotation driven transaction management, and even Spring MVC can be enabled and
* configured from {@code @Configuration}
@@ -304,6 +336,7 @@ import org.springframework.stereotype.Component;
* for details.
*
* <h2>Constraints when authoring {@code @Configuration} classes</h2>
*
* <ul>
* <li>&#064;Configuration classes must be non-final
* <li>&#064;Configuration classes must be non-local (may not be declared within a method)

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@ import java.lang.annotation.Target;
* &#064;Configuration
* &#064;EnableAspectJAutoProxy
* public class AppConfig {
*
* &#064;Bean
* public FooService fooService() {
* return new FooService();
@@ -47,12 +48,14 @@ import java.lang.annotation.Target;
*
* <pre class="code">
* public class FooService {
*
* // various methods
* }</pre>
*
* <pre class="code">
* &#064;Aspect
* public class MyAspect {
*
* &#064;Before("execution(* FooService+.*(..))")
* public void advice() {
* // advise FooService methods as appropriate
@@ -66,6 +69,7 @@ import java.lang.annotation.Target;
* <p>Users can control the type of proxy that gets created for {@code FooService} using
* the {@link #proxyTargetClass()} attribute. The following enables CGLIB-style 'subclass'
* proxies as opposed to the default interface-based JDK proxy approach.
*
* <pre class="code">
* &#064;Configuration
* &#064;EnableAspectJAutoProxy(proxyTargetClass=true)
@@ -75,6 +79,7 @@ import java.lang.annotation.Target;
*
* <p>Note that {@code @Aspect} beans may be component-scanned like any other. Simply
* mark the aspect with both {@code @Aspect} and {@code @Component}:
*
* <pre class="code">
* package com.foo;
*
@@ -86,11 +91,13 @@ import java.lang.annotation.Target;
* public class MyAspect { ... }</pre>
*
* Then use the @{@link ComponentScan} annotation to pick both up:
*
* <pre class="code">
* &#064;Configuration
* &#064;ComponentScan("com.foo")
* &#064;EnableAspectJAutoProxy
* public class AppConfig {
*
* // no explicit &#064Bean definitions required
* }</pre>
*

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,22 +29,28 @@ import org.springframework.instrument.classloading.LoadTimeWeaver;
* Activates a Spring {@link LoadTimeWeaver} for this application context, available as
* a bean with the name "loadTimeWeaver", similar to the {@code <context:load-time-weaver>}
* element in Spring XML.
* To be used
* on @{@link org.springframework.context.annotation.Configuration Configuration} classes;
*
* <p>To be used on @{@link org.springframework.context.annotation.Configuration Configuration} classes;
* the simplest possible example of which follows:
*
* <pre class="code">
* &#064;Configuration
* &#064;EnableLoadTimeWeaving
* public class AppConfig {
*
* // application-specific &#064;Bean definitions ...
* }</pre>
*
* The example above is equivalent to the following Spring XML configuration:
*
* <pre class="code">
* {@code
* <beans>
*
* <context:load-time-weaver/>
*
* <!-- application-specific <bean> definitions -->
*
* </beans>
* }</pre>
*
@@ -61,10 +67,12 @@ import org.springframework.instrument.classloading.LoadTimeWeaver;
* {@code @EnableLoadTimeWeaving} may also implement the {@link LoadTimeWeavingConfigurer}
* interface and return a custom {@code LoadTimeWeaver} instance through the
* {@code #getLoadTimeWeaver} method:
*
* <pre class="code">
* &#064;Configuration
* &#064;EnableLoadTimeWeaving
* public class AppConfig implements LoadTimeWeavingConfigurer {
*
* &#064;Override
* public LoadTimeWeaver getLoadTimeWeaver() {
* MyLoadTimeWeaver ltw = new MyLoadTimeWeaver();
@@ -75,10 +83,13 @@ import org.springframework.instrument.classloading.LoadTimeWeaver;
* }</pre>
*
* <p>The example above can be compared to the following Spring XML configuration:
*
* <pre class="code">
* {@code
* <beans>
*
* <context:load-time-weaver weaverClass="com.acme.MyLoadTimeWeaver"/>
*
* </beans>
* }</pre>
*
@@ -94,6 +105,7 @@ import org.springframework.instrument.classloading.LoadTimeWeaver;
* be registered through {@link LoadTimeWeaver#addTransformer}. AspectJ weaving will be
* activated by default if a "META-INF/aop.xml" resource is present on the classpath.
* Example:
*
* <pre class="code">
* &#064;Configuration
* &#064;EnableLoadTimeWeaving(aspectjWeaving=ENABLED)
@@ -101,10 +113,13 @@ import org.springframework.instrument.classloading.LoadTimeWeaver;
* }</pre>
*
* <p>The example above can be compared to the following Spring XML configuration:
*
* <pre class="code">
* {@code
* <beans>
*
* <context:load-time-weaver aspectj-weaving="on"/>
*
* </beans>
* }</pre>
*
@@ -131,7 +146,8 @@ public @interface EnableLoadTimeWeaving {
*/
AspectJWeaving aspectjWeaving() default AspectJWeaving.AUTODETECT;
public enum AspectJWeaving {
enum AspectJWeaving {
/**
* Switches on Spring-based AspectJ load-time weaving.
@@ -151,4 +167,5 @@ public @interface EnableLoadTimeWeaving {
*/
AUTODETECT;
}
}

View File

@@ -32,6 +32,7 @@ import org.springframework.core.io.support.PropertySourceFactory;
* conjunction with @{@link Configuration} classes.
*
* <h3>Example usage</h3>
*
* <p>Given a file {@code app.properties} containing the key/value pair
* {@code testbean.name=myTestBean}, the following {@code @Configuration} class
* uses {@code @PropertySource} to contribute {@code app.properties} to the
@@ -58,6 +59,7 @@ import org.springframework.core.io.support.PropertySourceFactory;
* the configuration above, a call to {@code testBean.getName()} will return "myTestBean".
*
* <h3>Resolving ${...} placeholders in {@code <bean>} and {@code @Value} annotations</h3>
*
* In order to resolve ${...} placeholders in {@code <bean>} definitions or {@code @Value}
* annotations using properties from a {@code PropertySource}, one must register
* a {@code PropertySourcesPlaceholderConfigurer}. This happens automatically when using
@@ -68,9 +70,11 @@ import org.springframework.core.io.support.PropertySourceFactory;
* for details and examples.
*
* <h3>Resolving ${...} placeholders within {@code @PropertySource} resource locations</h3>
*
* Any ${...} placeholders present in a {@code @PropertySource} {@linkplain #value()
* resource location} will be resolved against the set of property sources already
* registered against the environment. For example:
* registered against the environment. For example:
*
* <pre class="code">
* &#064;Configuration
* &#064;PropertySource("classpath:/com/${my.placeholder:default/path}/app.properties")
@@ -94,6 +98,7 @@ import org.springframework.core.io.support.PropertySourceFactory;
* IllegalArgumentException} will be thrown.
*
* <h3>A note on property overriding with @PropertySource</h3>
*
* In cases where a given property key exists in more than one {@code .properties}
* file, the last {@code @PropertySource} annotation processed will 'win' and override.
*

View File

@@ -64,8 +64,7 @@ import org.springframework.core.Ordered;
* {@code void} return type cannot transmit any exception back to the caller. By default,
* such uncaught exceptions are only logged.
*
* <p>To customize all this, implement {@link AsyncConfigurer} and
* provide:
* <p>To customize all this, implement {@link AsyncConfigurer} and provide:
* <ul>
* <li>your own {@link java.util.concurrent.Executor Executor} through the
* {@link AsyncConfigurer#getAsyncExecutor getAsyncExecutor()} method, and</li>
@@ -114,13 +113,19 @@ import org.springframework.core.Ordered;
*
* <p>For reference, the example above can be compared to the following Spring XML
* configuration:
*
* <pre class="code">
* {@code
* <beans>
*
* <task:annotation-driven executor="myExecutor" exception-handler="exceptionHandler"/>
*
* <task:executor id="myExecutor" pool-size="7-42" queue-capacity="11"/>
*
* <bean id="asyncBean" class="com.foo.MyAsyncBean"/>
*
* <bean id="exceptionHandler" class="com.foo.MyAsyncUncaughtExceptionHandler"/>
*
* </beans>
* }</pre>
*
@@ -148,8 +153,8 @@ public @interface EnableAsync {
/**
* Indicate the 'async' annotation type to be detected at either class
* or method level.
* <p>By default, both Spring's @{@link Async} annotation and the EJB
* 3.1 {@code @javax.ejb.Asynchronous} annotation will be detected.
* <p>By default, both Spring's @{@link Async} annotation and the EJB 3.1
* {@code @javax.ejb.Asynchronous} annotation will be detected.
* <p>This attribute exists so that developers can provide their own
* custom annotation type to indicate that a method (or all methods of
* a given class) should be invoked asynchronously.

View File

@@ -163,18 +163,25 @@ import org.springframework.scheduling.config.ScheduledTaskRegistrar;
*
* <p>For reference, the example above can be compared to the following Spring XML
* configuration:
*
* <pre class="code">
* {@code
* <beans>
*
* <task:annotation-driven scheduler="taskScheduler"/>
*
* <task:scheduler id="taskScheduler" pool-size="42"/>
*
* <task:scheduled-tasks scheduler="taskScheduler">
* <task:scheduled ref="myTask" method="work" fixed-rate="1000"/>
* </task:scheduled-tasks>
*
* <bean id="myTask" class="com.foo.MyTask"/>
*
* </beans>
* }</pre>
* the examples are equivalent save that in XML a <em>fixed-rate</em> period is used
*
* The examples are equivalent save that in XML a <em>fixed-rate</em> period is used
* instead of a custom <em>{@code Trigger}</em> implementation; this is because the
* {@code task:} namespace {@code scheduled} cannot easily expose such support. This is
* but one demonstration how the code-based approach allows for maximum configurability