简体   繁体   English

带有Swing和Web GUI的Java App

[英]Java App with Swing and Web GUI

I need to build a desktop application for internal users for certain business. 我需要为某些业务的内部用户构建一个桌面应用程序。 It also needs web based GUI for external users. 它还需要外部用户基于Web的GUI。 I know, with web GUI both internal and external users can access it, but there are certain factors which are outside our control - due to which, desktop application is really unavoidable. 我知道,使用Web GUI的内部和外部用户都可以访问它,但是某些因素是我们无法控制的-因此,桌面应用程序确实不可避免。 For the purpose of this question, I would like to focus on the way to support both Desktop client (Swing) and Browser client. 出于这个问题的目的,我想重点介绍支持桌面客户端(Swing)和浏览器客户端的方法。

Are there any best practices to be followed? 是否有任何最佳做法可遵循? I could think of below: 我可以想到以下:

  1. Expose service classes as web services and use these from both Swing client and web client 将服务类公开为Web服务,并在Swing客户端和Web客户端中使用它们
  2. Expose service classes as EJB (business is into Java EE techs) and use Swing client as EJB client. 将服务类公开为EJB(Java EE技术已涉足业务),并将Swing客户端用作EJB客户端。 Web client can use controller classes to interact with EJB Web客户端可以使用控制器类与EJB进行交互

Are there any known benefits of using either approach, apart from technology agnosticism offered by web services? 除了Web服务提供的技术不可知论之外,使用这两种方法是否有任何已知的好处?

Also, for swing client, I am thinking of using Java Web Start for easy distribution. 另外,对于摇摆客户,我正在考虑使用Java Web Start进行轻松分发。 I have never used it before, but from what I understood, it can support automatic version check at startup and update the client when required - is this correct? 我以前从未使用过它,但是据我了解,它可以在启动时支持自动版本检查并在需要时更新客户端-这是正确的吗?

If you need to avoid dependency to Java/JVM on the browser (which you most likely at least want to), you should definitely go with mixed Swing-Vaadin approach. 如果您需要避免对浏览器上Java / JVM的依赖(您很可能至少希望这么做),则绝对应该使用Swing-Vaadin混合方法。 Build the internal application with Swing or JavaFX and web part with Vaadin. 使用Swing或JavaFX构建内部应用程序,并使用Vaadin构建Web部件。 The programming model in Vaadin is so close to typical desktop UI library that it is really easy for the same developers to work with both code base, and naturally you'll use exactly the same backend. Vaadin中的编程模型非常接近典型的桌面UI库,以至于相同的开发人员可以很轻松地使用这两个代码库,并且自然地,您将使用完全相同的后端。

See the example application I recently built to demonstrate a setup like this. 请参阅我最近构建的示例应用程序,以演示这种设置。

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

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