简体   繁体   English

为Java / WebLogic Web Services创建特定于应用程序实例的缓存

[英]Creating an application instance specific cache for Java/WebLogic Web Services

I'm new to both J2EE and WebLogic. 我是J2EE和WebLogic的新手。 I'd trying to determine the best way to implement a non-distributed cache (one cache per application instance) in a Java Web Services application running on WebLogic 10.3. 我试图确定在WebLogic 10.3上运行的Java Web Services应用程序中实现非分布式缓存(每个应用程序实例一个缓存)的最佳方法。 I need to cache several different POJO's. 我需要缓存几个不同的POJO。

There will be multiple WebLogic instances running on each server in a cluster. 群集中的每台服务器上都将运行多个WebLogic实例。 When reading about ServletContext and InitialContext, I was a bit confused. 在阅读有关ServletContext和InitialContext的内容时,我有些困惑。 I believe ServletContext is instance specific, but I can only access it from a Servlet, correct? 我相信ServletContext是特定于实例的,但是我只能从Servlet访问它,对吗? I will need to access to the cache in separate threads so I'm not sure if this is possible outside of a Servlet. 我将需要在单独的线程中访问缓存,因此我不确定在Servlet之外是否可以实现。

I was reading a bit about JNDI, but it seems to work at the server or cluster level and not for each WebLogic/application instance. 我在阅读有关JNDI的文章,但它似乎可以在服务器或群集级别上运行,而不是适用于每个WebLogic /应用程序实例。

Can anyone provide me with a suggestion and a code example to initialize, access, and destroy a cache of Java POJO's? 谁能为我提供建议和代码示例,以初始化,访问和销毁Java POJO的缓存?

Thanks! 谢谢!

Leon 里昂

Here is an example on how to implement a method cache with Spring and EHCache: http://opensource.atlassian.com/confluence/spring/display/DISC/Caching+the+result+of+methods+using+Spring+and+EHCache The cache will be local if configured as in the example. 以下是有关如何使用Spring和EHCache实现方法缓存的示例: http : //opensource.atlassian.com/confluence/spring/display/DISC/Caching+the+result+of+methods+using+Spring+and+ EHCache如果按照示例配置,则缓存将是本地的。

I am using this method in a web service client library to cache the results of a frequently used service that has nearly no update to its data. 我在Web服务客户端库中使用此方法来缓存经常使用的服务的结果,而该服务的数据几乎没有更新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM