GWT 项目结构

发布于 2024-11-07 08:06:49 字数 1383 浏览 3 评论 0原文

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

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

我们的 application.gwt.xml 包含以下需要的源条目被转换成java脚本。

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

由于我们在服务器端使用 Spring,因此我们使用 Spring 注解来标记服务和 DAO,然后在 applicationContext.xml 中我们使用以下配置来扫描 DAO 和服务层。

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

现在我们的客户想要采用下面提到的结构。按模块对所有内容进行分组。此外,在我们的例子中,模块不是 GWT 模块。就像 diff 一样。应用程序的一部分。

  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

我的问题是:

  1. 考虑到它是非常大的应用程序,是否建议使用上面的方法?
  2. 如果要实现上述方法,如何设置需要由gwt编译器从java转换为java脚本的包/源文件。我应该在 application.gwt.xml 中提及每个模块名称吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

也只是曾经 2024-11-14 08:06:49

问题 1)我同意 edwardTheGreat 的观点,你最初的包结构听起来非常合理。您只需在 gwt.xml 文件中列出客户端和共享包(需要编译成 javascript 的包)。

问题 2)如果您确实更改了包结构,就像您提到的那样,您将必须在 gwt.xml 文件中列出每个模块的客户端和共享目录。正如 Daniel 所说,您可以将每个模块分解为它自己的“GWT 模块”,然后继承每个应用程序模块中所需的 GWT 模块。

要实现此目的,您必须使每个继承的 GWT 模块的源可供继承模块使用。无论您是通过 Maven、Ant 等来完成此操作,都没有关系。但是顶级 GWT 模块必须能够在编译时访问所有继承的 GWT 模块的源代码。例如:

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

使用此结构,模块“A”必须有权访问模块“B”的源。模块“B”可以像通常的 GWT 模块一样构建,但是在编译时,模块“A”必须在类路径上具有 B 的源代码。

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.

划一舟意中人 2024-11-14 08:06:49

要回答第二个问题,每个模块都应该有一个 .gwt.xml 文件,指出该模块中的客户端(和共享)目录。对于使用其他 GWT 模块的 GWT 模块,您应该在 .gwt.xml 文件中使用“inherit”来引用它们。

本页很好地描述了其中一些概念:
http://code.google.com/webtoolkit/doc/latest/DevGuideOrganizingProjects.html

To answer the second question, you should have one .gwt.xml file for each module, pointing out the client (and shared) directories in that module. For the GWT modules that use other GWT modules, you should use "inherit" in the .gwt.xml file to refer to them.

This page describes some of these concepts quite well:
http://code.google.com/webtoolkit/doc/latest/DevGuideOrganizingProjects.html

断念 2024-11-14 08:06:49

问题1)
如果这对您和其他开发人员有意义,那么这听起来是一个相当不错的项目结构。 (摘自此处

您应该捆绑这些类并
多个包中的接口
原因包括以下几点:

  • 您和其他程序员可以轻松确定这些类型是
    相关。
  • 您和其他程序员知道在哪里可以找到可以提供的类型
    图形相关函数。
  • 您的类型名称不会与其他类型的名称冲突
    包,因为包创建了一个
    新的命名空间。
  • 您可以允许包内的类型不受限制地访问
    彼此之间仍然限制访问
    对于包外的类型。

问题2)
让我澄清一下:

我应该在 application.gwt.xml 中提及每个模块名称吗?

你是说包裹吧?

...

    <entry-point class='com.customername.projectname.AppEntryPoint'/>

    <source path="modulename.client"/>
    <source path="modulename.anotherpackage"/>

</module>

GWT 模块中的任何包(从 .gwt.xml 所在的包开始)如果要编译,都应该在 .gwt.xml 中引用通过 GWT 编译器,引用的包的任何子包都将由 GWT 编译器自动编译。

不确定您的问题与 Spring 配置有关。

希望有帮助。

Question 1)
If it makes sense to you, and other developers it sounds like a fairly decent project structure. (Taken from Here)

You should bundle these classes and
the interface in a package for several
reasons, including the following:

  • You and other programmers can easily determine that these types are
    related.
  • You and other programmers know where to find types that can provide
    graphics-related functions.
  • The names of your types won't conflict with the type names in other
    packages because the package creates a
    new namespace.
  • You can allow types within the package to have unrestricted access to
    one another yet still restrict access
    for types outside the package.

Question 2)
Let me just clarify, in Regards to:

Should I mention each module name in application.gwt.xml?

you mean packages right?

...

    <entry-point class='com.customername.projectname.AppEntryPoint'/>

    <source path="modulename.client"/>
    <source path="modulename.anotherpackage"/>

</module>

Any package (starting from the package that the .gwt.xml is in) in the GWT Module, should be referenced in the .gwt.xml if it is to be compiled by the GWT Compiler, any sub-packages of the referenced packages will automatically be compiled by the GWT Compiler.

Not Sure what your question is in regard to the Spring Configuration.

Hope that Helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文