public class ContextConfigurationAttributes
extends java.lang.Object
ContextConfigurationAttributes
encapsulates the context configuration
attributes declared via @ContextConfiguration
.ContextConfiguration
,
SmartContextLoader.processContextConfiguration(ContextConfigurationAttributes)
,
MergedContextConfiguration
Modifier and Type | Field and Description |
---|---|
private java.lang.Class<?>[] |
classes |
private java.lang.Class<? extends ContextLoader> |
contextLoaderClass |
private java.lang.Class<?> |
declaringClass |
private boolean |
inheritInitializers |
private boolean |
inheritLocations |
private java.lang.Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>[] |
initializers |
private java.lang.String[] |
locations |
private static Log |
logger |
private java.lang.String |
name |
Constructor and Description |
---|
ContextConfigurationAttributes(java.lang.Class<?> declaringClass,
AnnotationAttributes annAttrs)
Construct a new
ContextConfigurationAttributes instance for the
supplied AnnotationAttributes (parsed from a
@ContextConfiguration annotation) and
the test class that declared them. |
ContextConfigurationAttributes(java.lang.Class<?> declaringClass,
ContextConfiguration contextConfiguration)
Construct a new
ContextConfigurationAttributes instance for the
supplied @ContextConfiguration annotation and
the test class that declared it. |
ContextConfigurationAttributes(java.lang.Class<?> declaringClass,
java.lang.String[] locations,
java.lang.Class<?>[] classes,
boolean inheritLocations,
java.lang.Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>[] initializers,
boolean inheritInitializers,
java.lang.Class<? extends ContextLoader> contextLoaderClass)
Construct a new
ContextConfigurationAttributes instance for the
test class that declared the
@ContextConfiguration annotation and its
corresponding attributes. |
ContextConfigurationAttributes(java.lang.Class<?> declaringClass,
java.lang.String[] locations,
java.lang.Class<?>[] classes,
boolean inheritLocations,
java.lang.Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>[] initializers,
boolean inheritInitializers,
java.lang.String name,
java.lang.Class<? extends ContextLoader> contextLoaderClass)
Construct a new
ContextConfigurationAttributes instance for the
test class that declared the
@ContextConfiguration annotation and its
corresponding attributes. |
ContextConfigurationAttributes(java.lang.Class<?> declaringClass,
java.lang.String[] locations,
java.lang.Class<?>[] classes,
boolean inheritLocations,
java.lang.Class<? extends ContextLoader> contextLoaderClass)
Deprecated.
as of Spring 3.2, use
ContextConfigurationAttributes(Class, String[], Class[], boolean, Class[], boolean, String, Class)
instead |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object other)
Determine if the supplied object is equal to this
ContextConfigurationAttributes instance by comparing both object's
declaring class,
locations,
annotated classes,
inheritLocations flag,
context initializer classes,
inheritInitializers flag, and the
ContextLoader class . |
java.lang.Class<?>[] |
getClasses()
Get the annotated classes that were declared via
@ContextConfiguration . |
java.lang.Class<? extends ContextLoader> |
getContextLoaderClass()
Get the
ContextLoader class that was declared via
@ContextConfiguration . |
java.lang.Class<?> |
getDeclaringClass()
Get the class that declared the
@ContextConfiguration annotation. |
java.lang.Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>[] |
getInitializers()
Get the
ApplicationContextInitializer classes that were declared via
@ContextConfiguration . |
java.lang.String[] |
getLocations()
Get the resource locations that were declared via
@ContextConfiguration . |
java.lang.String |
getName()
Get the name of the context hierarchy level that was declared via
@ContextConfiguration . |
boolean |
hasClasses()
Determine if this
ContextConfigurationAttributes instance has
class-based resources. |
int |
hashCode()
Generate a unique hash code for all properties of this
ContextConfigurationAttributes instance excluding the
name. |
boolean |
hasLocations()
Determine if this
ContextConfigurationAttributes instance has
path-based resource locations. |
boolean |
hasResources()
Determine if this
ContextConfigurationAttributes instance has
either path-based resource locations or class-based resources. |
boolean |
isInheritInitializers()
Get the
inheritInitializers flag that was declared via
@ContextConfiguration . |
boolean |
isInheritLocations()
Get the
inheritLocations flag that was declared via
@ContextConfiguration . |
private static java.lang.String[] |
resolveLocations(java.lang.Class<?> declaringClass,
ContextConfiguration contextConfiguration)
Resolve resource locations from the
locations
and value attributes of the supplied
ContextConfiguration annotation. |
private static java.lang.String[] |
resolveLocations(java.lang.Class<?> declaringClass,
java.lang.String[] locations,
java.lang.String[] value)
Resolve resource locations from the supplied
locations and
value arrays, which correspond to attributes of the same names in
the ContextConfiguration annotation. |
void |
setClasses(java.lang.Class<?>... classes)
Set the processed annotated classes, effectively overriding the
original value declared via
@ContextConfiguration . |
void |
setLocations(java.lang.String... locations)
Set the processed resource locations, effectively overriding the
original value declared via
@ContextConfiguration . |
java.lang.String |
toString()
Provide a String representation of the context configuration attributes
and declaring class.
|
private static final Log logger
private final java.lang.Class<?> declaringClass
private java.lang.Class<?>[] classes
private java.lang.String[] locations
private final boolean inheritLocations
private final java.lang.Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>[] initializers
private final boolean inheritInitializers
private final java.lang.String name
private final java.lang.Class<? extends ContextLoader> contextLoaderClass
public ContextConfigurationAttributes(java.lang.Class<?> declaringClass, ContextConfiguration contextConfiguration)
ContextConfigurationAttributes
instance for the
supplied @ContextConfiguration
annotation and
the test class that declared it.declaringClass
- the test class that declared @ContextConfiguration
contextConfiguration
- the annotation from which to retrieve the attributespublic ContextConfigurationAttributes(java.lang.Class<?> declaringClass, AnnotationAttributes annAttrs)
ContextConfigurationAttributes
instance for the
supplied AnnotationAttributes
(parsed from a
@ContextConfiguration
annotation) and
the test class that declared them.declaringClass
- the test class that declared @ContextConfiguration
annAttrs
- the annotation attributes from which to retrieve the attributes@Deprecated public ContextConfigurationAttributes(java.lang.Class<?> declaringClass, java.lang.String[] locations, java.lang.Class<?>[] classes, boolean inheritLocations, java.lang.Class<? extends ContextLoader> contextLoaderClass)
ContextConfigurationAttributes(Class, String[], Class[], boolean, Class[], boolean, String, Class)
insteadContextConfigurationAttributes
instance for the
test class that declared the
@ContextConfiguration
annotation and its
corresponding attributes.declaringClass
- the test class that declared @ContextConfiguration
locations
- the resource locations declared via @ContextConfiguration
classes
- the annotated classes declared via @ContextConfiguration
inheritLocations
- the inheritLocations
flag declared via @ContextConfiguration
contextLoaderClass
- the ContextLoader
class declared via @ContextConfiguration
java.lang.IllegalArgumentException
- if the declaringClass
or contextLoaderClass
is
null
public ContextConfigurationAttributes(java.lang.Class<?> declaringClass, java.lang.String[] locations, java.lang.Class<?>[] classes, boolean inheritLocations, java.lang.Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>[] initializers, boolean inheritInitializers, java.lang.Class<? extends ContextLoader> contextLoaderClass)
ContextConfigurationAttributes
instance for the
test class that declared the
@ContextConfiguration
annotation and its
corresponding attributes.declaringClass
- the test class that declared @ContextConfiguration
locations
- the resource locations declared via @ContextConfiguration
classes
- the annotated classes declared via @ContextConfiguration
inheritLocations
- the inheritLocations
flag declared via @ContextConfiguration
initializers
- the context initializers declared via @ContextConfiguration
inheritInitializers
- the inheritInitializers
flag declared via @ContextConfiguration
contextLoaderClass
- the ContextLoader
class declared via @ContextConfiguration
java.lang.IllegalArgumentException
- if the declaringClass
or contextLoaderClass
is
null
public ContextConfigurationAttributes(java.lang.Class<?> declaringClass, java.lang.String[] locations, java.lang.Class<?>[] classes, boolean inheritLocations, java.lang.Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>[] initializers, boolean inheritInitializers, java.lang.String name, java.lang.Class<? extends ContextLoader> contextLoaderClass)
ContextConfigurationAttributes
instance for the
test class that declared the
@ContextConfiguration
annotation and its
corresponding attributes.declaringClass
- the test class that declared @ContextConfiguration
locations
- the resource locations declared via @ContextConfiguration
classes
- the annotated classes declared via @ContextConfiguration
inheritLocations
- the inheritLocations
flag declared via @ContextConfiguration
initializers
- the context initializers declared via @ContextConfiguration
inheritInitializers
- the inheritInitializers
flag declared via @ContextConfiguration
name
- the name of level in the context hierarchy, or null
if not applicablecontextLoaderClass
- the ContextLoader
class declared via @ContextConfiguration
java.lang.IllegalArgumentException
- if the declaringClass
or contextLoaderClass
is
null
private static java.lang.String[] resolveLocations(java.lang.Class<?> declaringClass, ContextConfiguration contextConfiguration)
locations
and value
attributes of the supplied
ContextConfiguration
annotation.java.lang.IllegalStateException
- if both the locations and value attributes have been declaredprivate static java.lang.String[] resolveLocations(java.lang.Class<?> declaringClass, java.lang.String[] locations, java.lang.String[] value)
locations
and
value
arrays, which correspond to attributes of the same names in
the ContextConfiguration
annotation.java.lang.IllegalStateException
- if both the locations and value attributes have been declaredpublic java.lang.Class<?> getDeclaringClass()
@ContextConfiguration
annotation.null
)public void setClasses(java.lang.Class<?>... classes)
@ContextConfiguration
.getClasses()
public java.lang.Class<?>[] getClasses()
@ContextConfiguration
.
Note: this is a mutable property. The returned value may therefore
represent a processed value that does not match the original value
declared via @ContextConfiguration
.
null
or emptyContextConfiguration.classes()
,
setClasses(Class[])
public boolean hasClasses()
ContextConfigurationAttributes
instance has
class-based resources.true
if the classes
array is not emptyhasResources()
,
hasLocations()
public void setLocations(java.lang.String... locations)
@ContextConfiguration
.getLocations()
public java.lang.String[] getLocations()
@ContextConfiguration
.
Note: this is a mutable property. The returned value may therefore
represent a processed value that does not match the original value
declared via @ContextConfiguration
.
null
or emptyContextConfiguration.value()
,
ContextConfiguration.locations()
,
setLocations(String[])
public boolean hasLocations()
ContextConfigurationAttributes
instance has
path-based resource locations.true
if the locations
array is not emptyhasResources()
,
hasClasses()
public boolean hasResources()
ContextConfigurationAttributes
instance has
either path-based resource locations or class-based resources.true
if either the locations
or the classes
array is not emptyhasLocations()
,
hasClasses()
public boolean isInheritLocations()
inheritLocations
flag that was declared via
@ContextConfiguration
.inheritLocations
flagContextConfiguration.inheritLocations()
public java.lang.Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>[] getInitializers()
ApplicationContextInitializer
classes that were declared via
@ContextConfiguration
.ApplicationContextInitializer
classespublic boolean isInheritInitializers()
inheritInitializers
flag that was declared via
@ContextConfiguration
.inheritInitializers
flagpublic java.lang.String getName()
@ContextConfiguration
.null
if not applicableContextConfiguration.name()
public java.lang.Class<? extends ContextLoader> getContextLoaderClass()
ContextLoader
class that was declared via
@ContextConfiguration
.ContextLoader
classContextConfiguration.loader()
public boolean equals(java.lang.Object other)
ContextConfigurationAttributes
instance by comparing both object's
declaring class,
locations,
annotated classes,
inheritLocations flag,
context initializer classes,
inheritInitializers flag, and the
ContextLoader class
.equals
in class java.lang.Object
public int hashCode()
ContextConfigurationAttributes
instance excluding the
name.hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object