Let's say I want to allow my developers to upload their war
files to a web app (not the application server itself) running on our intranet and that web app would then run those wars as if they were separate apps deployed individually in our J2EE container.
In other words, we are not actually deploying the wars
as sep开发者_Go百科arate apps in the container - they are simply running side-by-side inside this one web app that acts like a J2EE container.
Is that possible?
Something like a war
virtualization app?
You could start creating ClassLoader
, expanding the .war
, loading the classes and dispatching the request to your application to the right sub web app. That looks like re-inventing the wheel (given that the app. server does that already) and is probably very complicated.
On the other side, this looks terribly similar to how portlets
work. Portlets are packaged into a .war
file and are then used by the portal. For instance, in Liferay portal, you can upload a portlet .war
from the liferay portal (not the app. server itself). Liferay will then place the uploaded .war
file in the auto-deploy directory of the app. server which will then be deployed like a regular web app. Then there is the portlet bridge that dispatch the request from the portal to the right portlet web app, etc. It's maybe worth having a closer look at that.
I don't know your requirements, but I would definitively try do keep it simple as such stuff can get really complicated. But you could:
- Let user upload the
.war
from you application - Manipulate the
.war
andweb.xml
to ensure that the context is something like/ParentApp/ChildApp
- Save the modified
.war
to the auto-deploy folder and let the app. server deploy it
This will provide the illusion the you can deploy sub webapp from your parent webapp.
Is there any specific reason why you need them to run side the context of another war? Sounds like what you need to do to achieve your goal - it's probably impossible to do if you're running it inside your war - is to build a war which then takes that war they upload and uses the API for deploying wars that the web server exposes to deploy the war and thus let it run as a top level web app. I don't think there's any other way to do it.
精彩评论