GWT三层架构

发布于 2024-12-22 18:19:46 字数 611 浏览 2 评论 0原文

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

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

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

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

我发现描述这种解决方案的非常有趣的文章(完整文章< /a>),但要实现我的目标需要做很多工作。希望有一个库或工具包可以简化代理生成过程。

任何想法都将不胜感激。

I am developing GWT based application using JPA as data access layer. My application is required to support three-tier architecture. Main idea is to have HTTP server (Apache) with static content (html/javascript etc.), Web Application server (Glassfish) with business logic (servlets, beans, etc.) and Database server (PostgreSQL).

Is there any easy way to divide content of war file generated for simple GWT application to achieve described architecture?

Maybe there is a maven plugin which will help in creating separate war files with static content and business logic.

I was also considering creating proxy which will intercept GWT-RPC calls and invoke business methods on remote server.

I found very interesting article describing such solution (full article) but it requires a lot of work to achieve my goal. Hopefully there is a library or toolkit which will simplify proxy generation process.

Any ideas will be greatly appreciated.

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

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

发布评论

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

评论(1

隐诗 2024-12-29 18:19:46

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

I have a similar setup, just Tomcat instead of Glassfish, and maven to build everything. Here's how it works. Apache httpd and Tomcat are connected with mod_jk. Apache forwards all requests to Tomcat except for the GWT module dir (lets call it gwt_module), which contains all the GWT compiled stuff - that gets served by Apache and is configured to be cached.
The rest - servlets basically, gets forwarded to Tomcat (RPC, RequestFactory, other servlets). MongoDB as a database server.

Here's the relevant httpd.conf section:

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

Note: I'm not sure that serving static files with apache is faster than serving everything with only tomcat, I use apache for load balancing primarily.

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