0

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

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

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

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

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

任何想法将不胜感激。

4

1 回答 1

0

我有一个类似的设置,只是 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 进行负载平衡。

于 2011-12-27T10:05:39.227 回答