开发者

GWT Project Structure

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.shar开发者_开发百科ed.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.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜