327725 multiple web.xml overrides
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2347 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
e3fe523cc7
commit
1261de5cdc
|
@ -40,7 +40,7 @@ public class MetaData
|
|||
protected Map<String, OriginInfo> _origins =new HashMap<String,OriginInfo>();
|
||||
protected WebDescriptor _webDefaultsRoot;
|
||||
protected WebDescriptor _webXmlRoot;
|
||||
protected WebDescriptor _webOverrideRoot;
|
||||
protected final List<WebDescriptor> _webOverrideRoots=new ArrayList<WebDescriptor>();
|
||||
protected boolean _metaDataComplete;
|
||||
protected final List<DiscoveredAnnotation> _annotations = new ArrayList<DiscoveredAnnotation>();
|
||||
protected final List<DescriptorProcessor> _descriptorProcessors = new ArrayList<DescriptorProcessor>();
|
||||
|
@ -152,14 +152,14 @@ public class MetaData
|
|||
}
|
||||
}
|
||||
|
||||
public void setOverride (Resource override)
|
||||
public void addOverride (Resource override)
|
||||
throws Exception
|
||||
{
|
||||
_webOverrideRoot = new OverrideDescriptor(override);
|
||||
_webOverrideRoot.setValidating(false);
|
||||
_webOverrideRoot.parse();
|
||||
OverrideDescriptor webOverrideRoot = new OverrideDescriptor(override);
|
||||
webOverrideRoot.setValidating(false);
|
||||
webOverrideRoot.parse();
|
||||
|
||||
switch(_webOverrideRoot.getMetaDataComplete())
|
||||
switch(webOverrideRoot.getMetaDataComplete())
|
||||
{
|
||||
case True:
|
||||
_metaDataComplete=true;
|
||||
|
@ -171,12 +171,12 @@ public class MetaData
|
|||
break;
|
||||
}
|
||||
|
||||
if (_webOverrideRoot.isOrdered())
|
||||
if (webOverrideRoot.isOrdered())
|
||||
{
|
||||
if (_ordering == null)
|
||||
_ordering = new Ordering.AbsoluteOrdering(this);
|
||||
|
||||
List<String> order = _webOverrideRoot.getOrdering();
|
||||
List<String> order = webOverrideRoot.getOrdering();
|
||||
for (String s:order)
|
||||
{
|
||||
if (s.equalsIgnoreCase("others"))
|
||||
|
@ -185,6 +185,7 @@ public class MetaData
|
|||
((Ordering.AbsoluteOrdering)_ordering).add(s);
|
||||
}
|
||||
}
|
||||
_webOverrideRoots.add(webOverrideRoot);
|
||||
}
|
||||
|
||||
|
||||
|
@ -281,7 +282,8 @@ public class MetaData
|
|||
{
|
||||
p.process(context,getWebDefault());
|
||||
p.process(context,getWebXml());
|
||||
p.process(context,getOverrideWeb());
|
||||
for (WebDescriptor wd : getOverrideWebs())
|
||||
p.process(context,wd);
|
||||
}
|
||||
|
||||
for (DiscoveredAnnotation a:_annotations)
|
||||
|
@ -314,9 +316,11 @@ public class MetaData
|
|||
{
|
||||
boolean distributable = (
|
||||
(_webDefaultsRoot != null && _webDefaultsRoot.isDistributable())
|
||||
|| (_webXmlRoot != null && _webXmlRoot.isDistributable())
|
||||
|| (_webOverrideRoot != null && _webOverrideRoot.isDistributable()));
|
||||
|
||||
|| (_webXmlRoot != null && _webXmlRoot.isDistributable()));
|
||||
|
||||
for (WebDescriptor d : _webOverrideRoots)
|
||||
distributable&=d.isDistributable();
|
||||
|
||||
List<Resource> orderedResources = getOrderedWebInfJars();
|
||||
for (Resource r: orderedResources)
|
||||
{
|
||||
|
@ -333,9 +337,9 @@ public class MetaData
|
|||
return _webXmlRoot;
|
||||
}
|
||||
|
||||
public WebDescriptor getOverrideWeb ()
|
||||
public List<WebDescriptor> getOverrideWebs ()
|
||||
{
|
||||
return _webOverrideRoot;
|
||||
return _webOverrideRoots;
|
||||
}
|
||||
|
||||
public WebDescriptor getWebDefault ()
|
||||
|
|
|
@ -18,6 +18,8 @@ import java.io.IOException;
|
|||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.security.PermissionCollection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.EventListener;
|
||||
import java.util.HashMap;
|
||||
|
@ -118,7 +120,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
|||
private Configuration[] _configurations;
|
||||
private String _defaultsDescriptor=WEB_DEFAULTS_XML;
|
||||
private String _descriptor=null;
|
||||
private String _overrideDescriptor=null;
|
||||
private final List<String> _overrideDescriptors = new ArrayList<String>();
|
||||
private boolean _distributable=false;
|
||||
private boolean _extractWAR=true;
|
||||
private boolean _copyDir=false;
|
||||
|
@ -578,10 +580,23 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
|||
/**
|
||||
* The override descriptor is a web.xml format file that is applied to the context after the standard WEB-INF/web.xml
|
||||
* @return Returns the Override Descriptor.
|
||||
* @deprecated use {@link #getOverrideDescriptors()}
|
||||
*/
|
||||
public String getOverrideDescriptor()
|
||||
{
|
||||
return _overrideDescriptor;
|
||||
if (_overrideDescriptors.size()!=1)
|
||||
return null;
|
||||
return _overrideDescriptors.get(0);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* An override descriptor is a web.xml format file that is applied to the context after the standard WEB-INF/web.xml
|
||||
* @return Returns the Override Descriptor list
|
||||
*/
|
||||
public List<String> getOverrideDescriptors()
|
||||
{
|
||||
return Collections.unmodifiableList(_overrideDescriptors);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -841,10 +856,23 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
|||
/**
|
||||
* The override descriptor is a web.xml format file that is applied to the context after the standard WEB-INF/web.xml
|
||||
* @param overrideDescriptor The overrideDescritpor to set.
|
||||
* @deprecated use {@link #setOverrideDescriptors(List)}
|
||||
*/
|
||||
public void setOverrideDescriptor(String overrideDescriptor)
|
||||
{
|
||||
_overrideDescriptor = overrideDescriptor;
|
||||
_overrideDescriptors.clear();
|
||||
_overrideDescriptors.add(overrideDescriptor);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* The override descriptor is a web.xml format file that is applied to the context after the standard WEB-INF/web.xml
|
||||
* @param overrideDescriptor The overrideDescritpor to set.
|
||||
*/
|
||||
public void setOverrideDescriptors(List<String> overrideDescriptors)
|
||||
{
|
||||
_overrideDescriptors.clear();
|
||||
_overrideDescriptors.addAll(overrideDescriptors);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
|
@ -14,6 +14,7 @@ package org.eclipse.jetty.webapp;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jetty.servlet.ErrorPageErrorHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHandler;
|
||||
|
@ -30,8 +31,6 @@ public class WebXmlConfiguration extends AbstractConfiguration
|
|||
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
|
@ -45,7 +44,6 @@ public class WebXmlConfiguration extends AbstractConfiguration
|
|||
if (dftResource == null)
|
||||
dftResource = context.newResource(defaultsDescriptor);
|
||||
context.getMetaData().setDefaults (dftResource);
|
||||
|
||||
}
|
||||
|
||||
//parse, but don't process web.xml
|
||||
|
@ -56,13 +54,15 @@ public class WebXmlConfiguration extends AbstractConfiguration
|
|||
}
|
||||
|
||||
//parse but don't process override-web.xml
|
||||
String overrideDescriptor = context.getOverrideDescriptor();
|
||||
if (overrideDescriptor != null && overrideDescriptor.length() > 0)
|
||||
for (String overrideDescriptor : context.getOverrideDescriptors())
|
||||
{
|
||||
Resource orideResource = Resource.newSystemResource(overrideDescriptor);
|
||||
if (orideResource == null)
|
||||
orideResource = context.newResource(overrideDescriptor);
|
||||
context.getMetaData().setOverride(orideResource);
|
||||
if (overrideDescriptor != null && overrideDescriptor.length() > 0)
|
||||
{
|
||||
Resource orideResource = Resource.newSystemResource(overrideDescriptor);
|
||||
if (orideResource == null)
|
||||
orideResource = context.newResource(overrideDescriptor);
|
||||
context.getMetaData().addOverride(orideResource);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue