如何在 tomcat 7 中共享数据访问库?
我对整个网络编程相当陌生,并且遇到以下问题:
我有 2 个网络应用程序,一个是轴网络服务,另一个是 Spring 应用程序。两者都应该从包含内存中数据的库中获取一组数据。该数据很大,因此无法为每个应用程序复制数据。
到目前为止,我所做的是开发在静态容器中加载和包含数据的库。计划是,两个应用程序都实例化包含容器的类并可以访问数据。
遗憾的是,这行不通。我收到一个异常,我想要使用的对象位于不同的类加载器中。
我的问题是:如何为 tomcat 7 中的两个库提供这样的容器提供程序?
顺便说一句:数据库是没有选择的,因为它很慢。
编辑:我应该对数据很清楚。数据是存储在主题图引擎中的主题图。 (请参阅 http://www.isotopicmaps.org )。引擎用于访问数据,因此是数据的访问点。我们有一个自己的引擎,它将数据保存在内存中,比数据库后端更快。
我想要一个 servlet,它提供主题图的配置和加载,然后上面的两个 servlet 应该能够读取和修改主题图。这就是为什么我需要对引擎有一种共享访问点。
I'm fairly new to the whole web programming stuff and have the following problem:
I have 2 webapps, one a axis web service and another one is a spring application. Both should get a set of data from a library which contains the data in memory. This data is large so copying the data for each app is no option.
What I did so far is developing the library which loads and contains the data in a static container. The plan was, that both apps instatiate the class containing the container and may access the data.
Sadly, this doesn't work. I get an exception that the object I want to use are in different classloaders.
My question is: How can I provide such a container provider for both libraries in tomcat 7?
BTW: A database is no option, because its to slow.
Edit: I should have been clear about the data. The data is a Topic Map stored in an topic map engine. (see http://www.isotopicmaps.org ). The engine is used to access the data and therefore is the access point to the data. We have an own engine, which hold the data inmemory which is faster than a database backend.
I Want to have a servlet which provides the configuration and loading of topic maps and then the two servlets above should be able to read and modify a topic map. Thats why I need to have a sort of shared access point to the engine.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这就是分布式缓存、键值存储、文档存储和 noSql 数据库的构建目的。每天都有很多选择和新选择。免费和开源选项可能会满足您的需求,并为您提供所需的支持。目前我最喜欢的是 membase。
This is what distributed caches, key-value stores, document stores, and noSql databases are built for. There are many options and new ones each day. The free and open-source options are likely to meet your needs and provide you with as much support as you will needs. The one the is currently my favorite is membase.
因此,您需要为服务器集群提供分布式内存缓存。为此,您可以使用 Terracotta 等。您可以在此处找到有关 Terracotta 的精彩介绍。
更新:我实际上不同意数据库“太慢”的论点。如果速度很慢,那么数据模型和/或数据访问代码设计得很糟糕。
So you want a distributed in-memory cache for a server cluster. You can use among others Terracotta for this. You can find here a nice introduction to Terracotta.
Update: I actually disagree the argument that a database is "too slow". If it's slow, then the datamodel and/or data access code is simply badly designed.