Product Documentation : Ehcache Developer Guide : Basic Caching : Loading a Configuration
Loading a Configuration
When a CacheManager is created, it creates caches found in a provided configuration.
The following creates a CacheManager based on the configuration defined in the ehcache.xml file in the classpath.
CacheManager manager = CacheManager.newInstance();
The following creates a CacheManager based on a specified configuration file.
CacheManager manager = CacheManager.newInstance("src/config/ehcache.xml");
The following creates a CacheManager from a configuration resource in the classpath.
URL url = getClass().getResource("/anotherconfigurationname.xml");
CacheManager manager = CacheManager.newInstance(url);
The following creates a CacheManager from a configuration in an InputStream.
InputStream fis = new FileInputStream(new File
("src/config/ehcache.xml").getAbsolutePath());
try {
CacheManager manager = CacheManager.newInstance(fis);
} finally {
fis.close();
}
Copyright © 2010-2017 Software AG, Darmstadt, Germany.

Product Logo |   Feedback