spring - Is it possible to Split an ehcache config file? -
i'm writing jar intended used spring , ehcache. spring requires there cache defined each element, planning have ehcache defined jar, preferably resource in jar imported primary ehcache configuration app. however, reading of example ehcache config file , google searches have not turned way import sub ehcache config file.
is there way import sub ehcache config file, or there other way solve problem?
what did similar (replace placeholders in ehcache xml file - import statement more or less placeholder if will) extend (more or less copy honest) springs ehcachemanagerfactorybean
, create final ehcache xml config file on fly.
for creating cachemanager
instance in afterpropertiesset()
hand on inputstream
points config.
@override public void afterpropertiesset() throws ioexception, cacheexception { if (this.configlocation != null) { inputstreamsource finalconfig = new yourresourcewrapper(this.configlocation); // put custom logic here inputstream = finalconfig.getinputstream(); try { this.cachemanager = (this.shared ? cachemanager.create(is) : new cachemanager(is)); } { ioutils.closequietly(is); } } else { // ... } // ... }
for filtering stuff internally used bytearrayresource
keep final config.
data = ioutils.tostring(source.getinputstream()); // original config (configlocation) string // string manipulation here resource finalconfigresource = new bytearrayresource(data.getbytes());
for "real" templating 1 think of using real template engine freemarker (which spring has support for) more fancy stuff.
Comments
Post a Comment