public class XmlConfiguration
extends java.lang.Object
implements org.ehcache.config.Configuration
Configuration and CacheConfigurationBuilder expressed
in a XML file that obeys the core Ehcache schema.
Instances of this class are not thread-safe.
| Modifier and Type | Class and Description |
|---|---|
static interface |
XmlConfiguration.Template |
| Modifier and Type | Field and Description |
|---|---|
static java.net.URL |
CORE_SCHEMA_URL |
| Constructor and Description |
|---|
XmlConfiguration(org.ehcache.config.Configuration configuration)
Constructs an instance of XmlConfiguration from an existing configuration object.
|
XmlConfiguration(org.w3c.dom.Document xml)
Constructs an instance of XmlConfiguration from the given XML DOM.
|
XmlConfiguration(org.w3c.dom.Document xml,
java.lang.ClassLoader classLoader)
Constructs an instance of XmlConfiguration from the given XML DOM and using the provided
classLoader to
load user types (e.g. |
XmlConfiguration(org.w3c.dom.Document xml,
java.lang.ClassLoader classLoader,
java.util.Map<java.lang.String,java.lang.ClassLoader> cacheClassLoaders)
Constructs an instance of XmlConfiguration from the given XML DOM and using the provided
classLoader to
load user types (e.g. |
XmlConfiguration(java.net.URL url)
Constructs an instance of XmlConfiguration mapping to the XML file located at
url. |
XmlConfiguration(java.net.URL url,
java.lang.ClassLoader classLoader)
Constructs an instance of XmlConfiguration mapping to the XML file located at
url and using the provided
classLoader to load user types (e.g. |
XmlConfiguration(java.net.URL url,
java.lang.ClassLoader classLoader,
java.util.Map<java.lang.String,java.lang.ClassLoader> cacheClassLoaders)
Constructs an instance of XmlConfiguration mapping to the XML file located at
url and using the provided
classLoader to load user types (e.g. |
| Modifier and Type | Method and Description |
|---|---|
org.w3c.dom.Document |
asDocument()
Return this configuration as an XML
Document. |
java.lang.String |
asRenderedDocument()
Return this configuration as a rendered XML string.
|
org.ehcache.config.FluentConfigurationBuilder<?> |
derive() |
java.util.Map<java.lang.String,org.ehcache.config.CacheConfiguration<?,?>> |
getCacheConfigurations() |
static java.lang.Class<?> |
getClassForName(java.lang.String name,
java.lang.ClassLoader classLoader) |
java.lang.ClassLoader |
getClassLoader() |
java.util.Collection<org.ehcache.spi.service.ServiceCreationConfiguration<?,?>> |
getServiceCreationConfigurations() |
java.net.URL |
getURL()
Exposes the URL where the XML file parsed or yet to be parsed was or will be sourced from.
|
<K,V> org.ehcache.config.builders.CacheConfigurationBuilder<K,V> |
newCacheConfigurationBuilderFromTemplate(java.lang.String name,
java.lang.Class<K> keyType,
java.lang.Class<V> valueType)
Creates a new
CacheConfigurationBuilder seeded with the cache-template configuration
by the given name in the parsed XML configuration. |
<K,V> org.ehcache.config.builders.CacheConfigurationBuilder<K,V> |
newCacheConfigurationBuilderFromTemplate(java.lang.String name,
java.lang.Class<K> keyType,
java.lang.Class<V> valueType,
org.ehcache.config.Builder<? extends org.ehcache.config.ResourcePools> resourcePoolsBuilder)
Creates a new
CacheConfigurationBuilder seeded with the cache-template configuration
by the given name in the parsed XML configuration. |
<K,V> org.ehcache.config.builders.CacheConfigurationBuilder<K,V> |
newCacheConfigurationBuilderFromTemplate(java.lang.String name,
java.lang.Class<K> keyType,
java.lang.Class<V> valueType,
org.ehcache.config.ResourcePools resourcePools)
Creates a new
CacheConfigurationBuilder seeded with the cache-template configuration
by the given name in the parsed XML configuration. |
java.lang.String |
toString() |
public XmlConfiguration(java.net.URL url)
throws org.ehcache.xml.exceptions.XmlConfigurationException
url.
The default ClassLoader will first try to use the thread context class loader, followed by the ClassLoader that loaded the Ehcache classes.
url - URL pointing to the XML file's locationorg.ehcache.xml.exceptions.XmlConfigurationException - if anything went wrong parsing the XMLpublic XmlConfiguration(java.net.URL url,
java.lang.ClassLoader classLoader)
throws org.ehcache.xml.exceptions.XmlConfigurationException
url and using the provided
classLoader to load user types (e.g. key and value Class instances).url - URL pointing to the XML file's locationclassLoader - ClassLoader to use to load user types.org.ehcache.xml.exceptions.XmlConfigurationException - if anything went wrong parsing the XMLpublic XmlConfiguration(java.net.URL url,
java.lang.ClassLoader classLoader,
java.util.Map<java.lang.String,java.lang.ClassLoader> cacheClassLoaders)
throws org.ehcache.xml.exceptions.XmlConfigurationException
url and using the provided
classLoader to load user types (e.g. key and value Class instances). The cacheClassLoaders will
let you specify a different ClassLoader to use for each Cache managed by
the CacheManager configured using this XmlConfiguration. Caches with
aliases that do not appear in the map will use classLoader as a default.url - URL pointing to the XML file's locationclassLoader - ClassLoader to use to load user types.cacheClassLoaders - the map with mappings between cache names and the corresponding class loadersorg.ehcache.xml.exceptions.XmlConfigurationException - if anything went wrong parsing the XMLpublic XmlConfiguration(org.w3c.dom.Document xml)
throws org.ehcache.xml.exceptions.XmlConfigurationException
The default ClassLoader will first try to use the thread context class loader, followed by the ClassLoader that loaded the Ehcache classes.
xml - XML Document Object Modelorg.ehcache.xml.exceptions.XmlConfigurationException - if anything went wrong parsing the XMLpublic XmlConfiguration(org.w3c.dom.Document xml,
java.lang.ClassLoader classLoader)
throws org.ehcache.xml.exceptions.XmlConfigurationException
classLoader to
load user types (e.g. key and value Class instances).xml - XML Document Object ModelclassLoader - ClassLoader to use to load user types.org.ehcache.xml.exceptions.XmlConfigurationException - if anything went wrong parsing the XMLpublic XmlConfiguration(org.w3c.dom.Document xml,
java.lang.ClassLoader classLoader,
java.util.Map<java.lang.String,java.lang.ClassLoader> cacheClassLoaders)
throws org.ehcache.xml.exceptions.XmlConfigurationException
classLoader to
load user types (e.g. key and value Class instances). The cacheClassLoaders will let you specify a
different ClassLoader to use for each Cache managed by the
CacheManager configured using this XmlConfiguration. Caches with
aliases that do not appear in the map will use classLoader as a default.xml - XML Document Object ModelclassLoader - ClassLoader to use to load user types.cacheClassLoaders - the map with mappings between cache names and the corresponding class loadersorg.ehcache.xml.exceptions.XmlConfigurationException - if anything went wrong parsing the XMLpublic XmlConfiguration(org.ehcache.config.Configuration configuration)
throws org.ehcache.xml.exceptions.XmlConfigurationException
configuration - existing configurationorg.ehcache.xml.exceptions.XmlConfigurationException - if anything went wrong converting to XMLpublic org.w3c.dom.Document asDocument()
Document.public java.lang.String asRenderedDocument()
public java.lang.String toString()
toString in class java.lang.Objectpublic java.net.URL getURL()
public <K,V> org.ehcache.config.builders.CacheConfigurationBuilder<K,V> newCacheConfigurationBuilderFromTemplate(java.lang.String name,
java.lang.Class<K> keyType,
java.lang.Class<V> valueType)
throws java.lang.InstantiationException,
java.lang.IllegalAccessException,
java.lang.ClassNotFoundException
CacheConfigurationBuilder seeded with the cache-template configuration
by the given name in the parsed XML configuration.
Note that this version does not specify resources, which are mandatory to create a
CacheConfigurationBuilder. So if the template does not define resources, this will throw.
K - type of keysV - type of valuesname - the unique name identifying the cache-template element in the XMLkeyType - the type of keys for the CacheConfigurationBuilder to use, must
match the key-type declared in the template if declared in XMLvalueType - the type of values for the CacheConfigurationBuilder to use, must
match the value-type declared in the template if declared in XMLCacheConfigurationBuilder
or null if no cache-template for the provided namejava.lang.IllegalStateException - if the template does not configure resources.java.lang.IllegalArgumentException - if keyType or valueType don't match the declared type(s) of the templatejava.lang.ClassNotFoundException - if a Class declared in the XML couldn't be foundjava.lang.InstantiationException - if a user provided Class couldn't get instantiatedjava.lang.IllegalAccessException - if a method (including constructor) couldn't be invoked on a user provided typepublic <K,V> org.ehcache.config.builders.CacheConfigurationBuilder<K,V> newCacheConfigurationBuilderFromTemplate(java.lang.String name,
java.lang.Class<K> keyType,
java.lang.Class<V> valueType,
org.ehcache.config.ResourcePools resourcePools)
throws java.lang.InstantiationException,
java.lang.IllegalAccessException,
java.lang.ClassNotFoundException
CacheConfigurationBuilder seeded with the cache-template configuration
by the given name in the parsed XML configuration.K - type of keysV - type of valuesname - the unique name identifying the cache-template element in the XMLkeyType - the type of keys for the CacheConfigurationBuilder to use, must
match the key-type declared in the template if declared in XMLvalueType - the type of values for the CacheConfigurationBuilder to use, must
match the value-type declared in the template if declared in XMLresourcePools - Resources definitions that will be usedCacheConfigurationBuilder
or null if no cache-template for the provided namejava.lang.IllegalArgumentException - if keyType or valueType don't match the declared type(s) of the templatejava.lang.ClassNotFoundException - if a Class declared in the XML couldn't be foundjava.lang.InstantiationException - if a user provided Class couldn't get instantiatedjava.lang.IllegalAccessException - if a method (including constructor) couldn't be invoked on a user provided typepublic <K,V> org.ehcache.config.builders.CacheConfigurationBuilder<K,V> newCacheConfigurationBuilderFromTemplate(java.lang.String name,
java.lang.Class<K> keyType,
java.lang.Class<V> valueType,
org.ehcache.config.Builder<? extends org.ehcache.config.ResourcePools> resourcePoolsBuilder)
throws java.lang.InstantiationException,
java.lang.IllegalAccessException,
java.lang.ClassNotFoundException
CacheConfigurationBuilder seeded with the cache-template configuration
by the given name in the parsed XML configuration.K - type of keysV - type of valuesname - the unique name identifying the cache-template element in the XMLkeyType - the type of keys for the CacheConfigurationBuilder to use, must
match the key-type declared in the template if declared in XMLvalueType - the type of values for the CacheConfigurationBuilder to use, must
match the value-type declared in the template if declared in XMLresourcePoolsBuilder - Resources definitions that will be usedCacheConfigurationBuilder
or null if no cache-template for the provided namejava.lang.IllegalArgumentException - if keyType or valueType don't match the declared type(s) of the templatejava.lang.ClassNotFoundException - if a Class declared in the XML couldn't be foundjava.lang.InstantiationException - if a user provided Class couldn't get instantiatedjava.lang.IllegalAccessException - if a method (including constructor) couldn't be invoked on a user provided typepublic java.util.Map<java.lang.String,org.ehcache.config.CacheConfiguration<?,?>> getCacheConfigurations()
getCacheConfigurations in interface org.ehcache.config.Configurationpublic java.util.Collection<org.ehcache.spi.service.ServiceCreationConfiguration<?,?>> getServiceCreationConfigurations()
getServiceCreationConfigurations in interface org.ehcache.config.Configurationpublic java.lang.ClassLoader getClassLoader()
getClassLoader in interface org.ehcache.config.Configurationpublic org.ehcache.config.FluentConfigurationBuilder<?> derive()
derive in interface org.ehcache.config.Configurationpublic static java.lang.Class<?> getClassForName(java.lang.String name,
java.lang.ClassLoader classLoader)
throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException