【问题标题】:GWT three-tier architectureGWT 三层架构
【发布时间】:2011-12-27 06:14:49
【问题描述】:

我正在使用 JPA 作为数据访问层开发基于 GWT 的应用程序。我的应用程序需要支持三层架构。主要思想是拥有具有静态内容(html/javascript 等)的 HTTP 服务器(Apache),具有业务逻辑(servlet、bean 等)的 Web 应用程序服务器(Glassfish) .) 和数据库服务器 (PostgreSQL)

有没有简单的方法来划分为简单的 GWT 应用程序生成的 war 文件的内容以实现所描述的架构?

也许有一个 maven 插件可以帮助创建具有静态内容和业务逻辑的单独战争文件。

我也在考虑创建代理来拦截 GWT-RPC 调用并在远程服务器上调用业务方法。

我发现描述这种解决方案的非常有趣的文章 (full article) 但它需要大量工作才能实现我的目标。希望有一个库或工具包可以简化代理生成过程。

我们将不胜感激任何想法。

【问题讨论】:

    标签: gwt jpa-2.0 three-tier


    【解决方案1】:

    我有一个类似的设置,只是 Tomcat 而不是 Glassfish,以及构建一切的 maven。这是它的工作原理。 Apache httpd 和 Tomcat 使用 mod_jk 连接。 Apache 将所有请求转发到 Tomcat,除了 GWT 模块目录(我们称之为 gwt_module),它包含所有 GWT 编译的东西 - 由 Apache 提供服务并配置为缓存。 其余的 - 基本上是 servlet,被转发到 Tomcat(RPC、RequestFactory、其他 servlet)。 MongoDB 作为数据库服务器。

    这里是相关的 httpd.conf 部分:

    JkMount  /* webbalancer
    JkUnMount /gwt_module/*  webbalancer
    Alias /gwt_module "/srv/web/app_servers/tomcat-1/webapps/ROOT/gwt_module/"
    
    <Directory  "/srv/web/app_servers/tomcat-1/webapps/ROOT/gwt_module/">
        Order deny,allow
        allow from all
        Options -Indexes
        <FilesMatch "\.cache\.*">
            Header set Cache-control max-age=31536000
    #       Header unset ETag
    #       FileETag None
        </FilesMatch>
    
    # turning off ETags, to force browsers to rely only on Cache-Control and Expires headers.
    # for some reason, FF wasn't using the cache for JS files if ETags are on.
      Header unset ETag
      FileETag None
    </Directory>
    
    # Tell clients to keep images in the cache
    ExpiresActive On
    ExpiresByType image/x-icon A2592000
    ExpiresByType image/gif A2592000
    ExpiresByType image/png A2592000
    ExpiresByType image/jpg A2592000
    ExpiresByType image/jpeg A2592000
    #ExpiresByType application/x-javascript A2592000
    ExpiresByType text/css A2592000
    ExpiresByType application/xhtml+xml A2592000
    
    # Compress output for text
    AddOutputFilterByType DEFLATE text/html text/xml text/css application/x-javascript text/javascript application/javascript
    

    注意:我不确定使用 apache 提供静态文件是否比仅使用 tomcat 提供所有内容要快,我主要使用 apache 进行负载平衡。

    【讨论】:

    • 这是一个很酷的主意;我从来没有考虑过用 Apache HTTPD 面对 GlassFish。我将针对我当前的 GlassFish 配置测试 mod_jk,希望一切都会像您描述的那样顺利。感谢您的快速回复和帮助。
    • 我不确定使用 apache 提供静态文件是否比只使用 tomcat 提供所有文件更快,我主要使用 apache 进行负载平衡。
    猜你喜欢
    • 2011-06-02
    • 1970-01-01
    • 2012-02-27
    • 2014-03-07
    • 1970-01-01
    • 1970-01-01
    • 2023-03-25
    相关资源
    最近更新 更多