Introduce @EnableSpringConfigured

Equivalent to <context:spring-configured/>.

Also update @EnableLoadTimeWeaving Javadoc and spring-configured XSD
documentation to reflect.

Issue: SPR-7888
This commit is contained in:
Chris Beams
2011-11-28 06:57:17 +00:00
parent 4318ccd9d5
commit d35620511e
6 changed files with 146 additions and 2 deletions

View File

@@ -0,0 +1,47 @@
/*
* Copyright 2002-2011 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.beans.factory.aspectj;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.context.annotation.Import;
/**
* Signals the current application context to apply dependency injection to non-managed
* classes that are instantiated outside of the Spring bean factory (typically classes
* annotated with the @{@link org.springframework.beans.factory.annotation.Configurable
* Configurable} annotation).
*
* <p>Similar to functionality found in Spring's {@code <context:spring-configured>} XML
* element. Often used in conjunction with {@link
* org.springframework.context.annotation.EnableLoadTimeWeaving @EnableLoadTimeWeaving}.
*
* @author Chris Beams
* @since 3.1
* @see org.springframework.context.annotation.EnableLoadTimeWeaving
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Import(SpringConfiguredConfiguration.class)
public @interface EnableSpringConfigured {
}

View File

@@ -0,0 +1,49 @@
/*
* Copyright 2002-2011 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.beans.factory.aspectj;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Role;
/**
* {@code @Configuration} class that registers an {@link AnnotationBeanConfigurerAspect}
* capable of performing dependency injection services for non-Spring managed objects
* annotated with @{@link org.springframework.beans.factory.annotation.Configurable
* Configurable}.
*
* <p>This configuration class is automatically imported when using the @{@link
* EnableSpringConfigured} annotation. See {@code @EnableSpringConfigured} Javadoc for
* complete usage details.
*
* @author Chris Beams
* @since 3.1
* @see EnableSpringConfigured
*/
@Configuration
public class SpringConfiguredConfiguration {
public static final String BEAN_CONFIGURER_ASPECT_BEAN_NAME =
"org.springframework.context.config.internalBeanConfigurerAspect";
@Bean(name=BEAN_CONFIGURER_ASPECT_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public AnnotationBeanConfigurerAspect beanConfigurerAspect() {
return AnnotationBeanConfigurerAspect.aspectOf();
}
}