- Create the server:
Server jetty = new Server(); - Create a handlerCollection with a ContextHandlerCollection in it:
HandlerCollection hc = new HandlerCollection ();
ContextHandlerCollection contextHandlerCollection = new ContextHandlerCollection();
hc.setHandlers(new Handler[]{contextHandlerCollection});
jetty.setHandler(hc); - Start the server:
server.start(); - Hot deploy your web application:
WebAppContext warWebappContext = new WebAppContext();
//configure it ...
contextHandlerCollection.addHandler(warWebappContext);
warWebappContext.start(); - Hot undeploy your application:
//get the WebAppContext to undeploy...
WebAppContext toUndeploy = getWebAppContextToUndeploy();
//stop it
toUndeploy.stop();
//and remove it from the handler collection
contextHandlerCollection.removeHandler(toUndeploy);In a nutshell, the trick is to use a HandlerCollection for your WebAppContextHandler.
source: http://www.bonitasoft.org/blog/tutorial/programmatic-hot-deploy-with-jetty/
2010年5月18日 星期二
Programmatic hot deploy with Jetty
訂閱:
文章 (Atom)