1 Reply Latest reply on Nov 28, 2006 9:17 AM by Jerry Gauthier

    TreeCacheMBean and TreeCache references

    John O'Grady Newbie

      I've been through the forums, wiki, and google, so at last I'm forced to post.

      We're setting up a treecache where nodes are created, each with it's own expiration date. Each of these nodes will be leaf-nodes, so there's no problem with expiring a node that has children that aren't ready to expire yet.

      There are a few things I've come up against, though, that are giving me headaches with JBoss Cache. The first is that if I create an MBean as in the examples, then that leaves me with no way to get a reference programmatically to the actual TreeCache instance object. I'm looking for that in order to get to the "org.jboss.cache.eviction.RegionManager", so when we add a new node, we can dynamically set its eviction policy.

      I've been pointed again and again to this little gem in the TreeCache documentation in section 6.2:

      // note this is just to show that a running TreeCache instance must be
      // retrieved somehow. How it is implemented is up to the implementer.
      TreeCache cache = getRunningTreeCacheInstance();

      ...which of course doesn't solve anything because I've yet to find one example anywhere on this site of an implementation of whatever magical code would be behind the "getRunningTreeCacheInstance();" method from an MBean setup.

      My other question would be whether or not we can actually do dynamic eviction policies - in other words, set the eviction policy for each node as they are added. Even better would be a way to tell the cache to key the eviction policy off a specifically named attribute of the nodes if it should exist (new feature request?). This would solve multiple problems at once and allow for some nice optimisation under the covers.