具有桌面、Android 和 ios 客户端的 java-ee 应用程序
我正在使用 java enterprise 和 glassfish 构建一个应用程序。客户端和服务器之间的信息通常是少量数据,但有时客户端需要获取更大的资源(通常为 1-20 MB)。我仍在规划系统的架构,并且我需要一些关于如何将服务器上的资源公开给多个客户端的建议。
最初我只想在 javaws 和 glassfish 提供的 ACC 中运行一个桌面客户端应用程序。我将远程接口放在一个单独的 jar 中,并计划通过调用通过这些接口公开的 EJB 方法来完成所有客户端服务器接口。对于 Java 桌面客户端来说,这一切都很好。对于 Android 客户端来说,这应该相当容易。但我认为对于 ios 来说这不会那么容易。
有什么方法可以从 iPhone 或 ipad 中运行的 Objective-C 调用我的 EJB 吗?我当然希望如此。
我预计解决方案是 RESTful Web 服务。据我了解,这是一种通过以通用 XML 或 JSON 形式传递数据来松散耦合客户端和服务器应用程序的方法。
抱歉,如果我遗漏了一些非常明显的东西,但似乎有两条路线:
保留我的 EJB 业务接口并为通用客户端(iOS 以及以后可能出现的其他任何东西)实现一个重复的 Restful 接口。
为所有客户端创建一个静态接口。
数字 2 看起来是一个更简洁的设计,但这意味着我必须放弃已经完成的工作并学习休息。有更有经验的人可以提供一些建议吗?我将非常感激。
I am building an application with java enterprise and glassfish. The information between client and server will usually be small amounts of data, but from time to time the client will need to get a larger resource (1-20 MB would be typical). I am still planning the architecture of the system, and I need some advice about how to expose resources on the server to multiple clients.
Originally I was only going to have a desktop client app running in the ACC provided by javaws and glassfish. I put the remote interfaces in a separate jar, and planned to do all client server interfacing by calling EJB methods exposed through those interfaces. This is all fine and well for a java desktop client. It should even be pretty easy for an android client. But I don't think its going to be as easy for ios.
Is there any way I can call my EJBs from the objective-c running in an iphone or ipad? I surely hope so.
Im anticipating that the solution is a RESTful web service. From what I understand this is a way to loosely couple client and server applications by passing the data in a generic XML or JSON form.
Sorry if I am missing something very obvious, but it seems like there are two routes from here:
keep my EJB business interface and implement a duplicate restful interface for generic clients (iOS and whatever else might come up later).
create one restful interface for all clients.
number 2 seems like a much cleaner design, but it means I have to scrap work ive already done and learn about rest. Can someone with more experience offer some suggestions? I would appreciate it so much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 EJB 3.1 中,您可以通过非常简单的方式将业务逻辑公开为 RESTful 服务,例如:
不需要 servlet 或任何其他委托。一种逻辑有多种访问方法是绝对没问题的,这样一些 Java 客户端使用 EJB (RMI),而其他客户端则使用 REST。将来您甚至可以根据需要添加一些新的服务,例如 XML Web 服务、通过异步消息传递等。
In EJB 3.1 you can expose you business logic as a RESTful service in a very simple way, e.g.:
No need for servlets or any other delegate. It's absolutely fine to have various access methods for one logic so that some java clients use EJB (RMI) and others use REST. In the future you may even add some new ones if needed, e.g. XML web service, through asynchronous messaging and so on.
我建议选项 2 进行一次修改,甚至不用费心去创建一个 Web 服务。
使用返回 JSON 的普通 servlet 以供 Android 和 iOS 使用
I would suggest Option 2 with one modification, dont even bother to create a web service.
Use a plain servlet which returns JSON to be consumed by Android and iOS