public class HierarchicalResourceLoader
extends org.springframework.core.io.DefaultResourceLoader
implements org.springframework.beans.factory.InitializingBean
HierarchicalResourceLoader.DEFAULT_DIALECT_PLACEHOLDER is replaced with successive class
names starting from the dialect class and
progressing up the hierarchy until the base class
is reached. A full resource search using Spring's DefaultResourceLoader is
done at each point until the resource is found or the base of the class hierarchy is
reached.
For example assume classpath resources:
RESOURCE 1: config/ibatis/org.hibernate.dialect.Dialect/SqlMap-DOG.xml
RESOURCE 2: config/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/SqlMap-DOG.xml
RESOURCE 3: config/ibatis/org.hibernate.dialect.Dialect/SqlMap-CAT.xml
RESOURCE 4: config/ibatis/org.hibernate.dialect.MySQLDialect/SqlMap-CAT.xml
and
dialectBaseClass = org.hibernate.dialect.Dialect
For dialect org.hibernate.dialect.MySQLInnoDBDialect the following will be returned:
config/ibatis/#resource.dialect#/SqlMap-DOG.xml == RESOURCE 2
config/ibatis/#resource.dialect#/SqlMap-CAT.xml == RESOURCE 4
For dialectorg.hibernate.dialect.MySQLDBDialect the following will be returned:
config/ibatis/#resource.dialect#/SqlMap-DOG.xml == RESOURCE 1
config/ibatis/#resource.dialect#/SqlMap-CAT.xml == RESOURCE 4
For dialectorg.hibernate.dialect.Dialect the following will be returned:
config/ibatis/#resource.dialect#/SqlMap-DOG.xml == RESOURCE 1
config/ibatis/#resource.dialect#/SqlMap-CAT.xml == RESOURCE 3
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DEFAULT_DIALECT_PLACEHOLDER |
static java.lang.String |
DEFAULT_DIALECT_REGEX |
| Constructor and Description |
|---|
HierarchicalResourceLoader()
Create a new HierarchicalResourceLoader.
|
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet() |
org.springframework.core.io.Resource |
getResource(java.lang.String location)
Get a resource using the defined class hierarchy as a search path.
|
void |
setDialectBaseClass(java.lang.String className)
Set the class to be used during hierarchical dialect replacement.
|
void |
setDialectClass(java.lang.String className) |
public static final java.lang.String DEFAULT_DIALECT_PLACEHOLDER
public static final java.lang.String DEFAULT_DIALECT_REGEX
public HierarchicalResourceLoader()
public void setDialectBaseClass(java.lang.String className)
className - the name of the class or interfacepublic void setDialectClass(java.lang.String className)
public void afterPropertiesSet()
throws java.lang.Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanjava.lang.Exceptionpublic org.springframework.core.io.Resource getResource(java.lang.String location)
getResource in interface org.springframework.core.io.ResourceLoadergetResource in class org.springframework.core.io.DefaultResourceLoaderlocation - the location including a placeholderCopyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.