在J2EE服务器中的两个不同应用程序之间匹配两个对象实例的最佳方法是什么? [英] What would be the best way to match up two object instances between two different applications in a J2EE server?

查看:113
本文介绍了在J2EE服务器中的两个不同应用程序之间匹配两个对象实例的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个J2ee应用程序,我基本上希望两个单独的servlet创建的两个对象可以直接通信,并且我需要这些实例保持稳定,即在会话期间彼此了解。

I have a J2ee application where I basically want two objects, created by two separate servlets to communicate directly and I need these intances to be stable, i.e. to "know" each other during the session.

顺序大致为:

The sequence is roughly:


  1. 客户端向Servlet#1发送请求,Servlet 1创建对象A

  2. 客户端向第二个创建对象B的servlet#2发送第二个请求(在第一次返回之后)。

  3. 对象B使用JNDI找到A ,并且两个对象进行交互。

  4. 客户端现在继续向对象A发送请求,该对象A需要再次找到B。

  1. Client sends a request to Servlet #1, which creates object A
  2. Client sends a second request (after the first returns) to servlet #2 which creates object B.
  3. Object B finds A, using JNDI, and the two objects interact.
  4. The client now continues to send requests to object A which needs to find B again.

如何确保在整个会话过程中这两个实例相互了解?
将它们绑定到JNDI并不能完全解决问题,因为对象B需要与其原始servlet(servlet#2)进行通信,而该servlet在请求之间并不稳定。

How do I make sure that these two instances know each throughout the session? Binding them to JNDI doesn't entirely solve the problem, since object B needs to communicate with its original servlet (servlet #2), which is not kept stable across requests.

有什么想法吗?

预先感谢。

是的,我承认问题描述有点含糊。但这不是一个非常简单的应用程序。
不过,我会尝试更好地询问它:

Yes, I admit the problem description is a bit vague. But it's not a very simple application. Still, I will try to ask it better:

我的最终目标是为我的应用程序创建一种语义调试器,与之相反

My end goal is to create a sort of a "semantic debugger" for my application that, as opposed to a java debugger which simply debugs the java statements.

被调试的应用程序基本上是一个servlet。我的工具连接到哪个。
该工具通过另一个控制调试过程的servlet维护与应用程序的连接。
这两个servlet需要不断且直接地相互通信。

The application debugged is basically a servlet. which my tool connects to. The tool maintains a connection to the application through another servlet which controls the debugging process. These two servlets need to communicate with each other constantly and directly.

我目前的想法是建立一个有状态会话Bean,以促进这种通信(从不做到了,但仍在努力进行设置。)

My current thought is to set up a stateful session bean that will facilitate this communication (never done it, still struggling with setting it up).

但是,我希望您能对如何更好地实现这一点有任何想法。

But I would appreciate any thoughts on how to achieve this better.

推荐答案

什么使您无法使用Session?您不需要JNDI,只需将对象放入预定义名称的会话中即可。如果通信对象是应用程序范围的,请使用Singleton。

And what stops you from using the Session? You don't need JNDI, just place your object into session under a predefined name. If the communication object is application-wide, use Singleton.

P.S。在我看来,您做的事情很奇怪,而实际上解决方案可能更简单。您能描述任务而不是拟议的实施吗?反正什么是语义调试器?

P.S. It looks to me you're doing something weird, while the solution could in fact be simpler. Can you describe the task, not the proposed implementation? What is a "semantic debugger" anyway?

这篇关于在J2EE服务器中的两个不同应用程序之间匹配两个对象实例的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆