简体   繁体   English

Java跨Web应用程序的通信设计?

[英]Java inter-web application communication design?

We're designing two distinct systems which can be simulated by the following typical example. 我们正在设计两个不同的系统,可以通过以下典型示例进行仿真。

Web App #1 - Course catalog (allows updating / populating the course catalog) Web App#1-课程目录(允许更新/填充课程目录)

  • Professors 教授
  • Course (courseCode, professorId, list of Prerequisites, grade scale used) 课程(courseCode,professorId,前提条件列表,使用的年级量表)
  • Prerequisites (courseCode and minimum grade required) 前提条件(要求课程代码和最低成绩)
  • GradeScale (ie AF, 1-100, pass/fail) GradeScale(即,AF,1-100,通过/失败)

Web App #2 - Student catalog (handles students registering for new courses, seeing their transcript, etc) Web App#2-学生目录(处理学生注册新课程,查看成绩单等)

  • Student 学生
  • Transcript (what courses did they take and what final grade) 成绩单(他们修了什么课程以及什么年级)

Data that needs to pass between the two systems (there will be more calls and stuff that needs to be handed back and forth, but this gives the idea that it's a 2-way flow of questions and answers): 需要在两个系统之间传递的数据(会有更多的呼叫和内容需要来回传递,但这使我们认为这是一个双向的问题和答案流):

  1. Does a student have the pre-reqs needed to take a particular course? 学生是否具备参加特定课程所需的先修课程?
  2. Pulling details from the course catalog to create a full transcript 从课程目录中提取详细信息以创建完整的成绩单

From reading, it seems our options are: 通过阅读,似乎我们的选择是:

  1. Create EJBs for the underlying data model, then have the web applications use the EJB interface. 为基础数据模型创建EJB,然后让Web应用程序使用EJB接口。
  2. Use a REST or Web Service interface between the two applications. 在两个应用程序之间使用REST或Web服务接口。
  3. RMI or other Java remoting? RMI或其他Java远程处理?

Which way would you cut this up into JARs/WARs/EARs? 您会以哪种方式将其分解为JAR / WAR / EAR?

This was initially a comment but it's actually too long. 这最初是评论,但实际上太长了。

If you got only simple imperative services (set this, do that, is this valid?), then you can go for an AXIS2/SOAP based web services solution. 如果您仅获得简单的命令式服务(对此进行设置,是否有效?),则可以选择基于AXIS2 / SOAP的Web服务解决方案。 (you probably won't need the whole bloat of SpringWS). (您可能不需要SpringWS的全部功能)。 If the app logic is not too twisted, I'd follow KISS principle. 如果应用逻辑不太复杂,我将遵循KISS原则。

I don't know your system scenario, but if you're using a full fledge RDBMS, it's high probable that the database will reside on its own machine, thus having different pools connecting to it, is not much of a burden. 我不知道您的系统方案,但是如果您使用的是完整的RDBMS,数据库很可能将驻留在其自己的计算机上,因此将不同的池连接到该计算机上并不是很大的负担。 (if you're using a local db on each AS, you're probably going to face some scalability problems later on). (如果您在每个AS上使用本地数据库,则稍后可能会遇到一些可伸缩性问题)。

In modern Java EE app servers you can actually use connection pools of one server from another (via jnp:// urls), it's just a matter of JNDI lookup. 在现代Java EE应用服务器中,您实际上可以使用一台服务器与另一台服务器的连接池(通过jnp:// URL),这只是JNDI查找的问题。

If the db engine supports it, oracle alike db links are also a good way to share a database between apps. 如果数据库引擎支持它,那么类似oracle的数据库链接也是在应用程序之间共享数据库的好方法。

You can spare code times by having a business/data layer in a simple java project with all the ORM stuffs, shared across the 2 web dinamic projects, so eventual changes in business logic will reflect onto both apps. 您可以通过在一个简单的Java项目中包含一个业务/数据层来节省代码时间,该项目具有所有ORM内容,并在2个Web dinamic项目之间共享,因此业务逻辑的最终更改将反映在两个应用程序上。

You can also tryout the mixed way (simple imperative Web Services and database share), it really depends on what messages are exchanged between the two applications. 您还可以尝试混合方式(简单的命令式Web服务和数据库共享),它实际上取决于两个应用程序之间交换的消息。 You can provide a layer of web services API (SOAP or jsonp based), but take into account execution time of the web service itself (it's not so good to have time consuming ws). 您可以提供一层Web服务API(基于SOAP或jsonp),但要考虑到Web服务本身的执行时间(拥有耗时的ws并不太好)。

Web Services and EJB are good and probably can do what you need, the real question is: do you really need them ? Web服务和EJB很好,并且可能可以满足您的需求,真正的问题是:您是否真的需要它们? lately I've seen lots of project starting with the full REST thing, and in many cases it was like killing flies with a bazooka. 最近,我看到了很多项目,都是从完整的REST开始的,在许多情况下,这就像用火箭筒杀死苍蝇一样。

If the requirements are simple, then keep it simple. 如果要求很简单,则保持简单。

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

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