简体   繁体   English

架构java gwt + jsf2 + spring封装

[英]architecture java gwt+jsf2+spring packaging

I am planning to do a website that has GWT as admin interface, JSF 2 as frontend and spring to handle business logic. 我打算创建一个网站,该网站具有GWT作为管理界面,以JSF 2作为前端,并且可以处理业务逻辑。

Basicly. 基本上。 I will have 3 projects: 我将有3个项目:

  1. GWT GWT
  2. spring (business logic which also might export some web services in the future) 春天(业务逻辑,将来也可能会导出一些Web服务)
  3. JSF 2 JSF 2

In GWT I am planning to have spring context (from the dependend spring-project) and use it to connect to database? 在GWT中,我计划具有spring上下文(来自dependend spring项目),并使用它来连接数据库?

  1. Is this possible to create 3 projects in eclipse, refer as dependencies them and then create an EAR that contains all of these? 是否可以在eclipse中创建3个项目,将它们称为依赖项,然后创建包含所有这些项目的EAR?
  2. What happens to user session? 用户会话会怎样? stored in GWT and JSF 2? 存储在GWT和JSF 2中?
  3. Is it a good architecture? 它是一个好的架构吗? how can be this done somehow else? 怎么可以这样呢?
  4. How do I package those? 我该如何包装? all war files? 所有战争档案? or jar? 还是罐子? in a single ear... or? 一只耳朵...还是?

First of all why do you want to use two different client side technologies together ( JSF2 and GWT )? 首先,为什么要一起使用两种不同的客户端技术( JSF2GWT )? I would rather stick to one of them. 我宁愿坚持其中之一。

Saying that: Yes, it is possible to have 3 different projects. 说:是的,可能有3个不同的项目。 Actually the recommended way (at least with GWT and Spring or any other backend) is to have them in separate projects. 实际上,推荐的方法(至少与GWTSpring或任何其他后端一起使用)是将它们放在单独的项目中。

Is this possible to create 3 projects in eclipse, refer as dependencies them and then create an EAR that contains all of these? 是否可以在eclipse中创建3个项目,将它们称为依赖项,然后创建包含所有这些项目的EAR?

Well at least with GWT you usually can't access the backend/database directly (not sure about JSF2). 至少使用GWT,您通常通常无法直接访问后端/数据库(不确定JSF2)。 You have to use some kind of communication protocol ( RequestBuilder , RequestFactory , GWT-RPC , REST ) You can have shared classes (in package xxx.shared ) that can be referenced by both your GWT and your Spring application (that is normally used by GWT-RPC or RequestFactory ) 您必须使用某种通信协议( RequestBuilderRequestFactoryGWT-RPCREST )您可以拥有共享类(在xxx.shared包中),您的GWTSpring应用程序都xxx.shared这些共享类(通常由GWT-RPCRequestFactory

What happens to user session? 用户会话会怎样? stored in GWT and JSF 2? 存储在GWT和JSF 2中?

There is nothing special about user sessions. 用户会话没有什么特别的。 GWT and JSF communicate via HTTP requests with the backend. GWT和JSF通过HTTP请求与后端进行通信。 So the same thing that applies to normal HTTP requests also applies to GWT/JSF2 requests. 因此,适用于普通HTTP请求的内容也适用于GWT / JSF2请求。

Is it a good architecture? 它是一个好的架构吗? how can be this done somehow else? 怎么可以这样呢?

It depends on what you want to achieve. 这取决于您要实现的目标。 As mentioned before I would rather stick to one client side technology ( GWT or JSF2 ) rather than using both of them. 如前所述,我宁愿坚持一种客户端技术( GWTJSF2 ),而不是同时使用它们。

How do I package those? 我该如何包装? all war files? 所有战争档案? or jar? 还是罐子? in a single ear... or? 一只耳朵...还是?

GWT compiles down to javascript which is included in your host file. GWT会编译为包含在主机文件中的javascript。 So you usually create one WAR or EAR file that gets deployed to the application server. 因此,您通常会创建一个WAREAR文件,并将其部署到应用程序服务器。

I will answer my question because I will give more details for the next guys that will want to do the same thing I do: 我将回答我的问题,因为我将为下一个想要做与我相同的事情的人提供更多详细信息:

In Eclipse: 在Eclipse中:

  1. Create new Java EE Application normaly with 3 or how many modules you want 通常使用3个或所需的模块数量来创建新的Java EE应用程序
  2. Add new GWT project 添加新的GWT项目
  3. Add the existing GWT project to the Java EE descriptor (to be added in ear) 将现有的GWT项目添加到Java EE描述符(将在耳朵中添加)
  4. In project builder you should have this: 在项目构建器中,您应该具有以下功能: 在此处输入图片说明
  5. Compile the GWT Apllication once: 一次编译GWT应用程序: 在此处输入图片说明
  6. After you deployed your application in glassfish access your website with chrome at this URL: http://localhost:8080/Admin/?gwt.codesvr=127.0.0.1:9997 当您在部署应用程序glassfish :访问铬在这个URL你的网站http://localhost:8080/Admin/?gwt.codesvr=127.0.0.1:9997

What you need to know: 您需要了解的内容:

  • Servlets are hot deployed Servlet是热部署的
  • Any modification you do on servlets will change server part 您对Servlet所做的任何修改都会更改服务器部分
  • Any modification you do on GWT Application google chrome plugin will take care of it 您在GWT应用程序google chrome插件上进行的任何修改都会照顾好它

My environment: 我的环境:

  • JDK 1.7.0_11
  • Eclipse 4.2 Java EE ( + GWT Plugin , + Spring plugin ) Eclipse 4.2 Java EE+ GWT Plugin+ Spring plugin
  • Glassfish 3.1.2.2

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

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