470803 If a webapp is not fully started do not fully stop it
This commit is contained in:
parent
8a64c50f24
commit
3ac6a727cf
|
@ -131,7 +131,7 @@ public class JettyWebAppContext extends WebAppContext
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
public JettyWebAppContext ()
|
public JettyWebAppContext ()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
@ -139,71 +139,81 @@ public class JettyWebAppContext extends WebAppContext
|
||||||
// Turn off copyWebInf option as it is not applicable for plugin.
|
// Turn off copyWebInf option as it is not applicable for plugin.
|
||||||
super.setCopyWebInf(false);
|
super.setCopyWebInf(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
public void setContainerIncludeJarPattern(String pattern)
|
public void setContainerIncludeJarPattern(String pattern)
|
||||||
{
|
{
|
||||||
_containerIncludeJarPattern = pattern;
|
_containerIncludeJarPattern = pattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
public String getContainerIncludeJarPattern()
|
public String getContainerIncludeJarPattern()
|
||||||
{
|
{
|
||||||
return _containerIncludeJarPattern;
|
return _containerIncludeJarPattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
public String getWebInfIncludeJarPattern()
|
public String getWebInfIncludeJarPattern()
|
||||||
{
|
{
|
||||||
return _webInfIncludeJarPattern;
|
return _webInfIncludeJarPattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
public void setWebInfIncludeJarPattern(String pattern)
|
public void setWebInfIncludeJarPattern(String pattern)
|
||||||
{
|
{
|
||||||
_webInfIncludeJarPattern = pattern;
|
_webInfIncludeJarPattern = pattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
public List<File> getClassPathFiles()
|
public List<File> getClassPathFiles()
|
||||||
{
|
{
|
||||||
return this._classpathFiles;
|
return this._classpathFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
public void setJettyEnvXml (String jettyEnvXml)
|
public void setJettyEnvXml (String jettyEnvXml)
|
||||||
{
|
{
|
||||||
this._jettyEnvXml = jettyEnvXml;
|
this._jettyEnvXml = jettyEnvXml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
public String getJettyEnvXml()
|
public String getJettyEnvXml()
|
||||||
{
|
{
|
||||||
return this._jettyEnvXml;
|
return this._jettyEnvXml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
public void setClasses(File dir)
|
public void setClasses(File dir)
|
||||||
{
|
{
|
||||||
_classes = dir;
|
_classes = dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
public File getClasses()
|
public File getClasses()
|
||||||
{
|
{
|
||||||
return _classes;
|
return _classes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
public void setWebInfLib (List<File> jars)
|
public void setWebInfLib (List<File> jars)
|
||||||
{
|
{
|
||||||
_webInfJars.addAll(jars);
|
_webInfJars.addAll(jars);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
public void setTestClasses (File dir)
|
public void setTestClasses (File dir)
|
||||||
{
|
{
|
||||||
_testClasses = dir;
|
_testClasses = dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
public File getTestClasses ()
|
public File getTestClasses ()
|
||||||
{
|
{
|
||||||
return _testClasses;
|
return _testClasses;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
/**
|
/**
|
||||||
* Ordered list of wars to overlay on top of the current project. The list
|
* Ordered list of wars to overlay on top of the current project. The list
|
||||||
* may contain an overlay that represents the current project.
|
* may contain an overlay that represents the current project.
|
||||||
|
@ -214,6 +224,7 @@ public class JettyWebAppContext extends WebAppContext
|
||||||
_overlays = overlays;
|
_overlays = overlays;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
public List<Overlay> getOverlays()
|
public List<Overlay> getOverlays()
|
||||||
{
|
{
|
||||||
return _overlays;
|
return _overlays;
|
||||||
|
@ -261,17 +272,20 @@ public class JettyWebAppContext extends WebAppContext
|
||||||
|
|
||||||
setBaseResource(new ResourceCollection(resources.toArray(new String[resources.size()])));
|
setBaseResource(new ResourceCollection(resources.toArray(new String[resources.size()])));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
public List<File> getWebInfLib()
|
public List<File> getWebInfLib()
|
||||||
{
|
{
|
||||||
return _webInfJars;
|
return _webInfJars;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
public void setGenerateQuickStart (boolean quickStart)
|
public void setGenerateQuickStart (boolean quickStart)
|
||||||
{
|
{
|
||||||
_isGenerateQuickStart = quickStart;
|
_isGenerateQuickStart = quickStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
public boolean isGenerateQuickStart()
|
public boolean isGenerateQuickStart()
|
||||||
{
|
{
|
||||||
return _isGenerateQuickStart;
|
return _isGenerateQuickStart;
|
||||||
|
@ -279,7 +293,7 @@ public class JettyWebAppContext extends WebAppContext
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
@Override
|
@Override
|
||||||
protected void startWebapp() throws Exception
|
protected void startWebapp() throws Exception
|
||||||
{
|
{
|
||||||
|
@ -295,10 +309,24 @@ public class JettyWebAppContext extends WebAppContext
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (LOG.isDebugEnabled()) { LOG.debug("Calling full start on webapp");}
|
||||||
super.startWebapp();
|
super.startWebapp();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
|
@Override
|
||||||
|
protected void stopWebapp() throws Exception
|
||||||
|
{
|
||||||
|
if (isGenerateQuickStart())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (LOG.isDebugEnabled()) { LOG.debug("Calling stop of fully started webapp");}
|
||||||
|
super.stopWebapp();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
@Override
|
@Override
|
||||||
public void doStart () throws Exception
|
public void doStart () throws Exception
|
||||||
{
|
{
|
||||||
|
@ -315,7 +343,6 @@ public class JettyWebAppContext extends WebAppContext
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//inject configurations with config from maven plugin
|
//inject configurations with config from maven plugin
|
||||||
for (Configuration c:getConfigurations())
|
for (Configuration c:getConfigurations())
|
||||||
{
|
{
|
||||||
|
@ -369,7 +396,9 @@ public class JettyWebAppContext extends WebAppContext
|
||||||
// CHECK setShutdown(false);
|
// CHECK setShutdown(false);
|
||||||
super.doStart();
|
super.doStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
public void doStop () throws Exception
|
public void doStop () throws Exception
|
||||||
{
|
{
|
||||||
if (_classpathFiles != null)
|
if (_classpathFiles != null)
|
||||||
|
@ -390,8 +419,9 @@ public class JettyWebAppContext extends WebAppContext
|
||||||
// CHECK setShutdown(true);
|
// CHECK setShutdown(true);
|
||||||
//just wait a little while to ensure no requests are still being processed
|
//just wait a little while to ensure no requests are still being processed
|
||||||
Thread.currentThread().sleep(500L);
|
Thread.currentThread().sleep(500L);
|
||||||
|
|
||||||
super.doStop();
|
super.doStop();
|
||||||
|
|
||||||
//remove all listeners, servlets and filters. This is because we will re-apply
|
//remove all listeners, servlets and filters. This is because we will re-apply
|
||||||
//any context xml file, which means they would potentially be added multiple times.
|
//any context xml file, which means they would potentially be added multiple times.
|
||||||
setEventListeners(new EventListener[0]);
|
setEventListeners(new EventListener[0]);
|
||||||
|
@ -400,7 +430,9 @@ public class JettyWebAppContext extends WebAppContext
|
||||||
getServletHandler().setServlets(new ServletHolder[0]);
|
getServletHandler().setServlets(new ServletHolder[0]);
|
||||||
getServletHandler().setServletMappings(new ServletMapping[0]);
|
getServletHandler().setServletMappings(new ServletMapping[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
@Override
|
@Override
|
||||||
public Resource getResource(String uriInContext) throws MalformedURLException
|
public Resource getResource(String uriInContext) throws MalformedURLException
|
||||||
{
|
{
|
||||||
|
@ -474,7 +506,9 @@ public class JettyWebAppContext extends WebAppContext
|
||||||
}
|
}
|
||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getResourcePaths(String path)
|
public Set<String> getResourcePaths(String path)
|
||||||
{
|
{
|
||||||
|
@ -511,7 +545,7 @@ public class JettyWebAppContext extends WebAppContext
|
||||||
return paths;
|
return paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
public String addPattern (String s, String pattern)
|
public String addPattern (String s, String pattern)
|
||||||
{
|
{
|
||||||
if (s == null)
|
if (s == null)
|
||||||
|
@ -529,6 +563,8 @@ public class JettyWebAppContext extends WebAppContext
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
public void initCDI()
|
public void initCDI()
|
||||||
{
|
{
|
||||||
Class cdiInitializer = null;
|
Class cdiInitializer = null;
|
||||||
|
|
|
@ -104,6 +104,17 @@ public class QuickStartWebApp extends WebAppContext
|
||||||
super.startWebapp();
|
super.startWebapp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void stopWebapp() throws Exception
|
||||||
|
{
|
||||||
|
if (!_startWebapp)
|
||||||
|
return;
|
||||||
|
|
||||||
|
super.stopWebapp();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doStart() throws Exception
|
protected void doStart() throws Exception
|
||||||
{
|
{
|
||||||
|
|
|
@ -772,6 +772,24 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
|
protected void stopContext () throws Exception
|
||||||
|
{
|
||||||
|
//stop all the handler hierarchy
|
||||||
|
super.doStop();
|
||||||
|
|
||||||
|
//Call the context listeners
|
||||||
|
if (!_contextListeners.isEmpty())
|
||||||
|
{
|
||||||
|
ServletContextEvent event = new ServletContextEvent(_scontext);
|
||||||
|
for (int i = _contextListeners.size(); i-->0;)
|
||||||
|
callContextDestroyed(_contextListeners.get(i),event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
protected void callContextInitialized (ServletContextListener l, ServletContextEvent e)
|
protected void callContextInitialized (ServletContextListener l, ServletContextEvent e)
|
||||||
{
|
{
|
||||||
|
@ -812,15 +830,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
|
||||||
current_thread.setContextClassLoader(_classLoader);
|
current_thread.setContextClassLoader(_classLoader);
|
||||||
}
|
}
|
||||||
|
|
||||||
super.doStop();
|
stopContext();
|
||||||
|
|
||||||
// Context listeners
|
|
||||||
if (!_contextListeners.isEmpty())
|
|
||||||
{
|
|
||||||
ServletContextEvent event = new ServletContextEvent(_scontext);
|
|
||||||
for (int i = _contextListeners.size(); i-->0;)
|
|
||||||
callContextDestroyed(_contextListeners.get(i),event);
|
|
||||||
}
|
|
||||||
|
|
||||||
//retain only durable listeners
|
//retain only durable listeners
|
||||||
setEventListeners(_durableListeners.toArray(new EventListener[_durableListeners.size()]));
|
setEventListeners(_durableListeners.toArray(new EventListener[_durableListeners.size()]));
|
||||||
|
@ -844,7 +854,9 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
|
||||||
|
|
||||||
_scontext.clearAttributes();
|
_scontext.clearAttributes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
public boolean checkVirtualHost(final Request baseRequest)
|
public boolean checkVirtualHost(final Request baseRequest)
|
||||||
{
|
{
|
||||||
if (_vhosts != null && _vhosts.length > 0)
|
if (_vhosts != null && _vhosts.length > 0)
|
||||||
|
@ -884,7 +896,9 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
public boolean checkContextPath(String uri)
|
public boolean checkContextPath(String uri)
|
||||||
{
|
{
|
||||||
// Are we not the root context?
|
// Are we not the root context?
|
||||||
|
|
|
@ -251,6 +251,7 @@ public class ServletContextHandler extends ContextHandler
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
@Override
|
@Override
|
||||||
protected void doStart() throws Exception
|
protected void doStart() throws Exception
|
||||||
{
|
{
|
||||||
|
@ -344,6 +345,13 @@ public class ServletContextHandler extends ContextHandler
|
||||||
if (_servletHandler != null)
|
if (_servletHandler != null)
|
||||||
_servletHandler.initialize();
|
_servletHandler.initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
|
@Override
|
||||||
|
protected void stopContext() throws Exception
|
||||||
|
{
|
||||||
|
super.stopContext();
|
||||||
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -534,25 +534,6 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
||||||
protected void doStop() throws Exception
|
protected void doStop() throws Exception
|
||||||
{
|
{
|
||||||
super.doStop();
|
super.doStop();
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
for (int i=_configurations.size();i-->0;)
|
|
||||||
_configurations.get(i).deconfigure(this);
|
|
||||||
|
|
||||||
if (_metadata != null)
|
|
||||||
_metadata.clear();
|
|
||||||
_metadata=new MetaData();
|
|
||||||
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
if (_ownClassLoader)
|
|
||||||
setClassLoader(null);
|
|
||||||
|
|
||||||
setAvailable(true);
|
|
||||||
_unavailableException=null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -1354,6 +1335,32 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
||||||
|
|
||||||
startWebapp();
|
startWebapp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
|
@Override
|
||||||
|
protected void stopContext() throws Exception
|
||||||
|
{
|
||||||
|
stopWebapp();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
for (int i=_configurations.size();i-->0;)
|
||||||
|
_configurations.get(i).deconfigure(this);
|
||||||
|
|
||||||
|
if (_metadata != null)
|
||||||
|
_metadata.clear();
|
||||||
|
_metadata=new MetaData();
|
||||||
|
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (_ownClassLoader)
|
||||||
|
setClassLoader(null);
|
||||||
|
|
||||||
|
setAvailable(true);
|
||||||
|
_unavailableException=null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
protected void startWebapp()
|
protected void startWebapp()
|
||||||
|
@ -1362,6 +1369,11 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
||||||
super.startContext();
|
super.startContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
|
protected void stopWebapp() throws Exception
|
||||||
|
{
|
||||||
|
super.stopContext();
|
||||||
|
}
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
@Override
|
@Override
|
||||||
public Set<String> setServletSecurity(Dynamic registration, ServletSecurityElement servletSecurityElement)
|
public Set<String> setServletSecurity(Dynamic registration, ServletSecurityElement servletSecurityElement)
|
||||||
|
|
Loading…
Reference in New Issue