We're running a Stateless Session Bean to retrieve some data from various locations.
What's the best way to achieve caching for this SLSB ?
Using interceptors ? Using JBossCache ?
We're using JBoss 5.0.1.
Technically, you are allowed to retain state in a stateless session bean, it's just that the state may be cleared by the container between invocations. As as result, you should not keep the cache itself in the bean, since it may just vanish.
Since you're using JBoss Appserver already, JBossCache would seem like the clear winner here. You can configure JBossCache instances using jboss service descriptors, and your EJB can then look up the cache instance from JMX/JNDI. It's all included in JBossAS already, so no additional dependencies needed.
Using JBossCache also gives you the added bonus of a cache distributed across a cluster, if that's something of interest to you.