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
and web.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.