Updated for servlet 4.0 schemas
This commit is contained in:
parent
7af59b8cc2
commit
8e7cdd8371
|
@ -343,7 +343,7 @@ public class WebAppProvider extends ScanningAppProvider
|
|||
context = "/" + context;
|
||||
}
|
||||
|
||||
webAppContext.setContextPath(context);
|
||||
webAppContext.setDefaultContextPath(context);
|
||||
webAppContext.setWar(file.getAbsolutePath());
|
||||
initializeWebAppContextDefaults(webAppContext);
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ public class MockAppProvider extends AbstractLifeCycle implements AppProvider
|
|||
if (path.endsWith("/") && path.length() > 0)
|
||||
path = path.substring(0,path.length() - 1);
|
||||
|
||||
context.setContextPath(path);
|
||||
context.setDefaultContextPath(path);
|
||||
|
||||
return context;
|
||||
}
|
||||
|
|
|
@ -219,7 +219,7 @@
|
|||
<artifactItem>
|
||||
<groupId>org.eclipse.jetty.toolchain</groupId>
|
||||
<artifactId>jetty-schemas</artifactId>
|
||||
<version>3.1.M0</version>
|
||||
<version>${servlet.schema.version}</version>
|
||||
<overWrite>true</overWrite>
|
||||
<outputDirectory>${assembly-directory}/lib</outputDirectory>
|
||||
<destFileName>jetty-schemas-3.1.jar</destFileName>
|
||||
|
|
|
@ -173,6 +173,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
|
|||
private final AttributesMap _attributes;
|
||||
private final Map<String, String> _initParams;
|
||||
private ClassLoader _classLoader;
|
||||
private boolean _contextPathDefault = true;
|
||||
private String _contextPath = "/";
|
||||
private String _contextPathEncoded = "/";
|
||||
|
||||
|
@ -753,7 +754,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
|
|||
|
||||
if (_contextPath == null)
|
||||
throw new IllegalStateException("Null contextPath");
|
||||
|
||||
|
||||
if (_logger == null)
|
||||
{
|
||||
_logger = Log.getLogger(ContextHandler.class.getName() + getLogNameSuffix());
|
||||
|
@ -1477,6 +1478,29 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
|
|||
_classLoader = classLoader;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Set the default context path.
|
||||
* A default context path may be overriden by a default-context-path element
|
||||
* in a web.xml
|
||||
* @param contextPath
|
||||
* The _contextPath to set.
|
||||
*/
|
||||
public void setDefaultContextPath(String contextPath)
|
||||
{
|
||||
setContextPath(contextPath);
|
||||
_contextPathDefault = true;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
*
|
||||
* @return True if the current contextPath is from default settings
|
||||
*/
|
||||
public boolean isContextPathDefault()
|
||||
{
|
||||
return _contextPathDefault;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param contextPath
|
||||
|
@ -1506,6 +1530,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
|
|||
|
||||
_contextPath = contextPath;
|
||||
_contextPathEncoded = URIUtil.encodePath(contextPath);
|
||||
_contextPathDefault = false;
|
||||
|
||||
if (getServer() != null && (getServer().isStarting() || getServer().isStarted()))
|
||||
{
|
||||
|
|
|
@ -76,6 +76,10 @@
|
|||
<artifactId>jetty-servlet</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.toolchain</groupId>
|
||||
<artifactId>jetty-schemas</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-jmx</artifactId>
|
||||
|
|
|
@ -98,6 +98,10 @@ public class StandardDescriptorProcessor extends IterativeDescriptorProcessor
|
|||
registerVisitor("listener", this.getClass().getMethod("visitListener", __signature));
|
||||
registerVisitor("distributable", this.getClass().getMethod("visitDistributable", __signature));
|
||||
registerVisitor("deny-uncovered-http-methods", this.getClass().getMethod("visitDenyUncoveredHttpMethods", __signature));
|
||||
registerVisitor("default-context-path", this.getClass().getMethod("visitDefaultContextPath", __signature));
|
||||
registerVisitor("request-encoding", this.getClass().getMethod("visitRequestEncoding", __signature));
|
||||
registerVisitor("response-encoding", this.getClass().getMethod("visitResponseEncoding", __signature));
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -1940,6 +1944,58 @@ public class StandardDescriptorProcessor extends IterativeDescriptorProcessor
|
|||
((ConstraintAware)context.getSecurityHandler()).setDenyUncoveredHttpMethods(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* When specified, this element provides a default context path
|
||||
* of the web application. The default context path starts
|
||||
* with a / character. If it is not rooted at the root of the
|
||||
* server's name space, the path does not end with a / character.
|
||||
* @since Servlet 4.0
|
||||
* @param context the of the processing
|
||||
* @param descriptor the descriptor
|
||||
* @param node the xml node
|
||||
*/
|
||||
public void visitDefaultContextPath(WebAppContext context, Descriptor descriptor, XmlParser.Node node)
|
||||
{
|
||||
if (!(descriptor instanceof FragmentDescriptor))
|
||||
{
|
||||
if (context.isContextPathDefault())
|
||||
{
|
||||
context.setContextPath(node.toString(false, true));
|
||||
context.getMetaData().setOrigin("default-context-path", descriptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When specified, this element provides a default request
|
||||
* encoding of the web application.
|
||||
* @since Servlet 4.0
|
||||
* @param context the of the processing
|
||||
* @param descriptor the descriptor
|
||||
* @param node the xml node
|
||||
*/
|
||||
public void visitRequestEncoding(WebAppContext context, Descriptor descriptor, XmlParser.Node node)
|
||||
{
|
||||
// TODO
|
||||
LOG.warn("Not implemented {}",node);
|
||||
// TODO
|
||||
}
|
||||
|
||||
/**
|
||||
* When specified, this element provides a default response
|
||||
* encoding of the web application.
|
||||
* @since Servlet 4.0
|
||||
* @param context the of the processing
|
||||
* @param descriptor the descriptor
|
||||
* @param node the xml node
|
||||
*/
|
||||
public void visitResponseEncoding(WebAppContext context, Descriptor descriptor, XmlParser.Node node)
|
||||
{
|
||||
// TODO
|
||||
LOG.warn("Not implemented {}",node);
|
||||
}
|
||||
|
||||
|
||||
public EventListener newListenerInstance(WebAppContext context,Class<? extends EventListener> clazz, Descriptor descriptor) throws Exception
|
||||
{
|
||||
ListenerHolder h = context.getServletHandler().newListenerHolder(new Source (Source.Origin.DESCRIPTOR, descriptor.getResource().toString()));
|
||||
|
|
|
@ -98,12 +98,15 @@ public class WebDescriptor extends Descriptor
|
|||
URL webapp25xsd=Loader.getResource("javax/servlet/resources/web-app_2_5.xsd");
|
||||
URL webapp30xsd=Loader.getResource("javax/servlet/resources/web-app_3_0.xsd");
|
||||
URL webapp31xsd=Loader.getResource("javax/servlet/resources/web-app_3_1.xsd");
|
||||
URL webapp40xsd=Loader.getResource("javax/servlet/resources/web-app_4_0.xsd");
|
||||
|
||||
URL webcommon30xsd=Loader.getResource("javax/servlet/resources/web-common_3_0.xsd");
|
||||
URL webcommon31xsd=Loader.getResource("javax/servlet/resources/web-common_3_1.xsd");
|
||||
URL webcommon40xsd=Loader.getResource("javax/servlet/resources/web-common_4_0.xsd");
|
||||
|
||||
URL webfragment30xsd=Loader.getResource("javax/servlet/resources/web-fragment_3_0.xsd");
|
||||
URL webfragment31xsd=Loader.getResource("javax/servlet/resources/web-fragment_3_1.xsd");
|
||||
URL webfragment40xsd=Loader.getResource("javax/servlet/resources/web-fragment_4_0.xsd");
|
||||
|
||||
URL schemadtd=Loader.getResource("javax/servlet/resources/XMLSchema.dtd");
|
||||
URL xmlxsd=Loader.getResource("javax/servlet/resources/xml.xsd");
|
||||
|
@ -165,6 +168,8 @@ public class WebDescriptor extends Descriptor
|
|||
redirectEntity("http://java.sun.com/xml/ns/javaee/web-common_3_0.xsd",webcommon30xsd);
|
||||
redirectEntity("web-common_3_1.xsd",webcommon31xsd);
|
||||
redirectEntity("http://xmlns.jcp.org/xml/ns/javaee/web-common_3_1.xsd",webcommon31xsd);
|
||||
redirectEntity("web-common_4_0.xsd",webcommon40xsd);
|
||||
redirectEntity("http://xmlns.jcp.org/xml/ns/javaee/web-common_4_0.xsd",webcommon40xsd);
|
||||
|
||||
redirectEntity("web-app_2_4.xsd",webapp24xsd);
|
||||
redirectEntity("http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd",webapp24xsd);
|
||||
|
@ -174,11 +179,15 @@ public class WebDescriptor extends Descriptor
|
|||
redirectEntity("http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd",webapp30xsd);
|
||||
redirectEntity("web-app_3_1.xsd",webapp31xsd);
|
||||
redirectEntity("http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd",webapp31xsd);
|
||||
redirectEntity("web-app_4_0.xsd",webapp40xsd);
|
||||
redirectEntity("http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd",webapp40xsd);
|
||||
|
||||
redirectEntity("web-fragment_3_0.xsd",webfragment30xsd);
|
||||
redirectEntity("http://java.sun.com/xml/ns/javaee/web-fragment_3_0.xsd",webfragment30xsd);
|
||||
redirectEntity("web-fragment_3_1.xsd",webfragment31xsd);
|
||||
redirectEntity("http://xmlns.jcp.org/xml/ns/javaee/web-fragment_3_1.xsd",webfragment31xsd);
|
||||
redirectEntity("web-fragment_4_0.xsd",webfragment40xsd);
|
||||
redirectEntity("http://xmlns.jcp.org/xml/ns/javaee/web-fragment_4_0.xsd",webfragment40xsd);
|
||||
|
||||
redirectEntity("xml.xsd",xmlxsd);
|
||||
redirectEntity("http://www.w3.org/2001/xml.xsd",xmlxsd);
|
||||
|
|
3
pom.xml
3
pom.xml
|
@ -23,6 +23,7 @@
|
|||
<alpn.api.version>1.1.3.v20160715</alpn.api.version>
|
||||
<jsp.version>8.5.9.1</jsp.version>
|
||||
<servlet.api.version>4.0.0-b07</servlet.api.version>
|
||||
<servlet.schema.version>4.0.0-b07</servlet.schema.version>
|
||||
<!-- default values are unsupported, but required to be defined for reactor sanity reasons -->
|
||||
<alpn.version>undefined</alpn.version>
|
||||
</properties>
|
||||
|
@ -898,7 +899,7 @@
|
|||
<dependency>
|
||||
<groupId>org.eclipse.jetty.toolchain</groupId>
|
||||
<artifactId>jetty-schemas</artifactId>
|
||||
<version>3.1</version>
|
||||
<version>${servlet.schema.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mortbay.jasper</groupId>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
</Arg>
|
||||
</New>
|
||||
|
||||
<Set name="contextPath">/test-spec</Set>
|
||||
<!-- ContextPath set in web.xml -->
|
||||
<Set name="war"><Property name="jetty.webapps"/>/test-spec.war</Set>
|
||||
<Set name="configurationDiscovered">true</Set>
|
||||
|
||||
|
|
|
@ -2,17 +2,18 @@
|
|||
<web-app
|
||||
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
|
||||
metadata-complete="false"
|
||||
version="3.1">
|
||||
version="4.0">
|
||||
|
||||
<display-name>Test Annotations WebApp</display-name>
|
||||
|
||||
<default-context-path>/test-spec</default-context-path>
|
||||
|
||||
<listener>
|
||||
<listener-class>com.acme.test.TestListener</listener-class>
|
||||
</listener>
|
||||
|
||||
|
||||
<servlet>
|
||||
<servlet-name>AnnotationTest</servlet-name>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<hr/>
|
||||
<center><span style="color:red; font-variant:small-caps; font-weight:bold">Test Web Application Only - Do NOT Deploy in Production</span> </center>
|
||||
|
||||
<h1>Servlet 3.1 Test WebApp</h1>
|
||||
<h1>Servlet 3.0/3.1/4.0 Test WebApp</h1>
|
||||
|
||||
<p>
|
||||
This example tests some aspects of the servlet 3.1 specification:<ul>
|
||||
|
|
Loading…
Reference in New Issue