在 EJB 远程接口中使用缓存
我有一个部署在 Glassfish 服务器上的应用程序,远程调用该应用程序的方法(使用标准 JNDI 和 RMI over IIOP 功能)。我想在客户端上安装一些缓存功能,以避免多次网络调用并优化应用程序行为。
那么,我怎样才能拥有一个缓存功能,最佳情况下,
- 我声明可以使用接口上的注释来缓存哪些远程接口调用,
- 所有缓存都是透明处理的
。可选地,我必须提到我的客户端应用程序使用 Weld 使用远程 EJB 实例,它可以选择性地用于拦截 EJB 方法调用。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
其中一种选择是在客户端使用 ServiceLocator 模式,它封装了缓存行为。缓存存根类,JNDI 查找后收到的内容。稍后您可以重新使用它。它可以避免额外的 JNDI 调用。
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.
看起来,从 JCache JSR 开始,大多数开源缓存“供应商” 今天提供一些准标准化的缓存注释:
仅此而已。
根据我当前的堆栈,(目前)最好的选择可能是 Infinispan,因为 ehcache 实现被标记为“实验性”并随着规范的发展而发展。
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.