{
final AbstractNetworkConnector jettyConnector = createJettyConnector();
configureConnector(jettyConnector, webappsConfiguration.getHost(), webappsConfiguration.getPort());
DeploymentManager deploymentManager = new DeploymentManager();
WebAppProvider webAppProvider = new WebAppProvider()
{
@Override
public ContextHandler createContextHandler(App app) throws Exception
{
WebAppContext webAppContext = (WebAppContext) super.createContextHandler(app);
if (webappsConfiguration.getServerClasses() != null)
{
webAppContext.setServerClasses(webappsConfiguration.getServerClasses());
}
if (webappsConfiguration.getSystemClasses() != null)
{
webAppContext.setSystemClasses(webappsConfiguration.getSystemClasses());
}
File workDir = new File(muleContext.getConfiguration().getWorkingDirectory(),
"_exploded_wars" + webAppContext.getContextPath());
workDir.mkdirs();
webAppContext.setTempDirectory(workDir);
webAppContext.setAttribute(MULE_CONTEXT_ATTRIBUTE, muleContext);
webAppContext.setVirtualHosts(new String[] {getVirtualHostName(jettyConnector)});
if (logger.isInfoEnabled())
{
String msg = String.format("Will deploy a web app at %s://%s%s%s",
"http", jettyConnector.getHost(),
jettyConnector.getPort() == 80 ? StringUtils.EMPTY : ":" + jettyConnector.getPort(),
webAppContext.getContextPath());
logger.info(StringMessageUtils.getBoilerPlate(msg, '*', 70));
}
return webAppContext;
}
};
deploymentManager.setContexts(contexts);
deploymentManager.addAppProvider(webAppProvider);
String webAppDir = webappsConfiguration.getDirectory();
if (StringUtils.isBlank(webAppDir))
{
// if none specified, resolve defaults dynamically