Top Description Fields Constructors Methods
org.springframework.beans.factory.xml

public Class DefaultNamespaceHandlerResolver

extends Object
implements NamespaceHandlerResolver
Class Inheritance
All Implemented Interfaces
org.springframework.beans.factory.xml.NamespaceHandlerResolver
Imports
java.io.IOException, java.util.Map, .Properties, java.util.concurrent.ConcurrentHashMap, org.apache.commons.logging.Log, .LogFactory, org.springframework.beans.BeanUtils, .FatalBeanException, org.springframework.core.io.support.PropertiesLoaderUtils, org.springframework.lang.Nullable, org.springframework.util.Assert, .ClassUtils, .CollectionUtils

Default implementation of the NamespaceHandlerResolver interface. Resolves namespace URIs to implementation classes based on the mappings contained in mapping file.

By default, this implementation looks for the mapping file at META-INF/spring.handlers, but this can be changed using the DefaultNamespaceHandlerResolver(ClassLoader, String) constructor.

Authors
Rob Harrop, Juergen Hoeller
Since
2.0
See Also
NamespaceHandler, DefaultBeanDefinitionDocumentReader

Field Summary

Modifier and TypeField and Description
private final ClassLoader
classLoader

ClassLoader to use for NamespaceHandler classes.

public static final String
DEFAULT_HANDLER_MAPPINGS_LOCATION

The location to look for the mapping files.

private volatile Map<String, Object>
handlerMappings

Stores the mappings from namespace URI to NamespaceHandler class name / instance.

private final String
handlerMappingsLocation

Resource location to search for.

protected final Log
logger

Logger available to subclasses.

Constructor Summary

AccessConstructor and Description
public
DefaultNamespaceHandlerResolver()

Create a new DefaultNamespaceHandlerResolver using the default mapping file location.

public
DefaultNamespaceHandlerResolver(ClassLoader
the ClassLoader instance used to load mapping resources (may be null, in which case the thread context ClassLoader will be used)
classLoader
)

Create a new DefaultNamespaceHandlerResolver using the default mapping file location.

public
DefaultNamespaceHandlerResolver(ClassLoader
the ClassLoader instance used to load mapping resources may be null, in which case the thread context ClassLoader will be used
classLoader
,
String
the mapping file location
handlerMappingsLocation
)

Create a new DefaultNamespaceHandlerResolver using the supplied mapping file location.

Method Summary

Modifier and TypeMethod and Description
private Map<String, Object>
getHandlerMappings()

Load the specified NamespaceHandler mappings lazily.

public NamespaceHandler

Returns:

the located NamespaceHandler, or null if none found
resolve
(String
the relevant namespace URI
namespaceUri
)

Implements org.springframework.beans.factory.xml.NamespaceHandlerResolver.resolve.

Locate the NamespaceHandler for the supplied namespace URI from the configured mappings.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

classLoaderback to summary
private final ClassLoader classLoader

ClassLoader to use for NamespaceHandler classes.

Annotations
@Nullable
DEFAULT_HANDLER_MAPPINGS_LOCATIONback to summary
public static final String DEFAULT_HANDLER_MAPPINGS_LOCATION

The location to look for the mapping files. Can be present in multiple JAR files.

handlerMappingsback to summary
private volatile Map<String, Object> handlerMappings

Stores the mappings from namespace URI to NamespaceHandler class name / instance.

Annotations
@Nullable
handlerMappingsLocationback to summary
private final String handlerMappingsLocation

Resource location to search for.

loggerback to summary
protected final Log logger

Logger available to subclasses.

Constructor Detail

DefaultNamespaceHandlerResolverback to summary
public DefaultNamespaceHandlerResolver()

Create a new DefaultNamespaceHandlerResolver using the default mapping file location.

This constructor will result in the thread context ClassLoader being used to load resources.

See Also
DEFAULT_HANDLER_MAPPINGS_LOCATION
DefaultNamespaceHandlerResolverback to summary
public DefaultNamespaceHandlerResolver(ClassLoader classLoader)

Create a new DefaultNamespaceHandlerResolver using the default mapping file location.

Parameters
classLoader:ClassLoader

the ClassLoader instance used to load mapping resources (may be null, in which case the thread context ClassLoader will be used)

See Also
DEFAULT_HANDLER_MAPPINGS_LOCATION
DefaultNamespaceHandlerResolverback to summary
public DefaultNamespaceHandlerResolver(ClassLoader classLoader, String handlerMappingsLocation)

Create a new DefaultNamespaceHandlerResolver using the supplied mapping file location.

Parameters
classLoader:ClassLoader

the ClassLoader instance used to load mapping resources may be null, in which case the thread context ClassLoader will be used

handlerMappingsLocation:String

the mapping file location

Method Detail

getHandlerMappingsback to summary
private Map<String, Object> getHandlerMappings()

Load the specified NamespaceHandler mappings lazily.

resolveback to summary
public NamespaceHandler resolve(String namespaceUri)

Implements org.springframework.beans.factory.xml.NamespaceHandlerResolver.resolve.

Locate the NamespaceHandler for the supplied namespace URI from the configured mappings.

Parameters
namespaceUri:String

the relevant namespace URI

Returns:NamespaceHandler

the located NamespaceHandler, or null if none found

Annotations
@Override
@Nullable
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override