GWT项目结构 [英] GWT Project Structure

查看:116
本文介绍了GWT项目结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在在我们的项目中,我们有下面提到的结构。我们的项目主要使用GWT& Spring框架。


  1. com.customername.projectname.client.module name

  2. com.customername。 projectname.client.rpc.module name

  3. com.customername.projectname.shared.validator.module name

  4. com.customername.projectname.server。模块名称

  5. com.customername.projectname.spring.dao.module名称

  6. com.customername.projectname.spring.service.module name
  7. li>

我们的 application.gwt.xml 包含以下需要转换的源代码项进入java脚本。

  source path ='client'
source path ='shared'

因为我们在服务器端使用spring,所以我们使用spring注释来标记服务和DAO,然后在 applicationContext.xml 我们使用下面的配置来扫描DAO和服务层。

 <上下文:注解的配置/> 
< context:component-scan base-package>

现在我们的客户想要使用下面提到的结构。按模块分组所有内容。在我们的情况下,模块也不是GWT模块。它就像差异。部分应用程序。


  1. com.customername.projectname.modulename.client

  2. com.customername.projectname.modulename。
  3. com.customername.projectname.Modulename.validator

  4. com.customername.projectname.Modulename.server

  5. com.customername.projectname.Modulename.spring.dao

  6. com.customername.projectname.Modulename.spring.Service

我的问题是:


  1. 考虑到它的应用程序非常大,推荐使用上面的方法吗?

  2. 如果要实现上述方法,如何设置需要由gwt编译器从java转换为java脚本的包/源文件。我应该在application.gwt.xml中提到每个模块名称吗?
  3. 同意edwardTheGreat,你的初始包装结构听起来非常合理。您只需在gwt.xml文件中列出客户端和共享包(需要编译为javascript的包)。



    问题2)如果您更改了包结构,就像你所说的,你必须在你的gwt.xml文件中列出每个模块的客户端和共享目录。正如丹尼尔所说,你可以将每个模块分解成它自己的GWT模块,然后在每个应用模块中继承你需要的GWT模块。为了达到这个目的,你必须让每个继承的GWT模块的源代码都可以被继承模块使用。无论你是通过Maven,Ant等来做到这一点,都无关紧要。但是顶级GWT模块必须具有编译时访问所有继承的GWT模块的源代码的权限。例如:

     < module rename-to ='A'> 
    < inherits name ='org.example.B'/>
    ...其他继承,入口点等...
    < source path ='client'/>
    < source path ='shared'/>
    < / module>

    通过这种结构,模块'A'必须能够访问模块'B'的源。模块'B'可以像通常的GWT模块一样构建,但是在编译时,模块'A'必须在类路径中有B的源。


    Right now in our project, we have below mentioned structure. Our project is mainly using GWT & Spring framework.

    1. com.customername.projectname.client.module name
    2. com.customername.projectname.client.rpc.module name
    3. com.customername.projectname.shared.validator.module name
    4. com.customername.projectname.server.module name
    5. com.customername.projectname.spring.dao.module name
    6. com.customername.projectname.spring.service.module name

    Our application.gwt.xml contains below entry for source which needs to be coverted in to java script.

    source path='client'
    source path='shared'
    

    As we are using spring at the server side, we are using spring annotation to mark the services and DAO and then in applicationContext.xml we are using below configuration to scan the DAO and Service Layer.

    <context:annotation-config/>    
    <context:component-scan base-package>
    

    Now our client wants to go with below mentioned structure. Grouping everything by module. Also in our case module is not GWT module. It is just like diff. parts of the application.

    1. com.customername.projectname.modulename.client
    2. com.customername.projectname.modulename.rpc
    3. com.customername.projectname.Modulename.validator
    4. com.customername.projectname.Modulename.server
    5. com.customername.projectname.Modulename.spring.dao
    6. com.customername.projectname.Modulename.spring.Service

    My question is:

    1. Is the upper approach is recommended considering it is very large application?
    2. If the above approach is to be implemented , how to go about setting up the packages/source files which needs to be converted by gwt compiler from java to java script. Should I mention each module name in application.gwt.xml?

    解决方案

    Question 1) I agree with edwardTheGreat, your initial package structure sounds perfectly reasonable. You will only have to list the client and shared packages (the ones that need compiled into javascript) in your gwt.xml file.

    Question 2) If you do change the package structure, like you've mentioned, you will have to list every module's client and shared directories in your gwt.xml file. As Daniel said, you could break each module out into it's own "GWT module," and then inherit the GWT modules you need in each application module.

    To achieve this, you would have to make each inherited GWT module's source available to the inheriting module. Whether you do this through Maven, Ant, etc., doesn't matter. But the top-level GWT module must have compile-time access to the source for all inherited GWT modules. For example:

    <module rename-to='A'>
      <inherits name='org.example.B' />
      ... other inherits, entry-point, etc. ...
      <source path='client' />
      <source path='shared' />
    </module>
    

    With this structure, module 'A' must have access to the source of module 'B'. Module 'B' can be built as you normally would a GWT module, but then, at compile-time, module 'A' must have B's source on the classpath.

    这篇关于GWT项目结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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