为 Swing-JavaFX / RMI / EJB3.0 应用程序定义 java 架构的想法

发布于 2024-10-06 17:29:43 字数 1622 浏览 0 评论 0原文

问题

我们参与了一个新项目,该项目将使用多台 PC 来开发一个应用程序,这些 PC 将充当通用计算机。还有一台计算机会时不时地充当主机,以控制客户端的所有流程。该计算机必须通过服务器计算机向所有其他计算机发送消息,请求例如注册帮助。此时,客户端计算机中运行的进程必须获得计算机的控制权,并充当运行该应用程序的从属计算机,直到从主机发送新消息来释放它们为止。之后,客户端计算机再次充当通用计算机。

以下方案试图解释 CM(控制机)获得 SM 访问权限后会发生什么( Slave Machines)通过服务器(SRVR)

  1. 控制机CM发送消息以向服务器注册协助 2 SRVR 接收消息,记录一些信息并向 SM 广播注册协助消息 等待
  2. 消息的正在运行的 SM 进程获得每个 SM 中的完全控制
  3. 用户通过 SM 中的视图选择操作,机器发送一个消息对 SRVR 的响应
  4. SRVR 接收响应并将其广播到所有机器,包括结果机器 (RM),以使用服务器 (SRVR) 中的新状态更新视图
  5. CM 向 SRVR 发送结束注册消息。
  6. SRVR向所有SM广播该消息,应用程序视图关闭并且应用程序再次进入监听状态。

声明:

  • 一切都需要以某种 Java 技术完成
  • 所有机器都运行 GNU/Linux/Gnome (Ubuntu)
  • JPA 对于日志记录和持久性是强制性的
  • JavaFX 将根据 Oracle 进行更改因为他们正在考虑放弃脚本语言

问题是:

  1. 您会在视图中使用哪种 Java 技术组合?我的意见是使用 Swing,也许可以通过 SwingComponent.wrap(loginPanel) 将其嵌入到 FX 中,以帮助图形设计师完成更好的视觉工作(此应用程序中必须这样做)。请考虑绑定选项 JSR-295(据我所知现在已失效)或一些适当的替代方案。

  2. 您将如何维护应用程序客户端的更新,我的意见是通过 Java Web Start 并将其作为小程序提供服务。

  3. 如果SRVR使用带有EJB 3.0的Java EE来访问远程对象可以吗?如果是这样,您将如何将 EJB 与 RMI 集成/建模/集成。我对 RMI/EJB 集成没有丰富的经验,并且不太确定它是否正确。特别是因为 EJB 规范已经信任 RMI。但是如何从会话 Bean(据我所知是有状态的 Bean)广播消息来更新视图?

  4. 在 SM 中选择的任何选项都必须在注册为观察者的所有视图(其他 SM、RM 和 CM)中查看。您能为此建议一个模型/架构/产品吗?

  5. 一旦进程被唤醒,SM应用程序获得完全控制权的正确方法是什么? -记住,它是Linux-

  6. 如何在分布式环境中应用观察者模式?

  7. 此应用程序的硬件安排是否正确?

我知道有很多问题,我并不是想开始对此进行讨论,我知道可能有很多不同的意见,我有兴趣听到所有这些意见,包括实施细节。我正在寻求你们的一些反馈,我们将非常感谢你们的意见。提前致谢!

The problem

We are involved in a new project to develop an application with several PC's that will act as general purpose computers. There is also a computer that will act from time to time as a master machine to gain the control of all the processes of the clients. That computer has to send a message to all the others through a server machine asking for instance to register assistance. At that time, a process running in the client machines has to gain the control of the computer and act as an slave machine running that application only until a new message is sent from the master machine to release them. After that, the client machines act again as a general purpose computers.

The following scheme tries to explain what happens after the CM(Control Machine) gains access of the SM(Slave Machines) through the server (SRVR)

  1. Control machine CM sends message to register assistance to a server
    2 The SRVR receives the message, logs some information and broadcasts the register assistance message to the SMs
  2. The running SM process that was waiting the message gains total control in each SM
  3. The user chooses an action through a view in the SM and the machine sends a response to the SRVR
  4. The SRVR receives the response and broadcasts it to all the machines, including the results machine (RM) to update the views with the new state in the server (SRVR)
  5. The CM sends the End Register Message to the SRVR.
  6. The SRVR broadcasts the message to all the SMs, the application view closes and the application enters to a listening state again.

Stated that:

  • Everything needs to be done in some kind of Java Technology
  • All the machines are runing GNU/Linux/Gnome (Ubuntu)
  • JPA is mandatory for the logging and persistence
  • JavaFX is going to change according to Oracle because they are thinking to abandon the scripting language

Questions are:

  1. Which mix of java technologies would you use for the view?. My opinion is using Swing and maybe embbed this in FX through SwingComponent.wrap(loginPanel) to help graphic designers do a better visual work (a must in this application). Please consider the binding options JSR-295 (now dead as I can see) or some adequate alternative.

  2. How would you maintain updated the application client, my opinion is through Java Web Start and serving it as an applet.

  3. Is it ok if the SRVR uses Java EE with EJB 3.0 to access to remote objects? If so, how would you integrate/model/ EJB with RMI. I have no big experience with RMI/EJB integration and I am not so sure that it is correct. Specially because EJB specification trusts in RMI already. But then how to broadcasts messages from a Session Bean (Stateful one as I can see) to update the view?

  4. Any option chosen in SM has to be viewed in all the views (other SMs, RM and CM) registered as observers. Would you suggest a model/architecture/products for this.

  5. Which is the right way to make the SM application gain total control once its process is awaken? -remember, it is Linux-

  6. How the observer pattern has to be applied in a distributed context?

  7. Is the HW arrangement correct for this application?

I know these are lot of questions and I am not trying to begin a discussion about this, I know that there can be a lot of different opinions and I am interested in hearing all of them, including implementation details. I am looking for some feedback from you guys, your opinions will be highly appreciated. Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你的呼吸 2024-10-13 17:29:43

嗯,这就是我解决这个问题的方法。

1.您将在视图中使用哪种 Java 技术组合?我的意见是使用 Swing,也许可以通过 SwingComponent.wrap(loginPanel) 将其嵌入到 FX 中,以帮助图形设计师完成更好的视觉工作(此应用程序中必须这样做)。请考虑绑定选项 JSR-295(据我所知现在已经死了)或一些适当的替代方案。

在本例中使用了 Swing,考虑因素是它是一种最稳定的技术,如果毕竟 JavaFX 将是一个库,之后可以使用它来为应用程序提供更好的方面,目前视图是使用 Swing LAF

2 自定义的。您将如何维护应用程序客户端的更新,我的意见是通过 Java Web Start 并将其作为小程序提供。

该需求是通过 shell 脚本和 ssh 提供的。经过一些更新后,客户端应用程序将重新部署到客户端计算机

3。如果SRVR使用JEE和EJB 3.0来访问远程对象可以吗?如果是这样,您将如何将 EJB 与 RMI 集成/建模/集成。我对 RMI/EJB 集成没有丰富的经验,并且不太确定它是否正确。特别是因为 EJB 规范已经信任 RMI。但是如何从会话 Bean(据我所知是有状态的)广播消息来更新视图?

RMI 架构很简单。在本例中,JBoss AS 应用程序是通过 rmiregistry 部署在每台客户端计算机上的 RMI 服务器的客户端。当客户端应用程序继续运行时,RMI 存根是服务器和客户端之间唯一共享的类,该接口允许您调用客户端方法。请小心使 JPA 模型类可序列化。

4. SM 中选择的任何选项都必须在注册为观察员的所有视图(其他 SM、RM 和 CM)中查看。您是否可以为此建议一个模型/架构/产品。

它的实现方式与上一点中所述的相同,但重要的一点是,RMI 不支持多播消息传递,因此如果您需要使用以下方式进行消息传递,请务必小心:许多注册客户端,因为如果您有 100 台机器相互广播消息,则意味着通过网络发送 100x100 条消息。

5.一旦进程被唤醒,SM应用程序获得完全控制权的正确方法是什么? -记住,它是Linux-

嗯,Java Swing 的JFrame 有一种方法来维护Window ALWAYS_ON_TOP。如果将此与 UNDECORATED_FRAME 结合使用,其他应用程序将继续运行,但它们永远不会获得焦点。

6.观察者模式必须如何应用在分布式上下文中?

它的应用方式相同,我们只需要小心何时注册观察者以及何时取消注册它们。

7.此应用程序的硬件布置是否正确?

硬件布置按照问题中包含的图形所示的方式进行部署。

感谢所有这些至少检查了这个问题。

Well that is the way I solved this.

1. Which mix of java technologies would you use for the view?. My opinion is using Swing and maybe embbed this in FX through SwingComponent.wrap(loginPanel) to help graphic designers do a better visual work (a must in this application). Please consider the binding options JSR-295 (now dead as I can see) or some adequate alternative.

Swing was used in this case, the considerations were that It was a most stable technology and if after all JavaFX is going to be a library it can be used after to give a better aspect to the application, for now view was customized using Swing LAF

2. How would you maintain updated the application client, my opinion is through Java Web Start and serving it as an applet.

The requirement was suplied through shell scripts and ssh. After some update the client application is redeployed in to the client machine

3. Is it ok if the SRVR uses JEE with EJB 3.0 to access to remote objects? If so, how would you integrate/model/ EJB with RMI. I have no big experience with RMI/EJB integration and I am not so sure that it is correct. Specially because EJB specification trusts in RMI already. But then how to broadcasts messages from a Session Bean (Stateful one as I can see) to update the view?

RMI architecture is simple. In this case the JBoss A.S. application was the client of an RMI server deployed on each client machine through rmiregistry. When the client application goes on, the RMI stub that is the only shared class between server and client, this interface lets you invoke the client methods. Be careful to make your JPA model classes serializable.

4. Any option chosen in SM has to be viewed in all the views (other SMs, RM and CM) registered as observers. Would you suggest a model/architecture/products for this.

It is achieved in the same way stated in the previous point, but an important note is that RMI does not support multicast messaging, so be careful if you need messaging with many registered clients, because if you have 100 machines that broadcast messages to each other, it means 100x100 messages sent over network.

5. Which is the right way to make the SM application gain total control once its process is awaken? -remember, it is Linux-

Well, Java Swing's JFrame has a way to maintain the Window ALWAYS_ON_TOP. If you combine this with UNDECORATED_FRAME, the other applications will remain running but they will never achieve focus.

6. How the observer pattern has to be applied in a distributed context?

It is applied the same way, we have just to be carefull when to register the observers and when to unregister them.

7. Is the HW arrangement correct for this application?

The hardware arrangement was deployed in the way shown by the graphic included in the question.

Thanks to all that at least checked the question.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文