1
votes

I have an application that is deployed on a Glassfish server, for which methods are invoked remotely (using standard JNDI and RMI over IIOP features). I would like to install some caching features on client, to avoid both multiple network calls and optimize application behaviour.

So, how could I have a caching feature for which, optimaly,

  • I declare what remote interface calls can be cached using an annotation on interface
  • all the caching is handled transparently

Optionnally, I must mention my client app gets used remote EJB instances using Weld, which can optionally be used to intercept EJB method calls.

2
I worked on exactly this problem back in 1998 (without annotations, interceptors, or CDI). I don't think we ever came up with a good solution! - Tom Anderson
Well, seems like javax.cache is a good starting point. (the blog entry even mention how to introduce that cache in a Weld application). - Riduidel
@Riduidel javax.cache will be introduced in Java EE 7 - yatskevich
@yatskevich, Yes, but like any java JSR, it can be used with older versions (in my case JavaEE6). According to blog entry i previously mentionned, JavaEE6 includes all i need to have an available cache manager in my code, so i think i will go that way. - Riduidel

2 Answers

1
votes

One of the options is to use ServiceLocator pattern on client, which encapsulate caching behaviour. Cache stub class, what you receive after JNDI lookup. And later you can resuse it. It allow to avoid additional JNDI calls.

0
votes

It seems like, starting together with JCache JSR, most open-source cache "vendors" today provide some quasi-standardized caching annotations :

And that's all. According to my current stack, best choice (for now) could be Infinispan as ehcache implementation is marked as "experimental" and evolving with the spec.