Merge branch 'jetty-8' of ssh://git.eclipse.org/gitroot/jetty/org.eclipse.jetty.project into jetty-8
This commit is contained in:
commit
4fc12483aa
|
@ -2298,9 +2298,15 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server.
|
|||
@Override
|
||||
public JspConfigDescriptor getJspConfigDescriptor()
|
||||
{
|
||||
LOG.warn(__unimplmented);
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setJspConfigDescriptor(JspConfigDescriptor d)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void declareRoles(String... roleNames)
|
||||
{
|
||||
|
|
|
@ -15,6 +15,7 @@ package org.eclipse.jetty.servlet;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.EventListener;
|
||||
|
@ -38,6 +39,8 @@ import javax.servlet.ServletSecurityElement;
|
|||
import javax.servlet.SessionCookieConfig;
|
||||
import javax.servlet.SessionTrackingMode;
|
||||
import javax.servlet.descriptor.JspConfigDescriptor;
|
||||
import javax.servlet.descriptor.JspPropertyGroupDescriptor;
|
||||
import javax.servlet.descriptor.TaglibDescriptor;
|
||||
|
||||
import org.eclipse.jetty.security.ConstraintAware;
|
||||
import org.eclipse.jetty.security.ConstraintSecurityHandler;
|
||||
|
@ -495,6 +498,290 @@ public class ServletContextHandler extends ContextHandler
|
|||
decorator.destroyFilterInstance(filter);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public static class JspPropertyGroup implements JspPropertyGroupDescriptor
|
||||
{
|
||||
private List<String> _urlPatterns = new ArrayList<String>();
|
||||
private String _elIgnored;
|
||||
private String _pageEncoding;
|
||||
private String _scriptingInvalid;
|
||||
private String _isXml;
|
||||
private List<String> _includePreludes = new ArrayList<String>();
|
||||
private List<String> _includeCodas = new ArrayList<String>();
|
||||
private String _deferredSyntaxAllowedAsLiteral;
|
||||
private String _trimDirectiveWhitespaces;
|
||||
private String _defaultContentType;
|
||||
private String _buffer;
|
||||
private String _errorOnUndeclaredNamespace;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @see javax.servlet.descriptor.JspPropertyGroupDescriptor#getUrlPatterns()
|
||||
*/
|
||||
public Collection<String> getUrlPatterns()
|
||||
{
|
||||
return new ArrayList<String>(_urlPatterns); // spec says must be a copy
|
||||
}
|
||||
|
||||
public void addUrlPattern (String s)
|
||||
{
|
||||
if (!_urlPatterns.contains(s))
|
||||
_urlPatterns.add(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.servlet.descriptor.JspPropertyGroupDescriptor#getElIgnored()
|
||||
*/
|
||||
public String getElIgnored()
|
||||
{
|
||||
return _elIgnored;
|
||||
}
|
||||
|
||||
public void setElIgnored (String s)
|
||||
{
|
||||
_elIgnored = s;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.servlet.descriptor.JspPropertyGroupDescriptor#getPageEncoding()
|
||||
*/
|
||||
public String getPageEncoding()
|
||||
{
|
||||
return _pageEncoding;
|
||||
}
|
||||
|
||||
public void setPageEncoding(String pageEncoding)
|
||||
{
|
||||
_pageEncoding = pageEncoding;
|
||||
}
|
||||
|
||||
public void setScriptingInvalid(String scriptingInvalid)
|
||||
{
|
||||
_scriptingInvalid = scriptingInvalid;
|
||||
}
|
||||
|
||||
public void setIsXml(String isXml)
|
||||
{
|
||||
_isXml = isXml;
|
||||
}
|
||||
|
||||
public void setDeferredSyntaxAllowedAsLiteral(String deferredSyntaxAllowedAsLiteral)
|
||||
{
|
||||
_deferredSyntaxAllowedAsLiteral = deferredSyntaxAllowedAsLiteral;
|
||||
}
|
||||
|
||||
public void setTrimDirectiveWhitespaces(String trimDirectiveWhitespaces)
|
||||
{
|
||||
_trimDirectiveWhitespaces = trimDirectiveWhitespaces;
|
||||
}
|
||||
|
||||
public void setDefaultContentType(String defaultContentType)
|
||||
{
|
||||
_defaultContentType = defaultContentType;
|
||||
}
|
||||
|
||||
public void setBuffer(String buffer)
|
||||
{
|
||||
_buffer = buffer;
|
||||
}
|
||||
|
||||
public void setErrorOnUndeclaredNamespace(String errorOnUndeclaredNamespace)
|
||||
{
|
||||
_errorOnUndeclaredNamespace = errorOnUndeclaredNamespace;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.servlet.descriptor.JspPropertyGroupDescriptor#getScriptingInvalid()
|
||||
*/
|
||||
public String getScriptingInvalid()
|
||||
{
|
||||
return _scriptingInvalid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.servlet.descriptor.JspPropertyGroupDescriptor#getIsXml()
|
||||
*/
|
||||
public String getIsXml()
|
||||
{
|
||||
return _isXml;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.servlet.descriptor.JspPropertyGroupDescriptor#getIncludePreludes()
|
||||
*/
|
||||
public Collection<String> getIncludePreludes()
|
||||
{
|
||||
return new ArrayList<String>(_includePreludes); //must be a copy
|
||||
}
|
||||
|
||||
public void addIncludePrelude(String prelude)
|
||||
{
|
||||
if (!_includePreludes.contains(prelude))
|
||||
_includePreludes.add(prelude);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.servlet.descriptor.JspPropertyGroupDescriptor#getIncludeCodas()
|
||||
*/
|
||||
public Collection<String> getIncludeCodas()
|
||||
{
|
||||
return new ArrayList<String>(_includeCodas); //must be a copy
|
||||
}
|
||||
|
||||
public void addIncludeCoda (String coda)
|
||||
{
|
||||
if (!_includeCodas.contains(coda))
|
||||
_includeCodas.add(coda);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.servlet.descriptor.JspPropertyGroupDescriptor#getDeferredSyntaxAllowedAsLiteral()
|
||||
*/
|
||||
public String getDeferredSyntaxAllowedAsLiteral()
|
||||
{
|
||||
return _deferredSyntaxAllowedAsLiteral;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.servlet.descriptor.JspPropertyGroupDescriptor#getTrimDirectiveWhitespaces()
|
||||
*/
|
||||
public String getTrimDirectiveWhitespaces()
|
||||
{
|
||||
return _trimDirectiveWhitespaces;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.servlet.descriptor.JspPropertyGroupDescriptor#getDefaultContentType()
|
||||
*/
|
||||
public String getDefaultContentType()
|
||||
{
|
||||
return _defaultContentType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.servlet.descriptor.JspPropertyGroupDescriptor#getBuffer()
|
||||
*/
|
||||
public String getBuffer()
|
||||
{
|
||||
return _buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.servlet.descriptor.JspPropertyGroupDescriptor#getErrorOnUndeclaredNamespace()
|
||||
*/
|
||||
public String getErrorOnUndeclaredNamespace()
|
||||
{
|
||||
return _errorOnUndeclaredNamespace;
|
||||
}
|
||||
|
||||
public String toString ()
|
||||
{
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("JspPropertyGroupDescriptor:");
|
||||
sb.append(" el-ignored="+_elIgnored);
|
||||
sb.append(" is-xml="+_isXml);
|
||||
sb.append(" page-encoding="+_pageEncoding);
|
||||
sb.append(" scripting-invalid="+_scriptingInvalid);
|
||||
sb.append(" deferred-syntax-allowed-as-literal="+_deferredSyntaxAllowedAsLiteral);
|
||||
sb.append(" trim-directive-whitespaces"+_trimDirectiveWhitespaces);
|
||||
sb.append(" default-content-type="+_defaultContentType);
|
||||
sb.append(" buffer="+_buffer);
|
||||
sb.append(" error-on-undeclared-namespace="+_errorOnUndeclaredNamespace);
|
||||
for (String prelude:_includePreludes)
|
||||
sb.append(" include-prelude="+prelude);
|
||||
for (String coda:_includeCodas)
|
||||
sb.append(" include-coda="+coda);
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public static class TagLib implements TaglibDescriptor
|
||||
{
|
||||
private String _uri;
|
||||
private String _location;
|
||||
|
||||
/**
|
||||
* @see javax.servlet.descriptor.TaglibDescriptor#getTaglibURI()
|
||||
*/
|
||||
public String getTaglibURI()
|
||||
{
|
||||
return _uri;
|
||||
}
|
||||
|
||||
public void setTaglibURI(String uri)
|
||||
{
|
||||
_uri = uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.servlet.descriptor.TaglibDescriptor#getTaglibLocation()
|
||||
*/
|
||||
public String getTaglibLocation()
|
||||
{
|
||||
return _location;
|
||||
}
|
||||
|
||||
public void setTaglibLocation(String location)
|
||||
{
|
||||
_location = location;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return ("TagLibDescriptor: taglib-uri="+_uri+" location="+_location);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public static class JspConfig implements JspConfigDescriptor
|
||||
{
|
||||
private List<TaglibDescriptor> _taglibs = new ArrayList<TaglibDescriptor>();
|
||||
private List<JspPropertyGroupDescriptor> _jspPropertyGroups = new ArrayList<JspPropertyGroupDescriptor>();
|
||||
|
||||
public JspConfig() {}
|
||||
|
||||
/**
|
||||
* @see javax.servlet.descriptor.JspConfigDescriptor#getTaglibs()
|
||||
*/
|
||||
public Collection<TaglibDescriptor> getTaglibs()
|
||||
{
|
||||
return new ArrayList<TaglibDescriptor>(_taglibs);
|
||||
}
|
||||
|
||||
public void addTaglibDescriptor (TaglibDescriptor d)
|
||||
{
|
||||
_taglibs.add(d);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.servlet.descriptor.JspConfigDescriptor#getJspPropertyGroups()
|
||||
*/
|
||||
public Collection<JspPropertyGroupDescriptor> getJspPropertyGroups()
|
||||
{
|
||||
return new ArrayList<JspPropertyGroupDescriptor>(_jspPropertyGroups);
|
||||
}
|
||||
|
||||
public void addJspPropertyGroup(JspPropertyGroupDescriptor g)
|
||||
{
|
||||
_jspPropertyGroups.add(g);
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("JspConfigDescriptor: \n");
|
||||
for (TaglibDescriptor taglib:_taglibs)
|
||||
sb.append(taglib+"\n");
|
||||
for (JspPropertyGroupDescriptor jpg:_jspPropertyGroups)
|
||||
sb.append(jpg+"\n");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public class Context extends ContextHandler.Context
|
||||
{
|
||||
|
@ -863,6 +1150,13 @@ public class ServletContextHandler extends ContextHandler
|
|||
return _jspConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setJspConfigDescriptor(JspConfigDescriptor d)
|
||||
{
|
||||
_jspConfig = d;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void declareRoles(String... roleNames)
|
||||
{
|
||||
|
|
|
@ -18,6 +18,7 @@ import java.io.IOException;
|
|||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
import java.util.EventListener;
|
||||
import java.util.HashSet;
|
||||
|
@ -31,6 +32,9 @@ import javax.servlet.MultipartConfigElement;
|
|||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRegistration;
|
||||
import javax.servlet.SessionTrackingMode;
|
||||
import javax.servlet.descriptor.JspConfigDescriptor;
|
||||
import javax.servlet.descriptor.JspPropertyGroupDescriptor;
|
||||
import javax.servlet.descriptor.TaglibDescriptor;
|
||||
|
||||
import org.eclipse.jetty.security.ConstraintAware;
|
||||
import org.eclipse.jetty.security.ConstraintMapping;
|
||||
|
@ -40,6 +44,9 @@ import org.eclipse.jetty.servlet.FilterHolder;
|
|||
import org.eclipse.jetty.servlet.FilterMapping;
|
||||
import org.eclipse.jetty.servlet.Holder;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler.JspConfig;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler.JspPropertyGroup;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler.TagLib;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.eclipse.jetty.servlet.ServletMapping;
|
||||
import org.eclipse.jetty.util.LazyList;
|
||||
|
@ -1246,6 +1253,18 @@ public class StandardDescriptorProcessor extends IterativeDescriptorProcessor
|
|||
String location = node.getString("taglib-location", false, true);
|
||||
|
||||
context.setResourceAlias(uri, location);
|
||||
|
||||
JspConfig config = (JspConfig)context.getServletHandler().getServletContext().getJspConfigDescriptor();
|
||||
if (config == null)
|
||||
{
|
||||
config = new JspConfig();
|
||||
context.getServletContext().setJspConfigDescriptor(config);
|
||||
}
|
||||
|
||||
TagLib tl = new TagLib();
|
||||
tl.setTaglibLocation(location);
|
||||
tl.setTaglibURI(uri);
|
||||
config.addTaglibDescriptor(tl);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1254,7 +1273,16 @@ public class StandardDescriptorProcessor extends IterativeDescriptorProcessor
|
|||
* @param node
|
||||
*/
|
||||
protected void visitJspConfig(WebAppContext context, Descriptor descriptor, XmlParser.Node node)
|
||||
{
|
||||
{
|
||||
//Additive across web.xml and web-fragment.xml
|
||||
JspConfig config = (JspConfig)context.getServletContext().getJspConfigDescriptor();
|
||||
if (config == null)
|
||||
{
|
||||
config = new JspConfig();
|
||||
context.getServletContext().setJspConfigDescriptor(config);
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < node.size(); i++)
|
||||
{
|
||||
Object o = node.get(i);
|
||||
|
@ -1263,19 +1291,51 @@ public class StandardDescriptorProcessor extends IterativeDescriptorProcessor
|
|||
}
|
||||
|
||||
// Map URLs from jsp property groups to JSP servlet.
|
||||
// this is more JSP stupidness creaping into the servlet spec
|
||||
// this is more JSP stupidness creeping into the servlet spec
|
||||
Iterator<XmlParser.Node> iter = node.iterator("jsp-property-group");
|
||||
List<String> paths = new ArrayList<String>();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
JspPropertyGroup jpg = new JspPropertyGroup();
|
||||
config.addJspPropertyGroup(jpg);
|
||||
XmlParser.Node group = iter.next();
|
||||
|
||||
//url-patterns
|
||||
Iterator<XmlParser.Node> iter2 = group.iterator("url-pattern");
|
||||
while (iter2.hasNext())
|
||||
{
|
||||
String url = iter2.next().toString(false, true);
|
||||
url = normalizePattern(url);
|
||||
paths.add( url);
|
||||
jpg.addUrlPattern(url);
|
||||
}
|
||||
|
||||
jpg.setElIgnored(group.getString("el-ignored", false, true));
|
||||
jpg.setPageEncoding(group.getString("page-encoding", false, true));
|
||||
jpg.setScriptingInvalid(group.getString("scripting-invalid", false, true));
|
||||
jpg.setIsXml(group.getString("is-xml", false, true));
|
||||
jpg.setDeferredSyntaxAllowedAsLiteral(group.getString("deferred-syntax-allowed-as-literal", false, true));
|
||||
jpg.setTrimDirectiveWhitespaces(group.getString("trim-directive-whitespaces", false, true));
|
||||
jpg.setDefaultContentType(group.getString("defaultContentType", false, true));
|
||||
jpg.setBuffer(group.getString("buffer", false, true));
|
||||
jpg.setErrorOnUndeclaredNamespace(group.getString("error-on-undeclared-namespace", false, true));
|
||||
|
||||
//preludes
|
||||
Iterator<XmlParser.Node> preludes = group.iterator("include-prelude");
|
||||
while (preludes.hasNext())
|
||||
{
|
||||
String prelude = preludes.next().toString(false, true);
|
||||
jpg.addIncludePrelude(prelude);
|
||||
}
|
||||
//codas
|
||||
Iterator<XmlParser.Node> codas = group.iterator("include-coda");
|
||||
while (codas.hasNext())
|
||||
{
|
||||
String coda = codas.next().toString(false, true);
|
||||
jpg.addIncludeCoda(coda);
|
||||
}
|
||||
|
||||
if (LOG.isDebugEnabled()) LOG.debug(config.toString());
|
||||
}
|
||||
|
||||
if (paths.size() > 0)
|
||||
|
|
Loading…
Reference in New Issue