|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.springframework.test.context.support.DelegatingSmartContextLoader
public class DelegatingSmartContextLoader
DelegatingSmartContextLoader is an implementation of the SmartContextLoader
SPI that delegates to a set of candidate SmartContextLoaders (i.e.,
GenericXmlContextLoader and AnnotationConfigContextLoader) to
determine which context loader is appropriate for a given test classÕs configuration.
Each candidate is given a chance to process the
ContextConfigurationAttributes for each class in the test class hierarchy that
is annotated with @ContextConfiguration, and the candidate
that supports the merged, processed configuration will be used to actually
load the context.
Placing an empty @ContextConfiguration annotation on a test class signals
that default resource locations (i.e., XML configuration files) or default
configuration classes
should be detected. Furthermore, if a specific ContextLoader or
SmartContextLoader is not explicitly declared via
@ContextConfiguration, DelegatingSmartContextLoader will be used as
the default loader, thus providing automatic support for either XML configuration
files or configuration classes, but not both simultaneously.
SmartContextLoader,
GenericXmlContextLoader,
AnnotationConfigContextLoader| Constructor Summary | |
|---|---|
DelegatingSmartContextLoader()
|
|
| Method Summary | |
|---|---|
ApplicationContext |
loadContext(MergedContextConfiguration mergedConfig)
Delegates to an appropriate candidate SmartContextLoader to load
an ApplicationContext. |
ApplicationContext |
loadContext(String... locations)
DelegatingSmartContextLoader does not support the
ContextLoader.loadContext(String...) method. |
void |
processContextConfiguration(ContextConfigurationAttributes configAttributes)
Delegates to candidate SmartContextLoaders to process the supplied
ContextConfigurationAttributes. |
String[] |
processLocations(Class<?> clazz,
String... locations)
DelegatingSmartContextLoader does not support the
ContextLoader.processLocations(Class, String...) method. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DelegatingSmartContextLoader()
| Method Detail |
|---|
public void processContextConfiguration(ContextConfigurationAttributes configAttributes)
SmartContextLoaders to process the supplied
ContextConfigurationAttributes.
Delegation is based on explicit knowledge of the implementations of
GenericXmlContextLoader and AnnotationConfigContextLoader.
Specifically, the delegation algorithm is as follows:
ContextConfigurationAttributes are not empty, the appropriate
candidate loader will be allowed to process the configuration as is,
without any checks for detection of defaults.GenericXmlContextLoader will be allowed to process
the configuration in order to detect default resource locations. If
GenericXmlContextLoader detects default resource locations,
an info message will be logged.AnnotationConfigContextLoader will be allowed to
process the configuration in order to detect default configuration classes.
If AnnotationConfigContextLoader detects default configuration
classes, an info message will be logged.
processContextConfiguration in interface SmartContextLoaderconfigAttributes - the context configuration attributes to process
IllegalArgumentException - if the supplied configuration attributes are
null, or if the supplied configuration attributes include both
resource locations and configuration classes
IllegalStateException - if GenericXmlContextLoader detects default
configuration classes; if AnnotationConfigContextLoader detects default
resource locations; if neither candidate loader detects defaults for the supplied
context configuration; or if both candidate loaders detect defaults for the
supplied context configuration
public ApplicationContext loadContext(MergedContextConfiguration mergedConfig)
throws Exception
SmartContextLoader to load
an ApplicationContext.
Delegation is based on explicit knowledge of the implementations of
GenericXmlContextLoader and AnnotationConfigContextLoader.
Specifically, the delegation algorithm is as follows:
MergedContextConfiguration
are not empty and the configuration classes are empty,
GenericXmlContextLoader will load the ApplicationContext.MergedContextConfiguration
are not empty and the resource locations are empty,
AnnotationConfigContextLoader will load the ApplicationContext.
loadContext in interface SmartContextLoadermergedConfig - the merged context configuration to use to load the application context
IllegalArgumentException - if the supplied merged configuration is null
IllegalStateException - if neither candidate loader is capable of loading an
ApplicationContext from the supplied merged context configuration
Exception - if context loading failedSmartContextLoader.processContextConfiguration(ContextConfigurationAttributes),
org.springframework.context.annotation.AnnotationConfigUtils#registerAnnotationConfigProcessors(),
MergedContextConfiguration.getActiveProfiles(),
ConfigurableApplicationContext.getEnvironment()
public String[] processLocations(Class<?> clazz,
String... locations)
DelegatingSmartContextLoader does not support the
ContextLoader.processLocations(Class, String...) method. Call
processContextConfiguration(ContextConfigurationAttributes) instead.
processLocations in interface ContextLoaderclazz - the class with which the locations are associated: used to
determine how to process the supplied locationslocations - the unmodified locations to use for loading the
application context (can be null or empty)
UnsupportedOperationException
public ApplicationContext loadContext(String... locations)
throws Exception
DelegatingSmartContextLoader does not support the
ContextLoader.loadContext(String...) method. Call
loadContext(MergedContextConfiguration) instead.
loadContext in interface ContextLoaderlocations - the resource locations to use to load the application context
UnsupportedOperationException
Exception - if context loading failed
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||