并行运行Servlet Web应用程序的多个版本 [英] Running multiple versions of a servlet web application parallel

查看:97
本文介绍了并行运行Servlet Web应用程序的多个版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想并行运行多个基于Java Servlet的Web应用程序的多个版本(例如myapp2.1,myapp2.2 ...).

I want to run multiple versions (like myapp2.1, myapp2.2 ...) of several Java Servlet based web applications parallel.

一种可能是将每个版本部署到单独的servlet上下文(应该具有自己的类加载器?!).但是我认为这将很难管理并且不会灵活,因为应用程序是一个很大的块.如果应用程序应包含两个不同版本的服务怎么办?也许这不是一个好主意...

One possibility could be to deploy each version to a separate servlet context (which should have its own class loader?!). But I think it will be hard to manage and won't be flexible, since an application is a quite large block. What if an application should contain a service in two different versions? Maybe that is not a good idea ...

环境将为GlassFish> = 3.0.

The environment will be GlassFish >= 3.0.

并行运行Servlet应用程序的多个版本的更好方法是什么? OSGI可以帮忙吗?

What is a better way to run multiple versions of a servlet application parallel? Could OSGI help?

推荐答案

每个Web应用程序都将使用其自己的ClassLoader(至少我知道的任何容器都可以加载;我无法想象为什么容器不会这样做).因此,它应该可以正常工作.您的课程的不同版本不会互相干扰.

Each web application will be loaded using its own ClassLoader (at least any container I know of; I can't imagine why a container would not do this). So, it should just work. Different versions of your classes will not interfere with one another.

确保不将任何类包含在容器自己的ClassLoader中-例如,将.jar放在Tomcat目录中的lib/中(不确定与Glassfish等效).这将由所有Web应用程序共享,并且将覆盖Web应用程序中的所有内容.

Make sure you do not include any of your classes in the container's own ClassLoader -- for example by putting a .jar in lib/ in Tomcat's directory (not sure of the equivalent for Glassfish). That would be shared by all web applications, and would override whatever is in the web app.

这篇关于并行运行Servlet Web应用程序的多个版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆