Issue #1138
This commit is contained in:
parent
32eff3ffd3
commit
f64cdd46b8
|
@ -25,7 +25,7 @@ public abstract class Descriptor
|
||||||
{
|
{
|
||||||
protected Resource _xml;
|
protected Resource _xml;
|
||||||
protected XmlParser.Node _root;
|
protected XmlParser.Node _root;
|
||||||
protected XmlParser _parser;
|
protected String _dtd;
|
||||||
protected boolean _validating;
|
protected boolean _validating;
|
||||||
|
|
||||||
public Descriptor (Resource xml)
|
public Descriptor (Resource xml)
|
||||||
|
@ -33,9 +33,10 @@ public abstract class Descriptor
|
||||||
_xml = xml;
|
_xml = xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void ensureParser()
|
public abstract XmlParser ensureParser()
|
||||||
throws ClassNotFoundException;
|
throws ClassNotFoundException;
|
||||||
|
|
||||||
|
|
||||||
public void setValidating (boolean validating)
|
public void setValidating (boolean validating)
|
||||||
{
|
{
|
||||||
_validating = validating;
|
_validating = validating;
|
||||||
|
@ -44,14 +45,15 @@ public abstract class Descriptor
|
||||||
public void parse ()
|
public void parse ()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
if (_parser == null)
|
|
||||||
ensureParser();
|
|
||||||
|
|
||||||
if (_root == null)
|
if (_root == null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_root = _parser.parse(_xml.getInputStream());
|
XmlParser parser = ensureParser();
|
||||||
|
_root = parser.parse(_xml.getInputStream());
|
||||||
|
_dtd = parser.getDTD();
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,6 +41,7 @@ public class MetaData
|
||||||
{
|
{
|
||||||
private static final Logger LOG = Log.getLogger(MetaData.class);
|
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 String ORDERED_LIBS = "javax.servlet.context.orderedLibs";
|
||||||
public static final Resource NON_FRAG_RESOURCE = EmptyResource.INSTANCE;
|
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> _orderedContainerResources = new ArrayList<Resource>();
|
||||||
protected final List<Resource> _orderedWebInfResources = 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 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
|
public static class OriginInfo
|
||||||
{
|
{
|
||||||
|
@ -154,13 +156,14 @@ public class MetaData
|
||||||
_orderedWebInfResources.clear();
|
_orderedWebInfResources.clear();
|
||||||
_orderedContainerResources.clear();
|
_orderedContainerResources.clear();
|
||||||
_ordering = null;
|
_ordering = null;
|
||||||
allowDuplicateFragmentNames = false;
|
_allowDuplicateFragmentNames = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDefaults (Resource webDefaults)
|
public void setDefaults (Resource webDefaults)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
_webDefaultsRoot = new DefaultsDescriptor(webDefaults);
|
_webDefaultsRoot = new DefaultsDescriptor(webDefaults);
|
||||||
|
_webDefaultsRoot.setValidating(isValidateXml());
|
||||||
_webDefaultsRoot.parse();
|
_webDefaultsRoot.parse();
|
||||||
if (_webDefaultsRoot.isOrdered())
|
if (_webDefaultsRoot.isOrdered())
|
||||||
{
|
{
|
||||||
|
@ -186,6 +189,7 @@ public class MetaData
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
_webXmlRoot = new WebDescriptor(webXml);
|
_webXmlRoot = new WebDescriptor(webXml);
|
||||||
|
_webXmlRoot.setValidating(isValidateXml());
|
||||||
_webXmlRoot.parse();
|
_webXmlRoot.parse();
|
||||||
_metaDataComplete=_webXmlRoot.getMetaDataComplete() == MetaDataComplete.True;
|
_metaDataComplete=_webXmlRoot.getMetaDataComplete() == MetaDataComplete.True;
|
||||||
|
|
||||||
|
@ -269,6 +273,7 @@ public class MetaData
|
||||||
_webFragmentResourceMap.put(jarResource, descriptor);
|
_webFragmentResourceMap.put(jarResource, descriptor);
|
||||||
_webFragmentRoots.add(descriptor);
|
_webFragmentRoots.add(descriptor);
|
||||||
|
|
||||||
|
descriptor.setValidating(isValidateXml());
|
||||||
descriptor.parse();
|
descriptor.parse();
|
||||||
|
|
||||||
if (descriptor.getName() != null)
|
if (descriptor.getName() != null)
|
||||||
|
@ -647,12 +652,28 @@ public class MetaData
|
||||||
|
|
||||||
public boolean isAllowDuplicateFragmentNames()
|
public boolean isAllowDuplicateFragmentNames()
|
||||||
{
|
{
|
||||||
return allowDuplicateFragmentNames;
|
return _allowDuplicateFragmentNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAllowDuplicateFragmentNames(boolean 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()
|
public Map<String,OriginInfo> getOrigins()
|
||||||
|
|
|
@ -534,6 +534,8 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_metadata.setAllowDuplicateFragmentNames(isAllowDuplicateFragmentNames());
|
_metadata.setAllowDuplicateFragmentNames(isAllowDuplicateFragmentNames());
|
||||||
|
Boolean validate = (Boolean)getAttribute(MetaData.VALIDATE_XML);
|
||||||
|
_metadata.setValidateXml((validate!=null && validate.booleanValue()));
|
||||||
preConfigure();
|
preConfigure();
|
||||||
super.doStart();
|
super.doStart();
|
||||||
postConfigure();
|
postConfigure();
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class WebDescriptor extends Descriptor
|
||||||
{
|
{
|
||||||
private static final Logger LOG = Log.getLogger(WebDescriptor.class);
|
private static final Logger LOG = Log.getLogger(WebDescriptor.class);
|
||||||
|
|
||||||
protected static XmlParser _parserSingleton;
|
protected static XmlParser _nonValidatingStaticParser;
|
||||||
protected MetaDataComplete _metaDataComplete;
|
protected MetaDataComplete _metaDataComplete;
|
||||||
protected int _majorVersion = 3; //default to container version
|
protected int _majorVersion = 3; //default to container version
|
||||||
protected int _minorVersion = 0;
|
protected int _minorVersion = 0;
|
||||||
|
@ -52,18 +52,18 @@ public class WebDescriptor extends Descriptor
|
||||||
protected List<String> _ordering = new ArrayList<String>();
|
protected List<String> _ordering = new ArrayList<String>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ensureParser() throws ClassNotFoundException
|
public XmlParser ensureParser() throws ClassNotFoundException
|
||||||
{
|
{
|
||||||
synchronized (WebDescriptor.class)
|
synchronized (WebDescriptor.class)
|
||||||
{
|
{
|
||||||
if (_parserSingleton == null)
|
if (_nonValidatingStaticParser == null)
|
||||||
_parserSingleton = newParser(isValidating());
|
_nonValidatingStaticParser = newParser(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_parserSingleton.isValidating()==isValidating())
|
if (!isValidating())
|
||||||
_parser = _parserSingleton;
|
return _nonValidatingStaticParser;
|
||||||
else
|
else
|
||||||
_parser = newParser(isValidating());
|
return newParser(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static XmlParser newParser(boolean validating) throws ClassNotFoundException
|
public static XmlParser newParser(boolean validating) throws ClassNotFoundException
|
||||||
|
@ -232,8 +232,8 @@ public class WebDescriptor extends Descriptor
|
||||||
{
|
{
|
||||||
_majorVersion = 2;
|
_majorVersion = 2;
|
||||||
_minorVersion = 3;
|
_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;
|
_majorVersion = 2;
|
||||||
_minorVersion = 2;
|
_minorVersion = 2;
|
||||||
|
|
Loading…
Reference in New Issue