针对Java Swing和GWT进行交叉开发 [英] Cross developing targeting both Java Swing and GWT

查看:133
本文介绍了针对Java Swing和GWT进行交叉开发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有几个屏幕,它们可以帮助您轻松地将应用程序移植到Java Swing和GWT中在桌面应用程序和浏览器中都具有完全意义,我想知道是否有某种通用的API可以有针对性地促进创建这两个不同的视图(请参阅​​我的评论)?

解决方案

我认为这完全有可能,但这意味着服务器端不同。 b
$ b

如果您进行UI通信的服务器端组件的基于接口的POJO开发来完成这项工作,那么您可以选择内存中实现还是选择作为远程组件的代理。 Swing桌面用户界面可能使用服务器端的内存版本,而GWT版本会与分布式版本对话。



如果使用Spring,很容易为每个UI注入适当的实现。他们都只知道接口,并且没有注意到实现细节。



我想象一个可能以不同方式打包的代码库。 Swing桌面应用程序将打包并作为JAR文件提供。它不包括GWT或Web层控制器类。 GWT代码库将包含Web配置和控制器,因为控制器实际上是Web层的一部分。

服务界面及其背后的所有内容对于两者都是相同的。唯一的区别是Swing桌面配置会注入服务接口的内存中服务层实现。 Web配置将注入基于Web的服务接口实现。



无论我尝试阅读您的需求是否正确,这种方法都有价值,无论你是如何决定实现服务和客户端层的。



我是Spring粉丝,所以我建议使用Spring。


Does anyone know of any tool that can facilitate/ease porting of an app to both Java Swing and GWT?

I've got a few "screens" that makes complete sense to have both in a desktop app and in a browser and I was wondering if there was some kind of common API that could be targeted that would facilitate creating these two different "views" (see my comment)?

解决方案

I think it's entirely possible, but it would mean a different take on the server side of things.

If you do interface-based POJO development of the server-side components that the UI communicates with to do the work, you leave yourself the option of either an in-memory implementation or one that acts as a proxy to a remote component. The Swing desktop UI might use the in-memory version of the server-side, while the GWT version talks to the distributed version.

If you use Spring, it's easy to inject the appropriate implementation for each UI. Both only know about the interface and are oblivious to the implementation details.

I imagine a single code base that might be packaged in different ways. The Swing desktop app would be packaged and delivered as a JAR file. It wouldn't include the GWT or web tier controller classes. The GWT code base would include web configuration and controllers, because controllers are really part of the web tier.

The service interface and everything behind it would remain the same for both. The only difference would be that the Swing desktop configuration would inject the in-memory service layer implementations of the service interface. The web configuration would inject the web-based implementations of the service interface.

Whether my attempt to read your mind for requirements is correct or not, this approach has value regardless of how you decide to implement the service and client tiers.

I'm a Spring fan, so I'd recommend the use of Spring.

这篇关于针对Java Swing和GWT进行交叉开发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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