Top Description Fields Constructors Methods
net.sf.ehcache.config

public final Class ConfigurationFactory

extends Object
Class Inheritance
Imports
net.sf.ehcache.CacheException, net.sf.ehcache.util.ClassLoaderUtil, javax.xml.parsers.SAXParser, .SAXParserFactory, java.io.BufferedInputStream, .ByteArrayInputStream, .File, .FileInputStream, .IOException, .InputStream, .InputStreamReader, .Reader, .StringReader, java.net.URL, java.util.HashSet, .Set, org.slf4j.Logger, .LoggerFactory, org.xml.sax.InputSource, java.util.regex.Matcher, .Pattern, net.sf.ehcache.config.generator.ConfigurationSource

A utility class which configures beans from XML, using reflection.
Author
Greg Luck
Version
$Id: ConfigurationFactory.java 10789 2018-04-26 02:08:13Z adahanne $

Field Summary

Modifier and TypeField and Description
private static final String
private static final String
private static final Logger

Constructor Summary

AccessConstructor and Description
private
ConfigurationFactory()

Constructor.

Method Summary

Modifier and TypeMethod and Description
pack-priv static Set<E>

Returns:

a Set of properties. So, duplicates are only counted once.
extractPropertyTokens
(String
the source document
sourceDocument
)

Extracts properties of the form ${...}

public static CacheConfiguration
parseCacheConfiguration(String xmlString)

Configures a cache bean from a string of XML.

public static Configuration
parseConfiguration(final File file)

Configures a bean from an XML file.

public static Configuration
parseConfiguration(final URL url)

Configures a bean from an XML file available as an URL.

public static Configuration
parseConfiguration()

Configures a bean from an XML file in the classpath.

public static Configuration
parseConfiguration(final InputStream inputStream)

Configures a bean from an XML input stream.

private static InputStream

Returns:

a translated stream
translateSystemProperties
(InputStream inputStream)

Translates system properties which can be added as tokens to the config file using ${token} syntax.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_CLASSPATH_CONFIGURATION_FILEback to summary
private static final String DEFAULT_CLASSPATH_CONFIGURATION_FILE
FAILSAFE_CLASSPATH_CONFIGURATION_FILEback to summary
private static final String FAILSAFE_CLASSPATH_CONFIGURATION_FILE
LOGback to summary
private static final Logger LOG

Constructor Detail

ConfigurationFactoryback to summary
private ConfigurationFactory()

Constructor.

Method Detail

extractPropertyTokensback to summary
pack-priv static Set<E> extractPropertyTokens(String sourceDocument)

Extracts properties of the form ${...}

Parameters
sourceDocument:String

the source document

Returns:Set<E>

a Set of properties. So, duplicates are only counted once.

parseCacheConfigurationback to summary
public static CacheConfiguration parseCacheConfiguration(String xmlString) throws CacheException

Configures a cache bean from a string of XML.

parseConfigurationback to summary
public static Configuration parseConfiguration(final File file) throws CacheException

Configures a bean from an XML file.

parseConfigurationback to summary
public static Configuration parseConfiguration(final URL url) throws CacheException

Configures a bean from an XML file available as an URL.

parseConfigurationback to summary
public static Configuration parseConfiguration() throws CacheException

Configures a bean from an XML file in the classpath.

parseConfigurationback to summary
public static Configuration parseConfiguration(final InputStream inputStream) throws CacheException

Configures a bean from an XML input stream.

translateSystemPropertiesback to summary
private static InputStream translateSystemProperties(InputStream inputStream) throws IOException

Translates system properties which can be added as tokens to the config file using ${token} syntax.

So, if the config file contains a character sequence "multicastGroupAddress=${multicastAddress}", and there is a system property multicastAddress=230.0.0.12 then the translated sequence becomes "multicastGroupAddress=230.0.0.12"

Returns:InputStream

a translated stream