Issue #490 serverClasses set from jetty-web.xml
Provided a mode that ignores server classes, but still allows them to be edited.
This commit is contained in:
parent
4b94aa2c97
commit
d9bfc8b8e0
|
@ -19,6 +19,7 @@
|
|||
package org.eclipse.jetty.webapp;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
@ -77,39 +78,35 @@ public class JettyWebXmlConfiguration extends AbstractConfiguration
|
|||
jetty=web_inf.addPath("web-jetty.xml");
|
||||
|
||||
if(jetty.exists())
|
||||
{
|
||||
// No server classes while configuring
|
||||
String[] old_server_classes = context.getServerClasses();
|
||||
{
|
||||
if(LOG.isDebugEnabled())
|
||||
LOG.debug("Configure: "+jetty);
|
||||
|
||||
Object xml_attr=context.getAttribute(XML_CONFIGURATION);
|
||||
context.removeAttribute(XML_CONFIGURATION);
|
||||
|
||||
final XmlConfiguration jetty_config = xml_attr instanceof XmlConfiguration
|
||||
?(XmlConfiguration)xml_attr
|
||||
:new XmlConfiguration(jetty.getURI().toURL());
|
||||
setupXmlConfiguration(jetty_config, web_inf);
|
||||
|
||||
try
|
||||
{
|
||||
context.setServerClasses(null);
|
||||
if(LOG.isDebugEnabled())
|
||||
LOG.debug("Configure: "+jetty);
|
||||
|
||||
XmlConfiguration jetty_config = (XmlConfiguration)context.getAttribute(XML_CONFIGURATION);
|
||||
|
||||
if (jetty_config==null)
|
||||
final XmlConfiguration config=jetty_config;
|
||||
context.runWithoutCheckingServerClasses(new Callable<Void>()
|
||||
{
|
||||
jetty_config=new XmlConfiguration(jetty.getURL());
|
||||
}
|
||||
else
|
||||
{
|
||||
context.removeAttribute(XML_CONFIGURATION);
|
||||
}
|
||||
setupXmlConfiguration(jetty_config, web_inf);
|
||||
try
|
||||
{
|
||||
jetty_config.configure(context);
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
LOG.warn("Unable to process jetty-web.xml", e);
|
||||
}
|
||||
@Override
|
||||
public Void call() throws Exception
|
||||
{
|
||||
config.configure(context);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
finally
|
||||
catch(Exception e)
|
||||
{
|
||||
if (old_server_classes != null)
|
||||
context.setServerClasses(old_server_classes);
|
||||
LOG.warn("Error applying {}",jetty);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletRegistration.Dynamic;
|
||||
|
@ -185,6 +186,8 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
|||
private boolean _configurationDiscovered=true;
|
||||
private boolean _allowDuplicateFragmentNames = false;
|
||||
private boolean _throwUnavailableOnStartupException = false;
|
||||
private boolean _checkingServerClasses = true;
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -747,11 +750,33 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
|||
|
||||
_systemClasses.prependPattern(classOrPackage);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Call a Callable for which all calls to {@link #isServerClass(String)}
|
||||
* will return false.
|
||||
* @param callable The callable to call.
|
||||
* @throws Exception Any exception thrown by the Callable
|
||||
*/
|
||||
public void runWithoutCheckingServerClasses(Callable<Void> callable) throws Exception
|
||||
{
|
||||
_checkingServerClasses=false;
|
||||
try
|
||||
{
|
||||
callable.call();
|
||||
}
|
||||
finally
|
||||
{
|
||||
_checkingServerClasses=true;
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public boolean isServerClass(String name)
|
||||
{
|
||||
if (!_checkingServerClasses)
|
||||
return false;
|
||||
|
||||
if (_serverClasses == null)
|
||||
loadServerClasses();
|
||||
|
||||
|
|
Loading…
Reference in New Issue