[jboss-user] [JBossCache] - Re: JBossCache with Hibernate on Glassfish v2

eric.hubert do-not-reply at jboss.com
Wed Nov 21 06:56:33 EST 2007


"genman" wrote : 
  | I don't personally have a problem with wanting to know about these things 
  | 
With due respect I wouldn't care much about you having those problems. ;)

I read through the official JBoss Cache documentation as well as some outdated wiki entries which did help me to get a starting point but which were not sufficient to solve my problems in a timely manner. That's why I kindly asked for some help and pointers into the right direction.
Nobody can really be sure that he hadn't overseen some "obvious" source of information. At least that's what I thought might be the case. Ideally one only had to pick a couple of libraries (jbosscache.jar) as well as a very few dependencies and change some configuration properties to use JBossCache on a specific application server. That's exactly the information I was looking for. I see inspecting the source of an open source project I would like to use as a kind of last resort, as this may require a tremendous effort. You can't be sure beforehand.

That doesn't mean that I'm not willing to do so if there is no other way. Of course I'm also happy to provide my findings for later reuse. Personally I don't see anything wrong with this approach. But back to topic!

So in this case I ended up inspecting the source of JBoss AS and JBoss Cache 2.0. I started with Hibernate's CacheProvider interface following it's concrete implementations of TreeCacheProviderHook as well as DeployedTreeCacheProvider. 
In JBoss AS the Cache is wrapped in a MBean which is registered with the MBeanServer. In recent code the actual mbean server lookup was moved from concrete CacheProvider to a TransactionCacheFactory. Since JBoss Cache 2.0 this is JBCCacheFactory. It is responsible for connecting with the MBeanServer, retrieving an MBeanProxy of the Cache (in this case CacheJmxWrapperBean), read the caches configuration and evaluate the locking strategie and build the Cache appropriately.
I'm not quite sure if I can oversee anything from my first glance at the code, but the only obvious thing which is application server dependent is the way the MBeanServer is located. Unfortunately there was no standard way of doing this before JSE 5.0. Since then the preferred way is by using java.lang.management.ManagementFactory.getPlatformMBeanServer().
JBoss uses a utility class MBeanServerLocator to retrieve it's MBeanServer.

So at the moment I have to think about how to solve my problem best. I could write my own implementation of the CacheProvider interface. But would that be clever? It seems to be a good idea to also use the underlying logic of the CacheFactory.

If I got it right I had to register the CacheJmxWrapperBean with Glassfish's MBean-Server and change the way how the MBeanServer is located. Seems pretty simple, If that would be all. Well, I guess I'll see.
It might be a good idea to make the MBeanLookup-Code exchangeable.

Unfortunately at the moment I have no time to experiment on the code level. I will take some time at the weekend. If one of you had any further suggestions it will be more than welcome. :-)

Isolating issues in a non container environment is generally a good idea, but it doesn't seem practical for me in this special case. On the one hand I have a full blown JEE application and on the other hand my problems are not related to the cache and it's configuration but to container integration. Anyhow, genman, I thank you for your suggestions and pointers. Any assistance is greatly appreciated.

Regards,
   Eric

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4106705#4106705

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4106705



More information about the jboss-user mailing list