442642 Quickstart generates valid XML
Fixed issues with XmlParser and WebDescriptor that were stopping validation.
This commit is contained in:
parent
8ce96cdd2e
commit
4c8e2a6635
|
@ -12,6 +12,12 @@
|
||||||
<description>Jetty Quick Start Example</description>
|
<description>Jetty Quick Start Example</description>
|
||||||
<url>http://www.eclipse.org/jetty</url>
|
<url>http://www.eclipse.org/jetty</url>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-quickstart</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>jetty-webapp</artifactId>
|
<artifactId>jetty-webapp</artifactId>
|
||||||
|
@ -101,6 +107,12 @@
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty.toolchain</groupId>
|
||||||
|
<artifactId>jetty-test-helper</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class PreconfigureJNDIWar
|
||||||
|
|
||||||
LOG.info("Preconfigured in {}ms",TimeUnit.NANOSECONDS.toMillis(System.nanoTime()-__start));
|
LOG.info("Preconfigured in {}ms",TimeUnit.NANOSECONDS.toMillis(System.nanoTime()-__start));
|
||||||
|
|
||||||
IO.copy(new FileInputStream("target/test-jndi-preconfigured/WEB-INF/quickstart-web.xml"),System.out);
|
// IO.copy(new FileInputStream("target/test-jndi-preconfigured/WEB-INF/quickstart-web.xml"),System.out);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -52,7 +52,7 @@ public class PreconfigureSpecWar
|
||||||
|
|
||||||
LOG.info("Preconfigured in {}ms",TimeUnit.NANOSECONDS.toMillis(System.nanoTime()-__start));
|
LOG.info("Preconfigured in {}ms",TimeUnit.NANOSECONDS.toMillis(System.nanoTime()-__start));
|
||||||
|
|
||||||
IO.copy(new FileInputStream("target/test-spec-preconfigured/WEB-INF/quickstart-web.xml"),System.out);
|
// IO.copy(new FileInputStream("target/test-spec-preconfigured/WEB-INF/quickstart-web.xml"),System.out);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -34,7 +34,6 @@ import org.eclipse.jetty.util.resource.Resource;
|
||||||
*/
|
*/
|
||||||
public class PreconfigureStandardTestWar
|
public class PreconfigureStandardTestWar
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final long __start=System.nanoTime();
|
private static final long __start=System.nanoTime();
|
||||||
private static final Logger LOG = Log.getLogger(Server.class);
|
private static final Logger LOG = Log.getLogger(Server.class);
|
||||||
|
|
||||||
|
@ -57,6 +56,6 @@ public class PreconfigureStandardTestWar
|
||||||
|
|
||||||
LOG.info("Preconfigured in {}ms",TimeUnit.NANOSECONDS.toMillis(System.nanoTime()-__start));
|
LOG.info("Preconfigured in {}ms",TimeUnit.NANOSECONDS.toMillis(System.nanoTime()-__start));
|
||||||
|
|
||||||
IO.copy(new FileInputStream("target/test-standard-preconfigured/WEB-INF/quickstart-web.xml"),System.out);
|
// IO.copy(new FileInputStream("target/test-standard-preconfigured/WEB-INF/quickstart-web.xml"),System.out);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,179 @@
|
||||||
|
//
|
||||||
|
// ========================================================================
|
||||||
|
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// All rights reserved. This program and the accompanying materials
|
||||||
|
// are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
// and Apache License v2.0 which accompanies this distribution.
|
||||||
|
//
|
||||||
|
// The Eclipse Public License is available at
|
||||||
|
// http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
//
|
||||||
|
// The Apache License v2.0 is available at
|
||||||
|
// http://www.opensource.org/licenses/apache2.0.php
|
||||||
|
//
|
||||||
|
// You may elect to redistribute this code under either of these licenses.
|
||||||
|
// ========================================================================
|
||||||
|
//
|
||||||
|
|
||||||
|
package org.eclipse.jetty.quickstart;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertThat;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.server.NetworkConnector;
|
||||||
|
import org.eclipse.jetty.server.Server;
|
||||||
|
import org.eclipse.jetty.util.IO;
|
||||||
|
import org.eclipse.jetty.util.resource.Resource;
|
||||||
|
import org.eclipse.jetty.webapp.WebDescriptor;
|
||||||
|
import org.eclipse.jetty.xml.XmlConfiguration;
|
||||||
|
import org.eclipse.jetty.xml.XmlParser.Node;
|
||||||
|
import org.hamcrest.Matchers;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class QuickStartTest
|
||||||
|
{
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testStandardTestWar() throws Exception
|
||||||
|
{
|
||||||
|
PreconfigureStandardTestWar.main(new String[]{});
|
||||||
|
|
||||||
|
WebDescriptor descriptor = new WebDescriptor(Resource.newResource("./target/test-standard-preconfigured/WEB-INF/quickstart-web.xml"));
|
||||||
|
descriptor.setValidating(true);
|
||||||
|
descriptor.parse();
|
||||||
|
Node node = descriptor.getRoot();
|
||||||
|
assertThat(node,Matchers.notNullValue());
|
||||||
|
|
||||||
|
System.setProperty("jetty.home", "target");
|
||||||
|
|
||||||
|
//war file or dir to start
|
||||||
|
String war = "target/test-standard-preconfigured";
|
||||||
|
|
||||||
|
//optional jetty context xml file to configure the webapp
|
||||||
|
Resource contextXml = Resource.newResource("src/test/resources/test.xml");
|
||||||
|
|
||||||
|
Server server = new Server(0);
|
||||||
|
|
||||||
|
QuickStartWebApp webapp = new QuickStartWebApp();
|
||||||
|
webapp.setAutoPreconfigure(true);
|
||||||
|
webapp.setWar(war);
|
||||||
|
webapp.setContextPath("/");
|
||||||
|
|
||||||
|
//apply context xml file
|
||||||
|
if (contextXml != null)
|
||||||
|
{
|
||||||
|
// System.err.println("Applying "+contextXml);
|
||||||
|
XmlConfiguration xmlConfiguration = new XmlConfiguration(contextXml.getURL());
|
||||||
|
xmlConfiguration.configure(webapp);
|
||||||
|
}
|
||||||
|
|
||||||
|
server.setHandler(webapp);
|
||||||
|
|
||||||
|
server.start();
|
||||||
|
|
||||||
|
URL url = new URL("http://127.0.0.1:"+server.getBean(NetworkConnector.class).getLocalPort()+"/test/dump/info");
|
||||||
|
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
|
||||||
|
assertEquals(200,connection.getResponseCode());
|
||||||
|
assertThat(IO.toString((InputStream)connection.getContent()),Matchers.containsString("Dump Servlet"));
|
||||||
|
|
||||||
|
server.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSpecWar() throws Exception
|
||||||
|
{
|
||||||
|
PreconfigureSpecWar.main(new String[]{});
|
||||||
|
|
||||||
|
WebDescriptor descriptor = new WebDescriptor(Resource.newResource("./target/test-spec-preconfigured/WEB-INF/quickstart-web.xml"));
|
||||||
|
descriptor.setValidating(true);
|
||||||
|
descriptor.parse();
|
||||||
|
Node node = descriptor.getRoot();
|
||||||
|
assertThat(node,Matchers.notNullValue());
|
||||||
|
|
||||||
|
System.setProperty("jetty.home", "target");
|
||||||
|
|
||||||
|
//war file or dir to start
|
||||||
|
String war = "target/test-spec-preconfigured";
|
||||||
|
|
||||||
|
//optional jetty context xml file to configure the webapp
|
||||||
|
Resource contextXml = Resource.newResource("src/test/resources/test-spec.xml");
|
||||||
|
|
||||||
|
Server server = new Server(0);
|
||||||
|
|
||||||
|
QuickStartWebApp webapp = new QuickStartWebApp();
|
||||||
|
webapp.setAutoPreconfigure(true);
|
||||||
|
webapp.setWar(war);
|
||||||
|
webapp.setContextPath("/");
|
||||||
|
|
||||||
|
//apply context xml file
|
||||||
|
if (contextXml != null)
|
||||||
|
{
|
||||||
|
// System.err.println("Applying "+contextXml);
|
||||||
|
XmlConfiguration xmlConfiguration = new XmlConfiguration(contextXml.getURL());
|
||||||
|
xmlConfiguration.configure(webapp);
|
||||||
|
}
|
||||||
|
|
||||||
|
server.setHandler(webapp);
|
||||||
|
|
||||||
|
server.start();
|
||||||
|
|
||||||
|
URL url = new URL("http://127.0.0.1:"+server.getBean(NetworkConnector.class).getLocalPort()+"/");
|
||||||
|
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
|
||||||
|
assertEquals(200,connection.getResponseCode());
|
||||||
|
assertThat(IO.toString((InputStream)connection.getContent()),Matchers.containsString("Test Specification WebApp"));
|
||||||
|
|
||||||
|
server.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testJNDIWar() throws Exception
|
||||||
|
{
|
||||||
|
PreconfigureJNDIWar.main(new String[]{});
|
||||||
|
|
||||||
|
WebDescriptor descriptor = new WebDescriptor(Resource.newResource("./target/test-jndi-preconfigured/WEB-INF/quickstart-web.xml"));
|
||||||
|
descriptor.setValidating(true);
|
||||||
|
descriptor.parse();
|
||||||
|
Node node = descriptor.getRoot();
|
||||||
|
assertThat(node,Matchers.notNullValue());
|
||||||
|
|
||||||
|
System.setProperty("jetty.home", "target");
|
||||||
|
|
||||||
|
//war file or dir to start
|
||||||
|
String war = "target/test-jndi-preconfigured";
|
||||||
|
|
||||||
|
//optional jetty context xml file to configure the webapp
|
||||||
|
Resource contextXml = Resource.newResource("src/test/resources/test-jndi.xml");
|
||||||
|
|
||||||
|
Server server = new Server(0);
|
||||||
|
|
||||||
|
QuickStartWebApp webapp = new QuickStartWebApp();
|
||||||
|
webapp.setAutoPreconfigure(true);
|
||||||
|
webapp.setWar(war);
|
||||||
|
webapp.setContextPath("/");
|
||||||
|
|
||||||
|
//apply context xml file
|
||||||
|
if (contextXml != null)
|
||||||
|
{
|
||||||
|
// System.err.println("Applying "+contextXml);
|
||||||
|
XmlConfiguration xmlConfiguration = new XmlConfiguration(contextXml.getURL());
|
||||||
|
xmlConfiguration.configure(webapp);
|
||||||
|
}
|
||||||
|
|
||||||
|
server.setHandler(webapp);
|
||||||
|
|
||||||
|
server.start();
|
||||||
|
|
||||||
|
URL url = new URL("http://127.0.0.1:"+server.getBean(NetworkConnector.class).getLocalPort()+"/");
|
||||||
|
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
|
||||||
|
assertEquals(200,connection.getResponseCode());
|
||||||
|
String content=IO.toString((InputStream)connection.getContent());
|
||||||
|
assertThat(content,Matchers.containsString("JNDI Test WebApp"));
|
||||||
|
|
||||||
|
server.stop();
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,9 +19,7 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.quickstart;
|
package org.eclipse.jetty.quickstart;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -50,7 +48,6 @@ import org.eclipse.jetty.security.authentication.FormAuthenticator;
|
||||||
import org.eclipse.jetty.servlet.ErrorPageErrorHandler;
|
import org.eclipse.jetty.servlet.ErrorPageErrorHandler;
|
||||||
import org.eclipse.jetty.servlet.FilterHolder;
|
import org.eclipse.jetty.servlet.FilterHolder;
|
||||||
import org.eclipse.jetty.servlet.FilterMapping;
|
import org.eclipse.jetty.servlet.FilterMapping;
|
||||||
import org.eclipse.jetty.servlet.Holder;
|
|
||||||
import org.eclipse.jetty.servlet.ServletHandler;
|
import org.eclipse.jetty.servlet.ServletHandler;
|
||||||
import org.eclipse.jetty.servlet.ServletHolder;
|
import org.eclipse.jetty.servlet.ServletHolder;
|
||||||
import org.eclipse.jetty.servlet.ServletMapping;
|
import org.eclipse.jetty.servlet.ServletMapping;
|
||||||
|
@ -163,7 +160,7 @@ public class QuickStartDescriptorGenerator
|
||||||
if (servlets.getFilters() != null)
|
if (servlets.getFilters() != null)
|
||||||
{
|
{
|
||||||
for (FilterHolder holder : servlets.getFilters())
|
for (FilterHolder holder : servlets.getFilters())
|
||||||
outholder(out,md,"filter",holder);
|
outholder(out,md,holder);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (servlets.getFilterMappings() != null)
|
if (servlets.getFilterMappings() != null)
|
||||||
|
@ -199,7 +196,7 @@ public class QuickStartDescriptorGenerator
|
||||||
if (servlets.getServlets() != null)
|
if (servlets.getServlets() != null)
|
||||||
{
|
{
|
||||||
for (ServletHolder holder : servlets.getServlets())
|
for (ServletHolder holder : servlets.getServlets())
|
||||||
outholder(out,md,"servlet",holder);
|
outholder(out,md,holder);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (servlets.getServletMappings() != null)
|
if (servlets.getServletMappings() != null)
|
||||||
|
@ -250,15 +247,36 @@ public class QuickStartDescriptorGenerator
|
||||||
{
|
{
|
||||||
out.openTag("security-constraint");
|
out.openTag("security-constraint");
|
||||||
|
|
||||||
|
out.openTag("web-resource-collection");
|
||||||
|
{
|
||||||
|
if (m.getConstraint().getName()!=null)
|
||||||
|
out.tag("web-resource-name",m.getConstraint().getName());
|
||||||
|
if (m.getPathSpec()!=null)
|
||||||
|
out.tag("url-pattern",origin(md,"constraint.url."+m.getPathSpec()),m.getPathSpec());
|
||||||
|
if (m.getMethod()!=null)
|
||||||
|
out.tag("http-method",m.getMethod());
|
||||||
|
|
||||||
|
if (m.getMethodOmissions()!=null)
|
||||||
|
for (String o:m.getMethodOmissions())
|
||||||
|
out.tag("http-method-omission",o);
|
||||||
|
|
||||||
|
out.closeTag();
|
||||||
|
}
|
||||||
|
|
||||||
if (m.getConstraint().getAuthenticate())
|
if (m.getConstraint().getAuthenticate())
|
||||||
|
{
|
||||||
|
String[] roles = m.getConstraint().getRoles();
|
||||||
|
if (roles!=null && roles.length>0)
|
||||||
{
|
{
|
||||||
out.openTag("auth-constraint");
|
out.openTag("auth-constraint");
|
||||||
if (m.getConstraint().getRoles()!=null)
|
if (m.getConstraint().getRoles()!=null)
|
||||||
for (String r : m.getConstraint().getRoles())
|
for (String r : m.getConstraint().getRoles())
|
||||||
out.tag("role-name",r);
|
out.tag("role-name",r);
|
||||||
|
|
||||||
out.closeTag();
|
out.closeTag();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
out.tag("auth-constraint");
|
||||||
|
}
|
||||||
|
|
||||||
switch (m.getConstraint().getDataConstraint())
|
switch (m.getConstraint().getDataConstraint())
|
||||||
{
|
{
|
||||||
|
@ -279,22 +297,6 @@ public class QuickStartDescriptorGenerator
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out.openTag("web-resource-collection");
|
|
||||||
{
|
|
||||||
if (m.getConstraint().getName()!=null)
|
|
||||||
out.tag("web-resource-name",m.getConstraint().getName());
|
|
||||||
if (m.getPathSpec()!=null)
|
|
||||||
out.tag("url-pattern",origin(md,"constraint.url."+m.getPathSpec()),m.getPathSpec());
|
|
||||||
if (m.getMethod()!=null)
|
|
||||||
out.tag("http-method",m.getMethod());
|
|
||||||
|
|
||||||
if (m.getMethodOmissions()!=null)
|
|
||||||
for (String o:m.getMethodOmissions())
|
|
||||||
out.tag("http-method-omission",o);
|
|
||||||
|
|
||||||
out.closeTag();
|
|
||||||
}
|
|
||||||
|
|
||||||
out.closeTag();
|
out.closeTag();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -331,12 +333,6 @@ public class QuickStartDescriptorGenerator
|
||||||
int maxInactiveSec = _webApp.getSessionHandler().getSessionManager().getMaxInactiveInterval();
|
int maxInactiveSec = _webApp.getSessionHandler().getSessionManager().getMaxInactiveInterval();
|
||||||
out.tag("session-timeout", (maxInactiveSec==0?"0":Integer.toString(maxInactiveSec/60)));
|
out.tag("session-timeout", (maxInactiveSec==0?"0":Integer.toString(maxInactiveSec/60)));
|
||||||
|
|
||||||
Set<SessionTrackingMode> modes =_webApp. getSessionHandler().getSessionManager().getEffectiveSessionTrackingModes();
|
|
||||||
if (modes != null)
|
|
||||||
{
|
|
||||||
for (SessionTrackingMode mode:modes)
|
|
||||||
out.tag("tracking-mode", mode.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
//cookie-config
|
//cookie-config
|
||||||
SessionCookieConfig cookieConfig = _webApp.getSessionHandler().getSessionManager().getSessionCookieConfig();
|
SessionCookieConfig cookieConfig = _webApp.getSessionHandler().getSessionManager().getSessionCookieConfig();
|
||||||
|
@ -360,6 +356,15 @@ public class QuickStartDescriptorGenerator
|
||||||
out.tag("max-age", origin(md, "cookie-config.max-age"), Integer.toString(cookieConfig.getMaxAge()));
|
out.tag("max-age", origin(md, "cookie-config.max-age"), Integer.toString(cookieConfig.getMaxAge()));
|
||||||
out.closeTag();
|
out.closeTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// tracking-modes
|
||||||
|
Set<SessionTrackingMode> modes =_webApp. getSessionHandler().getSessionManager().getEffectiveSessionTrackingModes();
|
||||||
|
if (modes != null)
|
||||||
|
{
|
||||||
|
for (SessionTrackingMode mode:modes)
|
||||||
|
out.tag("tracking-mode", mode.toString());
|
||||||
|
}
|
||||||
|
|
||||||
out.closeTag();
|
out.closeTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -560,29 +565,57 @@ public class QuickStartDescriptorGenerator
|
||||||
* @param holder
|
* @param holder
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
private void outholder(XmlAppendable out, MetaData md, String tag, Holder<?> holder) throws IOException
|
private void outholder(XmlAppendable out, MetaData md, FilterHolder holder) throws IOException
|
||||||
{
|
{
|
||||||
out.openTag(tag,Collections.singletonMap("source",holder.getSource().toString()));
|
if (LOG.isDebugEnabled())
|
||||||
String n = holder.getName();
|
out.openTag("filter",Collections.singletonMap("source",holder.getSource().toString()));
|
||||||
out.tag(tag + "-name",n);
|
else
|
||||||
|
out.openTag("filter");
|
||||||
|
|
||||||
String ot = n + "." + tag + ".";
|
String n = holder.getName();
|
||||||
|
out.tag("filter-name",n);
|
||||||
|
|
||||||
|
String ot = n + ".filter.";
|
||||||
|
|
||||||
if (holder instanceof FilterHolder)
|
if (holder instanceof FilterHolder)
|
||||||
out.tag(tag + "-class",origin(md,ot + tag + "-class"),holder.getClassName());
|
|
||||||
else if (holder instanceof ServletHolder)
|
|
||||||
{
|
{
|
||||||
ServletHolder s = (ServletHolder)holder;
|
out.tag("filter-class",origin(md,ot + "filter-class"),holder.getClassName());
|
||||||
if (s.getForcedPath() != null && s.getClassName() == null)
|
out.tag("async-supported",origin(md,ot + "async-supported"),holder.isAsyncSupported()?"true":"false");
|
||||||
out.tag("jsp-file",s.getForcedPath());
|
|
||||||
else
|
|
||||||
out.tag(tag + "-class",origin(md,ot + tag + "-class"),s.getClassName());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String p : holder.getInitParameters().keySet())
|
for (String p : holder.getInitParameters().keySet())
|
||||||
{
|
{
|
||||||
if ("scratchdir".equalsIgnoreCase(p)) //don't preconfigure the temp dir for jsp output
|
out.openTag("init-param",origin(md,ot + "init-param." + p))
|
||||||
|
.tag("param-name",p)
|
||||||
|
.tag("param-value",holder.getInitParameter(p))
|
||||||
|
.closeTag();
|
||||||
|
}
|
||||||
|
|
||||||
|
out.closeTag();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void outholder(XmlAppendable out, MetaData md, ServletHolder holder) throws IOException
|
||||||
|
{
|
||||||
|
|
||||||
|
if (LOG.isDebugEnabled())
|
||||||
|
out.openTag("servlet",Collections.singletonMap("source",holder.getSource().toString()));
|
||||||
|
else
|
||||||
|
out.openTag("servlet");
|
||||||
|
|
||||||
|
String n = holder.getName();
|
||||||
|
out.tag("servlet-name",n);
|
||||||
|
|
||||||
|
String ot = n + ".servlet.";
|
||||||
|
|
||||||
|
ServletHolder s = (ServletHolder)holder;
|
||||||
|
if (s.getForcedPath() != null && s.getClassName() == null)
|
||||||
|
out.tag("jsp-file",s.getForcedPath());
|
||||||
|
else
|
||||||
|
out.tag("servlet-class",origin(md,ot + "servlet-class"),s.getClassName());
|
||||||
|
|
||||||
|
for (String p : holder.getInitParameters().keySet())
|
||||||
|
{
|
||||||
|
if ("jsp".equalsIgnoreCase(n) && "scratchdir".equalsIgnoreCase(p)) //don't preconfigure the temp dir for jsp output
|
||||||
continue;
|
continue;
|
||||||
out.openTag("init-param",origin(md,ot + "init-param." + p))
|
out.openTag("init-param",origin(md,ot + "init-param." + p))
|
||||||
.tag("param-name",p)
|
.tag("param-name",p)
|
||||||
|
@ -590,12 +623,14 @@ public class QuickStartDescriptorGenerator
|
||||||
.closeTag();
|
.closeTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (holder instanceof ServletHolder)
|
|
||||||
{
|
|
||||||
ServletHolder s = (ServletHolder)holder;
|
|
||||||
if (s.getInitOrder() >= 0)
|
if (s.getInitOrder() >= 0)
|
||||||
out.tag("load-on-startup",Integer.toString(s.getInitOrder()));
|
out.tag("load-on-startup",Integer.toString(s.getInitOrder()));
|
||||||
|
|
||||||
|
if (!s.isEnabled())
|
||||||
|
out.tag("enabled",origin(md,ot + "enabled"),"false");
|
||||||
|
|
||||||
|
out.tag("async-supported",origin(md,ot + "async-supported"),holder.isAsyncSupported()?"true":"false");
|
||||||
|
|
||||||
if (s.getRunAsRole() != null)
|
if (s.getRunAsRole() != null)
|
||||||
out.openTag("run-as",origin(md,ot + "run-as"))
|
out.openTag("run-as",origin(md,ot + "run-as"))
|
||||||
.tag("role-name",s.getRunAsRole())
|
.tag("role-name",s.getRunAsRole())
|
||||||
|
@ -613,9 +648,6 @@ public class QuickStartDescriptorGenerator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!s.isEnabled())
|
|
||||||
out.tag("enabled",origin(md,ot + "enabled"),"false");
|
|
||||||
|
|
||||||
//multipart-config
|
//multipart-config
|
||||||
MultipartConfigElement multipartConfig = ((ServletHolder.Registration)s.getRegistration()).getMultipartConfig();
|
MultipartConfigElement multipartConfig = ((ServletHolder.Registration)s.getRegistration()).getMultipartConfig();
|
||||||
if (multipartConfig != null)
|
if (multipartConfig != null)
|
||||||
|
@ -628,14 +660,11 @@ public class QuickStartDescriptorGenerator
|
||||||
out.tag("file-size-threshold", Long.toString(multipartConfig.getFileSizeThreshold()));
|
out.tag("file-size-threshold", Long.toString(multipartConfig.getFileSizeThreshold()));
|
||||||
out.closeTag();
|
out.closeTag();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
out.tag("async-supported",origin(md,ot + "async-supported"),holder.isAsyncSupported()?"true":"false");
|
|
||||||
out.closeTag();
|
out.closeTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find the origin (web.xml, fragment, annotation etc) of a web artifact from MetaData.
|
* Find the origin (web.xml, fragment, annotation etc) of a web artifact from MetaData.
|
||||||
*
|
*
|
||||||
|
|
|
@ -18,8 +18,6 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.webapp;
|
package org.eclipse.jetty.webapp;
|
||||||
|
|
||||||
import java.net.URL;
|
|
||||||
|
|
||||||
import org.eclipse.jetty.util.resource.Resource;
|
import org.eclipse.jetty.util.resource.Resource;
|
||||||
import org.eclipse.jetty.xml.XmlParser;
|
import org.eclipse.jetty.xml.XmlParser;
|
||||||
|
|
||||||
|
@ -35,19 +33,9 @@ public abstract class Descriptor
|
||||||
_xml = xml;
|
_xml = xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract XmlParser newParser()
|
|
||||||
throws ClassNotFoundException;
|
|
||||||
|
|
||||||
public abstract void ensureParser()
|
public abstract void ensureParser()
|
||||||
throws ClassNotFoundException;
|
throws ClassNotFoundException;
|
||||||
|
|
||||||
protected void redirect(XmlParser parser, String resource, URL source)
|
|
||||||
{
|
|
||||||
if (source != null)
|
|
||||||
parser.redirectEntity(resource, source);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setValidating (boolean validating)
|
public void setValidating (boolean validating)
|
||||||
{
|
{
|
||||||
_validating = validating;
|
_validating = validating;
|
||||||
|
|
|
@ -54,20 +54,23 @@ public class WebDescriptor extends Descriptor
|
||||||
protected List<String> _ordering = new ArrayList<String>();
|
protected List<String> _ordering = new ArrayList<String>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ensureParser()
|
public void ensureParser() throws ClassNotFoundException
|
||||||
throws ClassNotFoundException
|
{
|
||||||
|
synchronized (WebDescriptor.class)
|
||||||
{
|
{
|
||||||
if (_parserSingleton == null)
|
if (_parserSingleton == null)
|
||||||
{
|
_parserSingleton = newParser(isValidating());
|
||||||
_parserSingleton = newParser();
|
|
||||||
}
|
|
||||||
_parser = _parserSingleton;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public XmlParser newParser()
|
if (_parserSingleton.isValidating()==isValidating())
|
||||||
throws ClassNotFoundException
|
_parser = _parserSingleton;
|
||||||
|
else
|
||||||
|
_parser = newParser(isValidating());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static XmlParser newParser(boolean validating) throws ClassNotFoundException
|
||||||
{
|
{
|
||||||
XmlParser xmlParser=new XmlParser()
|
XmlParser xmlParser=new XmlParser(validating)
|
||||||
{
|
{
|
||||||
boolean mapped=false;
|
boolean mapped=false;
|
||||||
|
|
||||||
|
@ -137,55 +140,55 @@ public class WebDescriptor extends Descriptor
|
||||||
if (jsp23xsd == null) jsp23xsd = Loader.getResource(Servlet.class, "javax/servlet/jsp/resources/jsp_2_3.xsd");
|
if (jsp23xsd == null) jsp23xsd = Loader.getResource(Servlet.class, "javax/servlet/jsp/resources/jsp_2_3.xsd");
|
||||||
}
|
}
|
||||||
|
|
||||||
redirect(this,"web-app_2_2.dtd",dtd22);
|
redirectEntity("web-app_2_2.dtd",dtd22);
|
||||||
redirect(this,"-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN",dtd22);
|
redirectEntity("-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN",dtd22);
|
||||||
redirect(this,"web.dtd",dtd23);
|
redirectEntity("web.dtd",dtd23);
|
||||||
redirect(this,"web-app_2_3.dtd",dtd23);
|
redirectEntity("web-app_2_3.dtd",dtd23);
|
||||||
redirect(this,"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN",dtd23);
|
redirectEntity("-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN",dtd23);
|
||||||
redirect(this,"XMLSchema.dtd",schemadtd);
|
redirectEntity("XMLSchema.dtd",schemadtd);
|
||||||
redirect(this,"http://www.w3.org/2001/XMLSchema.dtd",schemadtd);
|
redirectEntity("http://www.w3.org/2001/XMLSchema.dtd",schemadtd);
|
||||||
redirect(this,"-//W3C//DTD XMLSCHEMA 200102//EN",schemadtd);
|
redirectEntity("-//W3C//DTD XMLSCHEMA 200102//EN",schemadtd);
|
||||||
redirect(this,"jsp_2_0.xsd",jsp20xsd);
|
redirectEntity("jsp_2_0.xsd",jsp20xsd);
|
||||||
redirect(this,"http://java.sun.com/xml/ns/j2ee/jsp_2_0.xsd",jsp20xsd);
|
redirectEntity("http://java.sun.com/xml/ns/j2ee/jsp_2_0.xsd",jsp20xsd);
|
||||||
redirect(this,"http://java.sun.com/xml/ns/javaee/jsp_2_1.xsd",jsp21xsd);
|
redirectEntity("http://java.sun.com/xml/ns/javaee/jsp_2_1.xsd",jsp21xsd);
|
||||||
redirect(this,"jsp_2_2.xsd",jsp22xsd);
|
redirectEntity("jsp_2_2.xsd",jsp22xsd);
|
||||||
redirect(this,"http://java.sun.com/xml/ns/javaee/jsp_2_2.xsd",jsp22xsd);
|
redirectEntity("http://java.sun.com/xml/ns/javaee/jsp_2_2.xsd",jsp22xsd);
|
||||||
redirect(this,"jsp_2_3.xsd",jsp23xsd);
|
redirectEntity("jsp_2_3.xsd",jsp23xsd);
|
||||||
redirect(this,"http://xmlns.jcp.org/xml/ns/javaee/jsp_2_3.xsd",jsp23xsd);
|
redirectEntity("http://xmlns.jcp.org/xml/ns/javaee/jsp_2_3.xsd",jsp23xsd);
|
||||||
redirect(this,"j2ee_1_4.xsd",j2ee14xsd);
|
redirectEntity("j2ee_1_4.xsd",j2ee14xsd);
|
||||||
redirect(this,"http://java.sun.com/xml/ns/j2ee/j2ee_1_4.xsd",j2ee14xsd);
|
redirectEntity("http://java.sun.com/xml/ns/j2ee/j2ee_1_4.xsd",j2ee14xsd);
|
||||||
redirect(this, "http://java.sun.com/xml/ns/javaee/javaee_5.xsd",javaee5);
|
redirectEntity( "http://java.sun.com/xml/ns/javaee/javaee_5.xsd",javaee5);
|
||||||
redirect(this, "http://java.sun.com/xml/ns/javaee/javaee_6.xsd",javaee6);
|
redirectEntity( "http://java.sun.com/xml/ns/javaee/javaee_6.xsd",javaee6);
|
||||||
redirect(this, "http://xmlns.jcp.org/xml/ns/javaee/javaee_7.xsd",javaee7);
|
redirectEntity( "http://xmlns.jcp.org/xml/ns/javaee/javaee_7.xsd",javaee7);
|
||||||
redirect(this,"web-app_2_4.xsd",webapp24xsd);
|
redirectEntity("web-app_2_4.xsd",webapp24xsd);
|
||||||
redirect(this,"http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd",webapp24xsd);
|
redirectEntity("http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd",webapp24xsd);
|
||||||
redirect(this,"web-app_2_5.xsd",webapp25xsd);
|
redirectEntity("web-app_2_5.xsd",webapp25xsd);
|
||||||
redirect(this,"http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd",webapp25xsd);
|
redirectEntity("http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd",webapp25xsd);
|
||||||
redirect(this,"web-app_3_0.xsd",webapp30xsd);
|
redirectEntity("web-app_3_0.xsd",webapp30xsd);
|
||||||
redirect(this,"http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd",webapp30xsd);
|
redirectEntity("http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd",webapp30xsd);
|
||||||
redirect(this,"web-common_3_0.xsd",webcommon30xsd);
|
redirectEntity("web-common_3_0.xsd",webcommon30xsd);
|
||||||
redirect(this,"http://java.sun.com/xml/ns/javaee/web-common_3_0.xsd",webcommon30xsd);
|
redirectEntity("http://java.sun.com/xml/ns/javaee/web-common_3_0.xsd",webcommon30xsd);
|
||||||
redirect(this,"web-fragment_3_0.xsd",webfragment30xsd);
|
redirectEntity("web-fragment_3_0.xsd",webfragment30xsd);
|
||||||
redirect(this,"http://java.sun.com/xml/ns/javaee/web-fragment_3_0.xsd",webfragment30xsd);
|
redirectEntity("http://java.sun.com/xml/ns/javaee/web-fragment_3_0.xsd",webfragment30xsd);
|
||||||
redirect(this,"web-app_3_1.xsd",webapp31xsd);
|
redirectEntity("web-app_3_1.xsd",webapp31xsd);
|
||||||
redirect(this,"http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd",webapp31xsd);
|
redirectEntity("http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd",webapp31xsd);
|
||||||
|
|
||||||
redirect(this,"web-common_3_1.xsd",webcommon30xsd);
|
redirectEntity("web-common_3_1.xsd",webcommon30xsd);
|
||||||
redirect(this,"http://xmlns.jcp.org/xml/ns/javaee/web-common_3_1.xsd",webcommon31xsd);
|
redirectEntity("http://xmlns.jcp.org/xml/ns/javaee/web-common_3_1.xsd",webcommon31xsd);
|
||||||
redirect(this,"web-fragment_3_1.xsd",webfragment30xsd);
|
redirectEntity("web-fragment_3_1.xsd",webfragment30xsd);
|
||||||
redirect(this,"http://xmlns.jcp.org/xml/ns/javaee/web-fragment_3_1.xsd",webfragment31xsd);
|
redirectEntity("http://xmlns.jcp.org/xml/ns/javaee/web-fragment_3_1.xsd",webfragment31xsd);
|
||||||
redirect(this,"xml.xsd",xmlxsd);
|
redirectEntity("xml.xsd",xmlxsd);
|
||||||
redirect(this,"http://www.w3.org/2001/xml.xsd",xmlxsd);
|
redirectEntity("http://www.w3.org/2001/xml.xsd",xmlxsd);
|
||||||
redirect(this,"datatypes.dtd",datatypesdtd);
|
redirectEntity("datatypes.dtd",datatypesdtd);
|
||||||
redirect(this,"http://www.w3.org/2001/datatypes.dtd",datatypesdtd);
|
redirectEntity("http://www.w3.org/2001/datatypes.dtd",datatypesdtd);
|
||||||
redirect(this,"j2ee_web_services_client_1_1.xsd",webservice11xsd);
|
redirectEntity("j2ee_web_services_client_1_1.xsd",webservice11xsd);
|
||||||
redirect(this,"http://www.ibm.com/webservices/xsd/j2ee_web_services_client_1_1.xsd",webservice11xsd);
|
redirectEntity("http://www.ibm.com/webservices/xsd/j2ee_web_services_client_1_1.xsd",webservice11xsd);
|
||||||
redirect(this,"javaee_web_services_client_1_2.xsd",webservice12xsd);
|
redirectEntity("javaee_web_services_client_1_2.xsd",webservice12xsd);
|
||||||
redirect(this,"http://www.ibm.com/webservices/xsd/javaee_web_services_client_1_2.xsd",webservice12xsd);
|
redirectEntity("http://www.ibm.com/webservices/xsd/javaee_web_services_client_1_2.xsd",webservice12xsd);
|
||||||
redirect(this,"javaee_web_services_client_1_3.xsd",webservice13xsd);
|
redirectEntity("javaee_web_services_client_1_3.xsd",webservice13xsd);
|
||||||
redirect(this,"http://java.sun.com/xml/ns/javaee/javaee_web_services_client_1_3.xsd",webservice13xsd);
|
redirectEntity("http://java.sun.com/xml/ns/javaee/javaee_web_services_client_1_3.xsd",webservice13xsd);
|
||||||
redirect(this,"javaee_web_services_client_1_4.xsd",webservice14xsd);
|
redirectEntity("javaee_web_services_client_1_4.xsd",webservice14xsd);
|
||||||
redirect(this,"http://xmlns.jcp.org/xml/ns/javaee/javaee_web_services_client_1_4.xsd",webservice14xsd);
|
redirectEntity("http://xmlns.jcp.org/xml/ns/javaee/javaee_web_services_client_1_4.xsd",webservice14xsd);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -317,6 +320,10 @@ public class WebDescriptor extends Descriptor
|
||||||
_validating = validating;
|
_validating = validating;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isValidating ()
|
||||||
|
{
|
||||||
|
return _validating;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isOrdered()
|
public boolean isOrdered()
|
||||||
{
|
{
|
||||||
|
|
|
@ -132,6 +132,12 @@ public class XmlParser
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
|
public boolean isValidating()
|
||||||
|
{
|
||||||
|
return _parser.isValidating();
|
||||||
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/**
|
/**
|
||||||
* @param name
|
* @param name
|
||||||
|
|
Loading…
Reference in New Issue