2011-12-27 97 views
0

我正在开发使用JPA作为数据访问层的基于GWT的应用程序。我的应用程序需要支持三层架构。主要思想是让带有静态内容的HTTP服务器(Apache)(HTML/javascript等),Web应用服务器(Glassfish)带有业务逻辑(servlets,beans等)和数据库服务器(PostgreSQL)GWT三层体系结构

有没有简单的方法来划分为简单的GWT应用程序生成的战争文件的内容来实现所描述的体系结构?

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

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

我发现非常有趣的文章描述这样的解决方案(full article),但它需要很多工作来实现我的目标。希望有一个简化代理生成过程的库或工具包。

任何想法将不胜感激。

回答

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负载均衡为主。

+0

这是一个很酷的想法;我从来没有考虑过使用Apache HTTPD来管理GlassFish。我将根据当前的GlassFish配置测试mod_jk,希望一切顺利如您所述。感谢您的快速响应和帮助。 – lhanusiak 2011-12-28 06:48:46

+0

我不确定使用apache提供静态文件比仅使用tomcat提供服务更快,我主要使用apache进行负载平衡。 – milan 2011-12-28 10:15:09