Browse Source
Equivalent to <context:spring-configured/>. Also update @EnableLoadTimeWeaving Javadoc and spring-configured XSD documentation to reflect. Issue: SPR-7888pull/7/head
6 changed files with 146 additions and 2 deletions
@ -0,0 +1,47 @@
@@ -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 { |
||||
|
||||
} |
||||
@ -0,0 +1,49 @@
@@ -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(); |
||||
} |
||||
} |
||||
@ -0,0 +1,43 @@
@@ -0,0 +1,43 @@
|
||||
/* |
||||
* 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.context.ConfigurableApplicationContext; |
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.context.annotation.ImportResource; |
||||
|
||||
/** |
||||
* Tests that @EnableSpringConfigured properly registers an |
||||
* {@link AnnotationBeanConfigurerAspect}, just as does {@code <context:spring-configured>} |
||||
* |
||||
* @author Chris Beams |
||||
* @since 3.1 |
||||
*/ |
||||
public class AnnotationBeanConfigurerTests extends AbstractBeanConfigurerTests { |
||||
|
||||
@Override |
||||
protected ConfigurableApplicationContext createContext() { |
||||
return new AnnotationConfigApplicationContext(Config.class); |
||||
} |
||||
|
||||
@Configuration |
||||
@ImportResource("org/springframework/beans/factory/aspectj/beanConfigurerTests-beans.xml") |
||||
@EnableSpringConfigured |
||||
static class Config { |
||||
} |
||||
} |
||||
Loading…
Reference in new issue