org.ehcache.config.xml
Class XmlConfiguration

java.lang.Object
  extended by org.ehcache.config.xml.XmlConfiguration
All Implemented Interfaces:
Configuration

public class XmlConfiguration
extends java.lang.Object
implements Configuration

Exposes Configuration and CacheConfigurationBuilder expressed in a XML file that obeys the ehcache-core.xsd (todo link this to proper location, wherever this ends up being)

Instances of this class are not thread-safe


Constructor Summary
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.
 
Method Summary
 java.util.Map<java.lang.String,CacheConfiguration<?,?>> getCacheConfigurations()
          Mapping of names to CacheConfiguration, used to create the named Cache managed by a CacheManager
 java.lang.ClassLoader getClassLoader()
          The ClassLoader to be associated with the CacheManager
 java.util.Collection<ServiceCreationConfiguration<?>> getServiceCreationConfigurations()
          All services initially used to bootstrap the CacheManager and its Cache instances
 java.net.URL getURL()
          Exposes the URL where the XML file parsed or yet to be parsed was or will be sourced from.
 CacheConfigurationBuilder<java.lang.Object,java.lang.Object> newCacheConfigurationBuilderFromTemplate(java.lang.String name)
          Creates a new CacheConfigurationBuilder seeded with the cache-template configuration by the given name in the XML configuration parsed using parseConfiguration()
<K,V> 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 XML configuration parsed using parseConfiguration()
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlConfiguration

public XmlConfiguration(java.net.URL url)
                 throws java.lang.ClassNotFoundException,
                        org.xml.sax.SAXException,
                        java.lang.InstantiationException,
                        java.lang.IllegalAccessException,
                        java.io.IOException
Constructs an instance of XmlConfiguration mapping to the XML file located at url

Parses the XML file at the url provided.

Parameters:
url - URL pointing to the XML file's location
Throws:
java.io.IOException - if anything went wrong accessing the URL
org.xml.sax.SAXException - if anything went wrong parsing or validating the XML
java.lang.ClassNotFoundException - if a Class declared in the XML couldn't be found
java.lang.InstantiationException - if a user provided Class couldn't get instantiated
java.lang.IllegalAccessException - if a method (including constructor) couldn't be invoked on a user provided type

XmlConfiguration

public XmlConfiguration(java.net.URL url,
                        java.lang.ClassLoader classLoader)
                 throws java.lang.ClassNotFoundException,
                        org.xml.sax.SAXException,
                        java.lang.InstantiationException,
                        java.io.IOException,
                        java.lang.IllegalAccessException
Constructs an instance of XmlConfiguration mapping to the XML file located at url and using the provided classLoader to load user types (e.g. key and value Class instances).

Parses the XML file at the url provided.

Parameters:
url - URL pointing to the XML file's location
classLoader - ClassLoader to use to load user types.
Throws:
java.io.IOException - if anything went wrong accessing the URL
org.xml.sax.SAXException - if anything went wrong parsing or validating the XML
java.lang.ClassNotFoundException - if a Class declared in the XML couldn't be found
java.lang.InstantiationException - if a user provided Class couldn't get instantiated
java.lang.IllegalAccessException - if a method (including constructor) couldn't be invoked on a user provided type

XmlConfiguration

public XmlConfiguration(java.net.URL url,
                        java.lang.ClassLoader classLoader,
                        java.util.Map<java.lang.String,java.lang.ClassLoader> cacheClassLoaders)
                 throws java.lang.ClassNotFoundException,
                        org.xml.sax.SAXException,
                        java.lang.InstantiationException,
                        java.lang.IllegalAccessException,
                        java.io.IOException
Constructs an instance of XmlConfiguration mapping to the XML file located at 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

Parses the XML file at the url provided.

Parameters:
url - URL pointing to the XML file's location
classLoader - ClassLoader to use to load user types.
cacheClassLoaders - the map with mappings between cache names and the corresponding class loaders
Throws:
java.io.IOException - if anything went wrong accessing the URL
org.xml.sax.SAXException - if anything went wrong parsing or validating the XML
java.lang.ClassNotFoundException - if a Class declared in the XML couldn't be found
java.lang.InstantiationException - if a user provided Class couldn't get instantiated
java.lang.IllegalAccessException - if a method (including constructor) couldn't be invoked on a user provided type
Method Detail

getURL

public java.net.URL getURL()
Exposes the URL where the XML file parsed or yet to be parsed was or will be sourced from.

Returns:
The URL provided at object instantiation

newCacheConfigurationBuilderFromTemplate

public CacheConfigurationBuilder<java.lang.Object,java.lang.Object> newCacheConfigurationBuilderFromTemplate(java.lang.String name)
                                                                                                      throws java.lang.InstantiationException,
                                                                                                             java.lang.IllegalAccessException,
                                                                                                             java.lang.ClassNotFoundException
Creates a new CacheConfigurationBuilder seeded with the cache-template configuration by the given name in the XML configuration parsed using parseConfiguration()

Parameters:
name - the unique name identifying the cache-template element in the XML
Returns:
the preconfigured CacheConfigurationBuilder or null if no cache-template for the provided name
Throws:
java.lang.ClassNotFoundException - if a Class declared in the XML couldn't be found
java.lang.InstantiationException - if a user provided Class couldn't get instantiated
java.lang.IllegalAccessException - if a method (including constructor) couldn't be invoked on a user provided type

newCacheConfigurationBuilderFromTemplate

public <K,V> 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
Creates a new CacheConfigurationBuilder seeded with the cache-template configuration by the given name in the XML configuration parsed using parseConfiguration()

Type Parameters:
K - type of keys
V - type of values
Parameters:
name - the unique name identifying the cache-template element in the XML
keyType - the type of keys for the CacheConfigurationBuilder to use, would need to match the key-type declared in the template if declared in XML
valueType - the type of values for the CacheConfigurationBuilder to use, would need to match the value-type declared in the template if declared in XML
Returns:
the preconfigured CacheConfigurationBuilder or null if no cache-template for the provided name
Throws:
java.lang.IllegalStateException - if parseConfiguration() hasn't yet been successfully invoked
java.lang.IllegalArgumentException - if keyType or valueType don't match the declared type(s) of the template
java.lang.ClassNotFoundException - if a Class declared in the XML couldn't be found
java.lang.InstantiationException - if a user provided Class couldn't get instantiated
java.lang.IllegalAccessException - if a method (including constructor) couldn't be invoked on a user provided type

getCacheConfigurations

public java.util.Map<java.lang.String,CacheConfiguration<?,?>> getCacheConfigurations()
Description copied from interface: Configuration
Mapping of names to CacheConfiguration, used to create the named Cache managed by a CacheManager

Specified by:
getCacheConfigurations in interface Configuration
Returns:
the map of names to configs

getServiceCreationConfigurations

public java.util.Collection<ServiceCreationConfiguration<?>> getServiceCreationConfigurations()
Description copied from interface: Configuration
All services initially used to bootstrap the CacheManager and its Cache instances

Specified by:
getServiceCreationConfigurations in interface Configuration
Returns:
the collection of said configs

getClassLoader

public java.lang.ClassLoader getClassLoader()
Description copied from interface: Configuration
The ClassLoader to be associated with the CacheManager

Specified by:
getClassLoader in interface Configuration
Returns:
The classloader