Merge remote-tracking branch 'origin/jetty-9.4.x'
This commit is contained in:
commit
bc96a8e0e6
|
@ -25,7 +25,7 @@ public abstract class Descriptor
|
|||
{
|
||||
protected Resource _xml;
|
||||
protected XmlParser.Node _root;
|
||||
protected XmlParser _parser;
|
||||
protected String _dtd;
|
||||
protected boolean _validating;
|
||||
|
||||
public Descriptor (Resource xml)
|
||||
|
@ -33,9 +33,10 @@ public abstract class Descriptor
|
|||
_xml = xml;
|
||||
}
|
||||
|
||||
public abstract void ensureParser()
|
||||
public abstract XmlParser ensureParser()
|
||||
throws ClassNotFoundException;
|
||||
|
||||
|
||||
public void setValidating (boolean validating)
|
||||
{
|
||||
_validating = validating;
|
||||
|
@ -44,14 +45,15 @@ public abstract class Descriptor
|
|||
public void parse ()
|
||||
throws Exception
|
||||
{
|
||||
if (_parser == null)
|
||||
ensureParser();
|
||||
|
||||
|
||||
if (_root == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
_root = _parser.parse(_xml.getInputStream());
|
||||
XmlParser parser = ensureParser();
|
||||
_root = parser.parse(_xml.getInputStream());
|
||||
_dtd = parser.getDTD();
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
@ -41,6 +41,7 @@ public class MetaData
|
|||
{
|
||||
private static final Logger LOG = Log.getLogger(MetaData.class);
|
||||
|
||||
public static final String VALIDATE_XML = "org.eclipse.jetty.webapp.validateXml";
|
||||
public static final String ORDERED_LIBS = "javax.servlet.context.orderedLibs";
|
||||
public static final Resource NON_FRAG_RESOURCE = EmptyResource.INSTANCE;
|
||||
|
||||
|
@ -59,7 +60,8 @@ public class MetaData
|
|||
protected final List<Resource> _orderedContainerResources = new ArrayList<Resource>();
|
||||
protected final List<Resource> _orderedWebInfResources = new ArrayList<Resource>();
|
||||
protected Ordering _ordering;//can be set to RelativeOrdering by web-default.xml, web.xml, web-override.xml
|
||||
protected boolean allowDuplicateFragmentNames = false;
|
||||
protected boolean _allowDuplicateFragmentNames = false;
|
||||
protected boolean _validateXml = false;
|
||||
|
||||
public static class OriginInfo
|
||||
{
|
||||
|
@ -154,13 +156,14 @@ public class MetaData
|
|||
_orderedWebInfResources.clear();
|
||||
_orderedContainerResources.clear();
|
||||
_ordering = null;
|
||||
allowDuplicateFragmentNames = false;
|
||||
_allowDuplicateFragmentNames = false;
|
||||
}
|
||||
|
||||
public void setDefaults (Resource webDefaults)
|
||||
throws Exception
|
||||
{
|
||||
_webDefaultsRoot = new DefaultsDescriptor(webDefaults);
|
||||
_webDefaultsRoot.setValidating(isValidateXml());
|
||||
_webDefaultsRoot.parse();
|
||||
if (_webDefaultsRoot.isOrdered())
|
||||
{
|
||||
|
@ -186,6 +189,7 @@ public class MetaData
|
|||
throws Exception
|
||||
{
|
||||
_webXmlRoot = new WebDescriptor(webXml);
|
||||
_webXmlRoot.setValidating(isValidateXml());
|
||||
_webXmlRoot.parse();
|
||||
_metaDataComplete=_webXmlRoot.getMetaDataComplete() == MetaDataComplete.True;
|
||||
|
||||
|
@ -269,6 +273,7 @@ public class MetaData
|
|||
_webFragmentResourceMap.put(jarResource, descriptor);
|
||||
_webFragmentRoots.add(descriptor);
|
||||
|
||||
descriptor.setValidating(isValidateXml());
|
||||
descriptor.parse();
|
||||
|
||||
if (descriptor.getName() != null)
|
||||
|
@ -647,12 +652,28 @@ public class MetaData
|
|||
|
||||
public boolean isAllowDuplicateFragmentNames()
|
||||
{
|
||||
return allowDuplicateFragmentNames;
|
||||
return _allowDuplicateFragmentNames;
|
||||
}
|
||||
|
||||
public void setAllowDuplicateFragmentNames(boolean allowDuplicateFragmentNames)
|
||||
{
|
||||
this.allowDuplicateFragmentNames = allowDuplicateFragmentNames;
|
||||
this._allowDuplicateFragmentNames = allowDuplicateFragmentNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the validateXml
|
||||
*/
|
||||
public boolean isValidateXml()
|
||||
{
|
||||
return _validateXml;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param validateXml the validateXml to set
|
||||
*/
|
||||
public void setValidateXml(boolean validateXml)
|
||||
{
|
||||
_validateXml = validateXml;
|
||||
}
|
||||
|
||||
public Map<String,OriginInfo> getOrigins()
|
||||
|
|
|
@ -552,6 +552,8 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
|||
try
|
||||
{
|
||||
_metadata.setAllowDuplicateFragmentNames(isAllowDuplicateFragmentNames());
|
||||
Boolean validate = (Boolean)getAttribute(MetaData.VALIDATE_XML);
|
||||
_metadata.setValidateXml((validate!=null && validate.booleanValue()));
|
||||
preConfigure();
|
||||
super.doStart();
|
||||
postConfigure();
|
||||
|
|
|
@ -41,7 +41,7 @@ public class WebDescriptor extends Descriptor
|
|||
{
|
||||
private static final Logger LOG = Log.getLogger(WebDescriptor.class);
|
||||
|
||||
protected static XmlParser _parserSingleton;
|
||||
protected static XmlParser _nonValidatingStaticParser;
|
||||
protected MetaDataComplete _metaDataComplete;
|
||||
protected int _majorVersion = 3; //default to container version
|
||||
protected int _minorVersion = 0;
|
||||
|
@ -52,18 +52,18 @@ public class WebDescriptor extends Descriptor
|
|||
protected List<String> _ordering = new ArrayList<String>();
|
||||
|
||||
@Override
|
||||
public void ensureParser() throws ClassNotFoundException
|
||||
public XmlParser ensureParser() throws ClassNotFoundException
|
||||
{
|
||||
synchronized (WebDescriptor.class)
|
||||
{
|
||||
if (_parserSingleton == null)
|
||||
_parserSingleton = newParser(isValidating());
|
||||
if (_nonValidatingStaticParser == null)
|
||||
_nonValidatingStaticParser = newParser(false);
|
||||
}
|
||||
|
||||
if (_parserSingleton.isValidating()==isValidating())
|
||||
_parser = _parserSingleton;
|
||||
if (!isValidating())
|
||||
return _nonValidatingStaticParser;
|
||||
else
|
||||
_parser = newParser(isValidating());
|
||||
return newParser(true);
|
||||
}
|
||||
|
||||
public static XmlParser newParser(boolean validating) throws ClassNotFoundException
|
||||
|
@ -232,8 +232,8 @@ public class WebDescriptor extends Descriptor
|
|||
{
|
||||
_majorVersion = 2;
|
||||
_minorVersion = 3;
|
||||
String dtd = _parser.getDTD();
|
||||
if (dtd != null && dtd.indexOf("web-app_2_2") >= 0)
|
||||
|
||||
if (_dtd != null && _dtd.indexOf("web-app_2_2") >= 0)
|
||||
{
|
||||
_majorVersion = 2;
|
||||
_minorVersion = 2;
|
||||
|
|
|
@ -527,8 +527,10 @@ public class XmlConfiguration
|
|||
Method set = null;
|
||||
for (int s = 0; sets != null && s < sets.length; s++)
|
||||
{
|
||||
if (sets[s].getParameterCount()!=1)
|
||||
continue;
|
||||
Class<?>[] paramTypes = sets[s].getParameterTypes();
|
||||
if (name.equals(sets[s].getName()) && paramTypes.length == 1)
|
||||
if (name.equals(sets[s].getName()))
|
||||
{
|
||||
// lets try it
|
||||
try
|
||||
|
|
Loading…
Reference in New Issue