The reason is that in both methods (populateCache and displayCacheContents)
you're creating a new cache instance. And if these instances are not
configured to be clustered, they won't see state in each other.
Bruce's case probably worked since when you retrieve the cache from an MBean
server rather than create a new one each tme, both cases use the same cache.
So what you want is probably something like this:
|
| private PojoCache pojoCache;
|
| private void createCache() {
| pojoCache = PojoCacheFactory.createCache("META-INF/service.xml", true);
| }
|
|
| private void populateCache() {
| Person person = new Person("Chris","Harris",32);
| pojoCache.attach("/cachedobjects/person", person);
| Person dummyPerson = (Person)pojoCache.find("/cachedobjects/person");
| log.info("Name = " + dummyPerson.getName());
| }
|
| private void displayCacheContents() {
| Person person = (Person)pojoCache.find("/cachedobjects/person");
| log.info("Name = " + person.getName());
| }
|
| public static void main(String args[]) {
| MyApp app = new MyApp();
| myApp.createCache();
| myApp.populateCache();
| myApp.displayCacheContents();
| }
|
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4091877#4091877
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4091877
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user