Revert introduction of AnnotationConfigCapableAC
Per review with Juergen in light of SPR-8413, which will revisit the overall structure of ACAC and ACWAC. Issue: SPR-8365, SPR-8413
This commit is contained in:
parent
3b50fc8d86
commit
ae61aa3555
|
|
@ -45,8 +45,7 @@ import org.springframework.util.Assert;
|
|||
* @see ClassPathBeanDefinitionScanner
|
||||
* @see org.springframework.context.support.GenericXmlApplicationContext
|
||||
*/
|
||||
public class AnnotationConfigApplicationContext extends GenericApplicationContext
|
||||
implements AnnotationConfigCapableApplicationContext {
|
||||
public class AnnotationConfigApplicationContext extends GenericApplicationContext {
|
||||
|
||||
private final AnnotatedBeanDefinitionReader reader = new AnnotatedBeanDefinitionReader(this);
|
||||
|
||||
|
|
@ -102,9 +101,13 @@ public class AnnotationConfigApplicationContext extends GenericApplicationContex
|
|||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* Provide a custom {@link BeanNameGenerator} for use with {@link AnnotatedBeanDefinitionReader}
|
||||
* and/or {@link ClassPathBeanDefinitionScanner}, if any.
|
||||
* <p>Default is {@link org.springframework.context.annotation.AnnotationBeanNameGenerator}.
|
||||
* <p>Any call to this method must occur prior to calls to {@link #register(Class...)}
|
||||
* and/or {@link #scan(String...)}.
|
||||
* @see AnnotatedBeanDefinitionReader#setBeanNameGenerator
|
||||
* @see ClassPathBeanDefinitionScanner#setBeanNameGenerator
|
||||
*/
|
||||
public void setBeanNameGenerator(BeanNameGenerator beanNameGenerator) {
|
||||
this.reader.setBeanNameGenerator(beanNameGenerator);
|
||||
|
|
@ -112,7 +115,8 @@ public class AnnotationConfigApplicationContext extends GenericApplicationContex
|
|||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* Set the {@link ScopeMetadataResolver} to use for detected bean classes.
|
||||
* <p>The default is an {@link AnnotationScopeMetadataResolver}.
|
||||
* <p>Any call to this method must occur prior to calls to {@link #register(Class...)}
|
||||
* and/or {@link #scan(String...)}.
|
||||
*/
|
||||
|
|
@ -121,11 +125,30 @@ public class AnnotationConfigApplicationContext extends GenericApplicationContex
|
|||
this.scanner.setScopeMetadataResolver(scopeMetadataResolver);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register one or more annotated classes to be processed.
|
||||
* Note that {@link #refresh()} must be called in order for the context to fully
|
||||
* process the new class.
|
||||
* <p>Calls to {@link #register} are idempotent; adding the same
|
||||
* annotated class more than once has no additional effect.
|
||||
* @param annotatedClasses one or more annotated classes,
|
||||
* e.g. {@link Configuration @Configuration} classes
|
||||
* @see #scan(String...)
|
||||
* @see #refresh()
|
||||
*/
|
||||
public void register(Class<?>... annotatedClasses) {
|
||||
Assert.notEmpty(annotatedClasses, "At least one annotated class must be specified");
|
||||
this.reader.register(annotatedClasses);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a scan within the specified base packages.
|
||||
* Note that {@link #refresh()} must be called in order for the context to
|
||||
* fully process the new class.
|
||||
* @param basePackages the packages to check for annotated classes
|
||||
* @see #register(Class...)
|
||||
* @see #refresh()
|
||||
*/
|
||||
public void scan(String... basePackages) {
|
||||
Assert.notEmpty(basePackages, "At least one base package must be specified");
|
||||
this.scanner.scan(basePackages);
|
||||
|
|
|
|||
|
|
@ -1,92 +0,0 @@
|
|||
/*
|
||||
* 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.context.annotation;
|
||||
|
||||
import org.springframework.beans.factory.support.BeanNameGenerator;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
/**
|
||||
* Extension of the {@link ConfigurableApplicationContext} interface to be implemented by
|
||||
* application contexts that are capable of registering or scanning for annotated classes
|
||||
* including @{@link Configuration} classes.
|
||||
*
|
||||
* <p>This subinterface is not intended for everyday use:
|
||||
* {@link AnnotationConfigApplicationContext} and its web variant
|
||||
* {@code AnnotationConfigWebApplicationContext} should be used directly in most cases.
|
||||
*
|
||||
* <p>The notable exception to the above is when designing
|
||||
* {@link org.springframework.context.ApplicationContextInitializer
|
||||
* ApplicationContextInitializer} (ACI) implementations: it may be desirable to design an
|
||||
* ACI such that it may be used interchangeably against a standalone or web-capable
|
||||
* "AnnotationConfig" application context. For example:
|
||||
* <pre class="code">
|
||||
* public class MyACI
|
||||
* implements ApplicationContextInitializer<AnnotationConfigCapableApplicationContext> {
|
||||
* void initialize(AnnotationConfigCapableApplicationContext context) {
|
||||
* context.register(MyConfig1.class, MyConfig2.class);
|
||||
* context.scan("pkg1", "pkg2");
|
||||
* // ...
|
||||
* }
|
||||
* }</pre>
|
||||
*
|
||||
* See {@link org.springframework.context.ApplicationContextInitializer
|
||||
* ApplicationContextInitializer} Javadoc for further usage details.
|
||||
*
|
||||
* @author Chris Beams
|
||||
* @since 3.1
|
||||
* @see AnnotationConfigApplicationContext
|
||||
* @see org.springframework.web.context.support.AnnotationConfigWebApplicationContext
|
||||
* @see org.springframework.context.ApplicationContextInitializer
|
||||
*/
|
||||
public interface AnnotationConfigCapableApplicationContext extends ConfigurableApplicationContext {
|
||||
|
||||
/**
|
||||
* Set the {@link ScopeMetadataResolver} to use for detected bean classes.
|
||||
* <p>The default is an {@link AnnotationScopeMetadataResolver}.
|
||||
*/
|
||||
void setScopeMetadataResolver(ScopeMetadataResolver scopeMetadataResolver);
|
||||
|
||||
/**
|
||||
* Set the {@link BeanNameGenerator} to use for detected bean classes.
|
||||
* <p>The default is an {@link AnnotationBeanNameGenerator}.
|
||||
*/
|
||||
void setBeanNameGenerator(BeanNameGenerator beanNameGenerator);
|
||||
|
||||
/**
|
||||
* Register one or more annotated classes to be processed.
|
||||
* Note that {@link #refresh()} must be called in order for the context to fully
|
||||
* process the new class.
|
||||
* <p>Calls to {@link #register} are idempotent; adding the same
|
||||
* annotated class more than once has no additional effect.
|
||||
* @param annotatedClasses one or more annotated classes,
|
||||
* e.g. {@link Configuration @Configuration} classes
|
||||
* @see #scan(String...)
|
||||
* @see #refresh()
|
||||
*/
|
||||
void register(Class<?>... annotatedClasses);
|
||||
|
||||
/**
|
||||
* Perform a scan within the specified base packages.
|
||||
* Note that {@link #refresh()} must be called in order for the context to
|
||||
* fully process the new class.
|
||||
* @param basePackages the packages to check for annotated classes
|
||||
* @see #register(Class...)
|
||||
* @see #refresh()
|
||||
*/
|
||||
void scan(String... basePackages);
|
||||
|
||||
}
|
||||
|
|
@ -19,7 +19,6 @@ package org.springframework.web.context.support;
|
|||
import org.springframework.beans.factory.support.BeanNameGenerator;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.context.annotation.AnnotatedBeanDefinitionReader;
|
||||
import org.springframework.context.annotation.AnnotationConfigCapableApplicationContext;
|
||||
import org.springframework.context.annotation.ClassPathBeanDefinitionScanner;
|
||||
import org.springframework.context.annotation.ScopeMetadataResolver;
|
||||
import org.springframework.util.Assert;
|
||||
|
|
@ -73,11 +72,9 @@ import org.springframework.web.context.ContextLoader;
|
|||
* @author Chris Beams
|
||||
* @author Juergen Hoeller
|
||||
* @since 3.0
|
||||
* @see org.springframework.context.annotation.AnnotationConfigCapableApplicationContext
|
||||
* @see org.springframework.context.annotation.AnnotationConfigApplicationContext
|
||||
*/
|
||||
public class AnnotationConfigWebApplicationContext extends AbstractRefreshableWebApplicationContext
|
||||
implements AnnotationConfigCapableApplicationContext {
|
||||
public class AnnotationConfigWebApplicationContext extends AbstractRefreshableWebApplicationContext {
|
||||
|
||||
private Class<?>[] annotatedClasses;
|
||||
|
||||
|
|
@ -133,9 +130,15 @@ public class AnnotationConfigWebApplicationContext extends AbstractRefreshableWe
|
|||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* Register one or more annotated classes to be processed.
|
||||
* Note that {@link #refresh()} must be called in order for the context to fully
|
||||
* process the new class.
|
||||
* <p>Calls to {@link #register} are idempotent; adding the same
|
||||
* annotated class more than once has no additional effect.
|
||||
* @param annotatedClasses one or more annotated classes,
|
||||
* e.g. {@link Configuration @Configuration} classes
|
||||
* @see #scan(String...)
|
||||
* @see #loadBeanDefinitions(DefaultListableBeanFactory)
|
||||
* @see #register(Class...)
|
||||
* @see #setConfigLocation(String)
|
||||
* @see #refresh()
|
||||
*/
|
||||
|
|
@ -145,7 +148,10 @@ public class AnnotationConfigWebApplicationContext extends AbstractRefreshableWe
|
|||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* Perform a scan within the specified base packages.
|
||||
* Note that {@link #refresh()} must be called in order for the context to
|
||||
* fully process the new class.
|
||||
* @param basePackages the packages to check for annotated classes
|
||||
* @see #loadBeanDefinitions(DefaultListableBeanFactory)
|
||||
* @see #register(Class...)
|
||||
* @see #setConfigLocation(String)
|
||||
|
|
@ -256,6 +262,10 @@ public class AnnotationConfigWebApplicationContext extends AbstractRefreshableWe
|
|||
return this.beanNameGenerator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the {@link ScopeMetadataResolver} to use for detected bean classes.
|
||||
* <p>The default is an {@link AnnotationScopeMetadataResolver}.
|
||||
*/
|
||||
public void setScopeMetadataResolver(ScopeMetadataResolver scopeMetadataResolver) {
|
||||
this.scopeMetadataResolver = scopeMetadataResolver;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue