[jboss-user] [JBossCache] - Re: JBoss Cache run from within an application WAR file...
carlabramsson
do-not-reply at jboss.com
Tue Aug 15 11:42:48 EDT 2006
Hi John!
Simply put a config-file in the root of your classpath (web-inf/classes for example) and then write a wrapper (singleton) around the the TreeCache that starts the cache.
Code to init the cache. You could call this block from a ContextListener in you webbapp.
| try {
| cache = new TreeCache();
| } catch (Exception e) {
| throw new Exception("Could not create cache!",e);
| }
| PropertyConfigurator config = new PropertyConfigurator(); // configure tree cache. Needs to be in the classpath
| try {
| config.configure(cache, "my-treecache-config.xml");
| } catch (ConfigureException e) {
| throw new Exception("Could not configure cache!",e);
| }
|
| try {
| cache.startService();
| } catch (Exception e) {
| throw new Exception("Could not start cache!",e);
| }
|
Then create whatever put-, get-, remove-methods you need in the wrapper.
The treecache instance will register itself and can be found in your jmx-console.
Hope this helps!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3965302#3965302
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3965302
More information about the jboss-user
mailing list