Merge remote-tracking branch 'origin/master' into jetty-http2
Conflicts: jetty-util/src/main/java/org/eclipse/jetty/util/IteratingCallback.java
This commit is contained in:
commit
5e281dd449
|
@ -19,12 +19,8 @@
|
|||
package org.eclipse.jetty.annotations;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.eclipse.jetty.plus.annotation.ContainerInitializer;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.util.ConcurrentHashSet;
|
||||
import org.eclipse.jetty.util.component.AbstractLifeCycle;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
|
|
@ -35,7 +35,6 @@ import org.eclipse.jetty.servlet.ServletMapping;
|
|||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.security.Constraint;
|
||||
import org.eclipse.jetty.webapp.Origin;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,7 +24,6 @@ import java.net.CookiePolicy;
|
|||
import java.net.CookieStore;
|
||||
import java.net.SocketAddress;
|
||||
import java.net.URI;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
|
|
|
@ -24,7 +24,6 @@ import java.util.Collections;
|
|||
import java.util.Iterator;
|
||||
|
||||
import org.eclipse.jetty.client.api.ContentProvider;
|
||||
import org.eclipse.jetty.client.util.DeferredContentProvider;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
|
|
|
@ -20,8 +20,6 @@ package org.eclipse.jetty.client.api;
|
|||
|
||||
import java.io.Closeable;
|
||||
|
||||
import org.eclipse.jetty.util.Promise;
|
||||
|
||||
/**
|
||||
* {@link Connection} represent a connection to a {@link Destination} and allow applications to send
|
||||
* requests via {@link #send(Request, Response.CompleteListener)}.
|
||||
|
|
|
@ -18,13 +18,7 @@
|
|||
|
||||
package org.eclipse.jetty.client.api;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.InputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.eclipse.jetty.client.util.ByteBufferContentProvider;
|
||||
import org.eclipse.jetty.client.util.PathContentProvider;
|
||||
|
||||
/**
|
||||
* {@link ContentProvider} provides a source of request content.
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.client.api;
|
||||
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.eclipse.jetty.util.FuturePromise;
|
||||
import org.eclipse.jetty.util.Promise;
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.eclipse.jetty.client.api;
|
|||
import java.io.IOException;
|
||||
import java.net.HttpCookie;
|
||||
import java.net.URI;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.file.Path;
|
||||
import java.util.EventListener;
|
||||
|
@ -31,8 +30,6 @@ import java.util.concurrent.ExecutionException;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.eclipse.jetty.client.util.InputStreamResponseListener;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.HttpMethod;
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.nio.ByteBuffer;
|
|||
import java.util.EventListener;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jetty.client.util.BufferingResponseListener;
|
||||
import org.eclipse.jetty.http.HttpField;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.http.HttpVersion;
|
||||
|
|
|
@ -21,9 +21,7 @@ package org.eclipse.jetty.client.util;
|
|||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.eclipse.jetty.client.api.Authentication;
|
||||
import org.eclipse.jetty.client.api.AuthenticationStore;
|
||||
import org.eclipse.jetty.client.api.ContentResponse;
|
||||
import org.eclipse.jetty.client.api.Request;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
|
|
|
@ -22,8 +22,6 @@ import java.nio.ByteBuffer;
|
|||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import org.eclipse.jetty.client.api.ContentProvider;
|
||||
|
||||
/**
|
||||
* A {@link ContentProvider} for {@link ByteBuffer}s.
|
||||
* <p />
|
||||
|
|
|
@ -22,8 +22,6 @@ import java.nio.ByteBuffer;
|
|||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import org.eclipse.jetty.client.api.ContentProvider;
|
||||
|
||||
/**
|
||||
* A {@link ContentProvider} for byte arrays.
|
||||
*/
|
||||
|
|
|
@ -30,9 +30,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.eclipse.jetty.client.AsyncContentProvider;
|
||||
import org.eclipse.jetty.client.api.ContentProvider;
|
||||
import org.eclipse.jetty.client.api.Request;
|
||||
import org.eclipse.jetty.client.api.Response;
|
||||
import org.eclipse.jetty.util.ArrayQueue;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
|
|
|
@ -33,9 +33,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.eclipse.jetty.client.api.Authentication;
|
||||
import org.eclipse.jetty.client.api.AuthenticationStore;
|
||||
import org.eclipse.jetty.client.api.ContentResponse;
|
||||
import org.eclipse.jetty.client.api.Request;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
|
|
|
@ -24,7 +24,6 @@ import java.nio.charset.Charset;
|
|||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.charset.UnsupportedCharsetException;
|
||||
|
||||
import org.eclipse.jetty.client.api.ContentProvider;
|
||||
import org.eclipse.jetty.util.Fields;
|
||||
|
||||
/**
|
||||
|
|
|
@ -32,7 +32,6 @@ import java.util.concurrent.TimeoutException;
|
|||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.eclipse.jetty.client.api.Response;
|
||||
import org.eclipse.jetty.client.api.Response.Listener;
|
||||
import org.eclipse.jetty.client.api.Result;
|
||||
|
|
|
@ -24,9 +24,6 @@ import java.nio.ByteBuffer;
|
|||
import java.util.Iterator;
|
||||
|
||||
import org.eclipse.jetty.client.AsyncContentProvider;
|
||||
import org.eclipse.jetty.client.api.ContentProvider;
|
||||
import org.eclipse.jetty.client.api.Request;
|
||||
import org.eclipse.jetty.client.api.Response;
|
||||
|
||||
/**
|
||||
* A {@link ContentProvider} that provides content asynchronously through an {@link OutputStream}
|
||||
|
|
|
@ -30,7 +30,6 @@ import java.nio.file.StandardOpenOption;
|
|||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import org.eclipse.jetty.client.api.ContentProvider;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
|
|
|
@ -21,8 +21,6 @@ package org.eclipse.jetty.client.util;
|
|||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.eclipse.jetty.client.api.ContentProvider;
|
||||
|
||||
/**
|
||||
* A {@link ContentProvider} for strings.
|
||||
* <p />
|
||||
|
|
|
@ -42,7 +42,6 @@ import org.eclipse.jetty.http.HttpHeader;
|
|||
import org.eclipse.jetty.http.HttpVersion;
|
||||
import org.eclipse.jetty.io.ByteArrayEndPoint;
|
||||
import org.eclipse.jetty.toolchain.test.TestTracker;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
|
|
@ -18,12 +18,7 @@
|
|||
|
||||
package org.eclipse.jetty.continuation;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.Servlet;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.ServletResponseWrapper;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
|
|
|
@ -20,8 +20,6 @@ package org.eclipse.jetty.continuation;
|
|||
|
||||
import java.util.EventListener;
|
||||
|
||||
import javax.servlet.ServletRequestListener;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** A Continuation Listener
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.deploy;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.util.component.LifeCycle;
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ import java.util.Locale;
|
|||
import org.eclipse.jetty.deploy.App;
|
||||
import org.eclipse.jetty.deploy.ConfigurationManager;
|
||||
import org.eclipse.jetty.deploy.util.FileID;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.util.URIUtil;
|
||||
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||
|
|
|
@ -26,7 +26,6 @@ import static org.hamcrest.Matchers.not;
|
|||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jetty.deploy.providers.ScanningAppProvider;
|
||||
import org.eclipse.jetty.deploy.test.XmlConfiguredJetty;
|
||||
import org.eclipse.jetty.toolchain.test.IO;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
|
|
|
@ -27,10 +27,6 @@ import static org.junit.Assert.assertTrue;
|
|||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Assert;
|
||||
|
|
|
@ -20,8 +20,6 @@ package org.eclipse.jetty.io;
|
|||
|
||||
import java.io.Closeable;
|
||||
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
|
||||
/**
|
||||
* <p>A {@link Connection} is associated to an {@link EndPoint} so that I/O events
|
||||
* happening on the {@link EndPoint} can be processed by the {@link Connection}.</p>
|
||||
|
|
|
@ -26,8 +26,6 @@ import java.nio.channels.ReadPendingException;
|
|||
import java.nio.channels.WritePendingException;
|
||||
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
import org.eclipse.jetty.util.FutureCallback;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -25,7 +25,6 @@ import java.nio.channels.SelectionKey;
|
|||
import java.nio.channels.SocketChannel;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.thread.Scheduler;
|
||||
|
|
|
@ -21,8 +21,6 @@ package org.eclipse.jetty.io;
|
|||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.net.ConnectException;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketAddress;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.nio.channels.CancelledKeyException;
|
||||
import java.nio.channels.SelectionKey;
|
||||
|
|
|
@ -38,7 +38,6 @@ import org.eclipse.jetty.io.EndPoint;
|
|||
import org.eclipse.jetty.io.EofException;
|
||||
import org.eclipse.jetty.io.FillInterest;
|
||||
import org.eclipse.jetty.io.RuntimeIOException;
|
||||
import org.eclipse.jetty.io.SelectChannelEndPoint;
|
||||
import org.eclipse.jetty.io.WriteFlusher;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
|
|
|
@ -24,7 +24,6 @@ import java.sql.Statement;
|
|||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.eclipse.jetty.util.component.ContainerLifeCycle;
|
||||
import org.eclipse.jetty.util.component.Destroyable;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
|
|
@ -80,6 +80,11 @@
|
|||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-quickstart</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-jaas</artifactId>
|
||||
|
|
|
@ -27,7 +27,6 @@ import java.net.URL;
|
|||
import java.net.URLClassLoader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
@ -684,7 +683,7 @@ public abstract class AbstractJettyMojo extends AbstractMojo
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private void printSystemProperties ()
|
||||
protected void printSystemProperties ()
|
||||
{
|
||||
// print out which system properties were set up
|
||||
if (getLog().isDebugEnabled())
|
||||
|
|
|
@ -39,34 +39,35 @@ import java.util.Random;
|
|||
import java.util.Set;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugin.MojoFailureException;
|
||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.eclipse.jetty.annotations.AnnotationConfiguration;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.util.resource.ResourceCollection;
|
||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* This goal is used to assemble your webapp into a war and automatically deploy it to Jetty in a forked JVM.
|
||||
* This goal is used to deploy your unassembled webapp into a forked JVM.
|
||||
* </p>
|
||||
* <p>
|
||||
* You need to define a jetty.xml file to configure connectors etc and a context xml file that sets up anything special
|
||||
* about your webapp. This plugin will fill in the:
|
||||
* <ul>
|
||||
* <li>context path
|
||||
* <li>classes
|
||||
* <li>web.xml
|
||||
* <li>root of the webapp
|
||||
* </ul>
|
||||
* Based on a combination of information that you supply and the location of files in your unassembled webapp.
|
||||
* You need to define a jetty.xml file to configure connectors etc. You can use the normal setters of o.e.j.webapp.WebAppContext on the <b>webApp</b>
|
||||
* configuration element for this plugin. You may also need context xml file for any particularly complex webapp setup.
|
||||
* about your webapp.
|
||||
* </p>
|
||||
* <p>
|
||||
* There is a <a href="run-war-mojo.html">reference guide</a> to the configuration parameters for this plugin, and more detailed information
|
||||
* with examples in the <a href="http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin/">Configuration Guide</a>.
|
||||
* Unlike the other jetty goals, this does NOT support the <b>scanIntervalSeconds</b> parameter: the webapp will be deployed only once.
|
||||
* </p>
|
||||
* <p>
|
||||
* The <b>stopKey</b>, <b>stopPort</b> configuration elements can be used to control the stopping of the forked process. By default, this plugin will launch
|
||||
* the forked jetty instance and wait for it to complete (in which case it acts much like the <b>jetty:run</b> goal, and you will need to Cntrl-C to stop).
|
||||
* By setting the configuration element <b>waitForChild</b> to <b>false</b>, the plugin will terminate after having forked the jetty process. In this case
|
||||
* you can use the <b>jetty:stop</b> goal to terminate the process.
|
||||
* <p>
|
||||
* See <a href="http://www.eclipse.org/jetty/documentation/">http://www.eclipse.org/jetty/documentation</a> for more information on this and other jetty plugins.
|
||||
* </p>
|
||||
*
|
||||
* @goal run-forked
|
||||
|
@ -75,7 +76,7 @@ import org.eclipse.jetty.util.resource.ResourceCollection;
|
|||
* @description Runs Jetty in forked JVM on an unassembled webapp
|
||||
*
|
||||
*/
|
||||
public class JettyRunForkedMojo extends AbstractMojo
|
||||
public class JettyRunForkedMojo extends JettyRunMojo
|
||||
{
|
||||
public static final String DEFAULT_WEBAPP_SRC = "src"+File.separator+"main"+File.separator+"webapp";
|
||||
public static final String FAKE_WEBAPP = "webapp-tmp";
|
||||
|
@ -83,42 +84,10 @@ public class JettyRunForkedMojo extends AbstractMojo
|
|||
|
||||
public String PORT_SYSPROPERTY = "jetty.port";
|
||||
|
||||
/**
|
||||
* Whether or not to include dependencies on the plugin's classpath with <scope>provided</scope>
|
||||
* Use WITH CAUTION as you may wind up with duplicate jars/classes.
|
||||
* @parameter default-value="false"
|
||||
*/
|
||||
protected boolean useProvidedScope;
|
||||
|
||||
|
||||
/**
|
||||
* The maven project.
|
||||
*
|
||||
* @parameter expression="${project}"
|
||||
* @required
|
||||
* @readonly
|
||||
*/
|
||||
private MavenProject project;
|
||||
|
||||
|
||||
/**
|
||||
* If true, the <testOutputDirectory>
|
||||
* and the dependencies of <scope>test<scope>
|
||||
* will be put first on the runtime classpath.
|
||||
* @parameter alias="useTestClasspath" default-value="false"
|
||||
*/
|
||||
private boolean useTestScope;
|
||||
|
||||
|
||||
/**
|
||||
* The default location of the web.xml file. Will be used
|
||||
* if <webAppConfig><descriptor> is not set.
|
||||
*
|
||||
* @parameter expression="${basedir}/src/main/webapp/WEB-INF/web.xml"
|
||||
* @readonly
|
||||
*/
|
||||
private String webXml;
|
||||
|
||||
|
||||
/**
|
||||
* The target directory
|
||||
|
@ -130,118 +99,6 @@ public class JettyRunForkedMojo extends AbstractMojo
|
|||
protected File target;
|
||||
|
||||
|
||||
/**
|
||||
* The temporary directory to use for the webapp.
|
||||
* Defaults to target/tmp
|
||||
*
|
||||
* @parameter alias="tmpDirectory" expression="${project.build.directory}/tmp"
|
||||
* @required
|
||||
* @readonly
|
||||
*/
|
||||
protected File tempDirectory;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Whether temporary directory contents should survive webapp restarts.
|
||||
*
|
||||
* @parameter default-value="false"
|
||||
*/
|
||||
private boolean persistTempDirectory;
|
||||
|
||||
|
||||
/**
|
||||
* The directory containing generated classes.
|
||||
*
|
||||
* @parameter expression="${project.build.outputDirectory}"
|
||||
* @required
|
||||
*
|
||||
*/
|
||||
private File classesDirectory;
|
||||
|
||||
|
||||
/**
|
||||
* The directory containing generated test classes.
|
||||
*
|
||||
* @parameter expression="${project.build.testOutputDirectory}"
|
||||
* @required
|
||||
*/
|
||||
private File testClassesDirectory;
|
||||
|
||||
|
||||
/**
|
||||
* Root directory for all html/jsp etc files
|
||||
*
|
||||
* @parameter expression="${basedir}/src/main/webapp"
|
||||
*
|
||||
*/
|
||||
private File webAppSourceDirectory;
|
||||
|
||||
/**
|
||||
* Resource Bases
|
||||
*
|
||||
* @parameter
|
||||
*
|
||||
*/
|
||||
private String[] resourceBases;
|
||||
|
||||
/**
|
||||
* If true, the webAppSourceDirectory will be first on the list of
|
||||
* resources that form the resource base for the webapp. If false,
|
||||
* it will be last.
|
||||
*
|
||||
* @parameter default-value="true"
|
||||
*/
|
||||
private boolean baseAppFirst;
|
||||
|
||||
|
||||
/**
|
||||
* Location of jetty xml configuration files whose contents
|
||||
* will be applied before any plugin configuration. Optional.
|
||||
* @parameter
|
||||
*/
|
||||
private String jettyXml;
|
||||
|
||||
/**
|
||||
* The context path for the webapp. Defaults to / for jetty-9
|
||||
*
|
||||
* @parameter expression="/"
|
||||
*/
|
||||
private String contextPath;
|
||||
|
||||
|
||||
/**
|
||||
* Location of a context xml configuration file whose contents
|
||||
* will be applied to the webapp AFTER anything in <webAppConfig>.Optional.
|
||||
* @parameter
|
||||
*/
|
||||
private String contextXml;
|
||||
|
||||
|
||||
/**
|
||||
* @parameter expression="${jetty.skip}" default-value="false"
|
||||
*/
|
||||
private boolean skip;
|
||||
|
||||
|
||||
/**
|
||||
* Port to listen to stop jetty on executing -DSTOP.PORT=<stopPort>
|
||||
* -DSTOP.KEY=<stopKey> -jar start.jar --stop
|
||||
* @parameter
|
||||
* @required
|
||||
*/
|
||||
protected int stopPort;
|
||||
|
||||
|
||||
/**
|
||||
* Key to provide when stopping jetty on executing java -DSTOP.KEY=<stopKey>
|
||||
* -DSTOP.PORT=<stopPort> -jar start.jar --stop
|
||||
* @parameter
|
||||
* @required
|
||||
*/
|
||||
protected String stopKey;
|
||||
|
||||
|
||||
/**
|
||||
* Arbitrary jvm args to pass to the forked process
|
||||
* @parameter
|
||||
|
@ -286,7 +143,7 @@ public class JettyRunForkedMojo extends AbstractMojo
|
|||
|
||||
|
||||
|
||||
|
||||
private Resource originalBaseResource;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -360,332 +217,62 @@ public class JettyRunForkedMojo extends AbstractMojo
|
|||
*/
|
||||
public void execute() throws MojoExecutionException, MojoFailureException
|
||||
{
|
||||
getLog().info("Configuring Jetty for project: " + project.getName());
|
||||
if (skip)
|
||||
{
|
||||
getLog().info("Skipping Jetty start: jetty.skip==true");
|
||||
return;
|
||||
}
|
||||
PluginLog.setLog(getLog());
|
||||
Runtime.getRuntime().addShutdownHook(new ShutdownThread());
|
||||
random = new Random();
|
||||
startJettyRunner();
|
||||
super.execute();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @throws MojoExecutionException
|
||||
*/
|
||||
public List<String> getProvidedJars() throws MojoExecutionException
|
||||
{
|
||||
//if we are configured to include the provided dependencies on the plugin's classpath
|
||||
//(which mimics being on jetty's classpath vs being on the webapp's classpath), we first
|
||||
//try and filter out ones that will clash with jars that are plugin dependencies, then
|
||||
//create a new classloader that we setup in the parent chain.
|
||||
if (useProvidedScope)
|
||||
{
|
||||
|
||||
List<String> provided = new ArrayList<String>();
|
||||
for ( Iterator<Artifact> iter = project.getArtifacts().iterator(); iter.hasNext(); )
|
||||
{
|
||||
Artifact artifact = iter.next();
|
||||
if (Artifact.SCOPE_PROVIDED.equals(artifact.getScope()) && !isPluginArtifact(artifact))
|
||||
{
|
||||
provided.add(artifact.getFile().getAbsolutePath());
|
||||
if (getLog().isDebugEnabled()) { getLog().debug("Adding provided artifact: "+artifact);}
|
||||
}
|
||||
}
|
||||
return provided;
|
||||
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @throws MojoExecutionException
|
||||
*/
|
||||
public File prepareConfiguration() throws MojoExecutionException
|
||||
@Override
|
||||
public void startJetty() throws MojoExecutionException
|
||||
{
|
||||
//Only do enough setup to be able to produce a quickstart-web.xml file to
|
||||
//pass onto the forked process to run
|
||||
try
|
||||
{
|
||||
//work out the configuration based on what is configured in the pom
|
||||
File propsFile = new File (target, "fork.props");
|
||||
if (propsFile.exists())
|
||||
propsFile.delete();
|
||||
printSystemProperties();
|
||||
|
||||
propsFile.createNewFile();
|
||||
//propsFile.deleteOnExit();
|
||||
|
||||
Properties props = new Properties();
|
||||
//apply any config from a jetty.xml file first to our "fake" server instance
|
||||
//TODO probably not necessary
|
||||
applyJettyXml ();
|
||||
|
||||
|
||||
//web.xml
|
||||
if (webXml != null)
|
||||
props.put("web.xml", webXml);
|
||||
server.configureHandlers();
|
||||
|
||||
//sort out the context path
|
||||
if (contextPath != null)
|
||||
props.put("context.path", contextPath);
|
||||
//ensure config of the webapp based on settings in plugin
|
||||
configureWebApplication();
|
||||
|
||||
//sort out the tmp directory (make it if it doesn't exist)
|
||||
if (tempDirectory != null)
|
||||
{
|
||||
if (!tempDirectory.exists())
|
||||
tempDirectory.mkdirs();
|
||||
props.put("tmp.dir", tempDirectory.getAbsolutePath());
|
||||
}
|
||||
//copy the base resource as configured by the plugin
|
||||
originalBaseResource = webApp.getBaseResource();
|
||||
|
||||
props.put("tmp.dir.persist", Boolean.toString(persistTempDirectory));
|
||||
//set the webapp up to do very little other than generate the quickstart-web.xml
|
||||
webApp.setCopyWebDir(false);
|
||||
webApp.setCopyWebInf(false);
|
||||
webApp.setGenerateQuickStart(true);
|
||||
webApp.setQuickStartDir(target);
|
||||
|
||||
if (resourceBases == null)
|
||||
{
|
||||
//sort out base dir of webapp
|
||||
if (webAppSourceDirectory == null || !webAppSourceDirectory.exists())
|
||||
{
|
||||
webAppSourceDirectory = new File (project.getBasedir(), DEFAULT_WEBAPP_SRC);
|
||||
if (!webAppSourceDirectory.exists())
|
||||
{
|
||||
//try last resort of making a fake empty dir
|
||||
File target = new File(project.getBuild().getDirectory());
|
||||
webAppSourceDirectory = new File(target, FAKE_WEBAPP);
|
||||
if (!webAppSourceDirectory.exists())
|
||||
webAppSourceDirectory.mkdirs();
|
||||
}
|
||||
}
|
||||
resourceBases = new String[] { webAppSourceDirectory.getAbsolutePath() };
|
||||
}
|
||||
StringBuffer rb = new StringBuffer(resourceBases[0]);
|
||||
for (int i=1; i<resourceBases.length; i++)
|
||||
{
|
||||
rb.append(File.pathSeparator);
|
||||
rb.append(resourceBases[i]);
|
||||
}
|
||||
props.put("base.dirs", rb.toString());
|
||||
server.addWebApplication(webApp);
|
||||
|
||||
//sort out the resource base directories of the webapp
|
||||
StringBuilder builder = new StringBuilder();
|
||||
props.put("base.first", Boolean.toString(baseAppFirst));
|
||||
//if our server has a thread pool associated we can do any annotation scanning multithreaded,
|
||||
//otherwise scanning will be single threaded
|
||||
QueuedThreadPool tpool = server.getBean(QueuedThreadPool.class);
|
||||
if (tpool != null)
|
||||
tpool.start();
|
||||
else
|
||||
webApp.setAttribute(AnnotationConfiguration.MULTI_THREADED, Boolean.FALSE.toString());
|
||||
|
||||
//web-inf classes
|
||||
List<File> classDirs = getClassesDirs();
|
||||
StringBuffer strbuff = new StringBuffer();
|
||||
for (int i=0; i<classDirs.size(); i++)
|
||||
{
|
||||
File f = classDirs.get(i);
|
||||
strbuff.append(f.getAbsolutePath());
|
||||
if (i < classDirs.size()-1)
|
||||
strbuff.append(",");
|
||||
}
|
||||
|
||||
if (classesDirectory != null)
|
||||
{
|
||||
props.put("classes.dir", classesDirectory.getAbsolutePath());
|
||||
}
|
||||
|
||||
if (useTestScope && testClassesDirectory != null)
|
||||
{
|
||||
props.put("testClasses.dir", testClassesDirectory.getAbsolutePath());
|
||||
}
|
||||
|
||||
//web-inf lib
|
||||
List<File> deps = getDependencyFiles();
|
||||
strbuff.setLength(0);
|
||||
for (int i=0; i<deps.size(); i++)
|
||||
{
|
||||
File d = deps.get(i);
|
||||
strbuff.append(d.getAbsolutePath());
|
||||
if (i < deps.size()-1)
|
||||
strbuff.append(",");
|
||||
}
|
||||
props.put("lib.jars", strbuff.toString());
|
||||
|
||||
//any war files
|
||||
List<Artifact> warArtifacts = getWarArtifacts();
|
||||
for (int i=0; i<warArtifacts.size(); i++)
|
||||
{
|
||||
strbuff.setLength(0);
|
||||
Artifact a = warArtifacts.get(i);
|
||||
strbuff.append(a.getGroupId()+",");
|
||||
strbuff.append(a.getArtifactId()+",");
|
||||
strbuff.append(a.getFile().getAbsolutePath());
|
||||
props.put("maven.war.artifact."+i, strbuff.toString());
|
||||
}
|
||||
|
||||
|
||||
//any overlay configuration
|
||||
WarPluginInfo warPlugin = new WarPluginInfo(project);
|
||||
|
||||
//add in the war plugins default includes and excludes
|
||||
props.put("maven.war.includes", toCSV(warPlugin.getDependentMavenWarIncludes()));
|
||||
props.put("maven.war.excludes", toCSV(warPlugin.getDependentMavenWarExcludes()));
|
||||
|
||||
|
||||
List<OverlayConfig> configs = warPlugin.getMavenWarOverlayConfigs();
|
||||
int i=0;
|
||||
for (OverlayConfig c:configs)
|
||||
{
|
||||
props.put("maven.war.overlay."+(i++), c.toString());
|
||||
}
|
||||
|
||||
try (OutputStream out = new BufferedOutputStream(new FileOutputStream(propsFile)))
|
||||
{
|
||||
props.store(out, "properties for forked webapp");
|
||||
}
|
||||
return propsFile;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new MojoExecutionException("Prepare webapp configuration", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
private List<File> getClassesDirs ()
|
||||
{
|
||||
List<File> classesDirs = new ArrayList<File>();
|
||||
|
||||
//if using the test classes, make sure they are first
|
||||
//on the list
|
||||
if (useTestScope && (testClassesDirectory != null))
|
||||
classesDirs.add(testClassesDirectory);
|
||||
|
||||
if (classesDirectory != null)
|
||||
classesDirs.add(classesDirectory);
|
||||
|
||||
return classesDirs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @throws MalformedURLException
|
||||
* @throws IOException
|
||||
*/
|
||||
private List<Artifact> getWarArtifacts()
|
||||
throws MalformedURLException, IOException
|
||||
{
|
||||
List<Artifact> warArtifacts = new ArrayList<Artifact>();
|
||||
for ( Iterator<Artifact> iter = project.getArtifacts().iterator(); iter.hasNext(); )
|
||||
{
|
||||
Artifact artifact = (Artifact) iter.next();
|
||||
|
||||
if (artifact.getType().equals("war"))
|
||||
warArtifacts.add(artifact);
|
||||
}
|
||||
|
||||
return warArtifacts;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
private List<File> getDependencyFiles ()
|
||||
{
|
||||
List<File> dependencyFiles = new ArrayList<File>();
|
||||
|
||||
for ( Iterator<Artifact> iter = project.getArtifacts().iterator(); iter.hasNext(); )
|
||||
{
|
||||
Artifact artifact = (Artifact) iter.next();
|
||||
// Test never appears here !
|
||||
if (((!Artifact.SCOPE_PROVIDED.equals(artifact.getScope())) && (!Artifact.SCOPE_TEST.equals( artifact.getScope())))
|
||||
||
|
||||
(useTestScope && Artifact.SCOPE_TEST.equals( artifact.getScope())))
|
||||
{
|
||||
dependencyFiles.add(artifact.getFile());
|
||||
getLog().debug( "Adding artifact " + artifact.getFile().getName() + " for WEB-INF/lib " );
|
||||
}
|
||||
}
|
||||
|
||||
return dependencyFiles;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param artifact
|
||||
* @return
|
||||
*/
|
||||
public boolean isPluginArtifact(Artifact artifact)
|
||||
{
|
||||
if (pluginArtifacts == null || pluginArtifacts.isEmpty())
|
||||
return false;
|
||||
|
||||
boolean isPluginArtifact = false;
|
||||
for (Iterator<Artifact> iter = pluginArtifacts.iterator(); iter.hasNext() && !isPluginArtifact; )
|
||||
{
|
||||
Artifact pluginArtifact = iter.next();
|
||||
if (getLog().isDebugEnabled()) { getLog().debug("Checking "+pluginArtifact);}
|
||||
if (pluginArtifact.getGroupId().equals(artifact.getGroupId()) && pluginArtifact.getArtifactId().equals(artifact.getArtifactId()))
|
||||
isPluginArtifact = true;
|
||||
}
|
||||
|
||||
return isPluginArtifact;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private Set<Artifact> getExtraJars()
|
||||
throws Exception
|
||||
{
|
||||
Set<Artifact> extraJars = new HashSet<Artifact>();
|
||||
|
||||
|
||||
List l = pluginArtifacts;
|
||||
Artifact pluginArtifact = null;
|
||||
|
||||
if (l != null)
|
||||
{
|
||||
Iterator itor = l.iterator();
|
||||
while (itor.hasNext() && pluginArtifact == null)
|
||||
{
|
||||
Artifact a = (Artifact)itor.next();
|
||||
if (a.getArtifactId().equals(plugin.getArtifactId())) //get the jetty-maven-plugin jar
|
||||
{
|
||||
extraJars.add(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return extraJars;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @throws MojoExecutionException
|
||||
*/
|
||||
public void startJettyRunner() throws MojoExecutionException
|
||||
{
|
||||
try
|
||||
{
|
||||
webApp.start(); //just enough to generate the quickstart
|
||||
|
||||
//save config of the webapp BEFORE we stop
|
||||
File props = prepareConfiguration();
|
||||
|
||||
webApp.stop();
|
||||
|
||||
if (tpool != null)
|
||||
tpool.stop();
|
||||
|
||||
List<String> cmd = new ArrayList<String>();
|
||||
cmd.add(getJavaBin());
|
||||
|
||||
|
@ -699,7 +286,7 @@ public class JettyRunForkedMojo extends AbstractMojo
|
|||
}
|
||||
}
|
||||
|
||||
String classPath = getClassPath();
|
||||
String classPath = getContainerClassPath();
|
||||
if (classPath != null && classPath.length() > 0)
|
||||
{
|
||||
cmd.add("-cp");
|
||||
|
@ -807,11 +394,258 @@ public class JettyRunForkedMojo extends AbstractMojo
|
|||
|
||||
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @throws MojoExecutionException
|
||||
*/
|
||||
public List<String> getProvidedJars() throws MojoExecutionException
|
||||
{
|
||||
//if we are configured to include the provided dependencies on the plugin's classpath
|
||||
//(which mimics being on jetty's classpath vs being on the webapp's classpath), we first
|
||||
//try and filter out ones that will clash with jars that are plugin dependencies, then
|
||||
//create a new classloader that we setup in the parent chain.
|
||||
if (useProvidedScope)
|
||||
{
|
||||
|
||||
List<String> provided = new ArrayList<String>();
|
||||
for ( Iterator<Artifact> iter = project.getArtifacts().iterator(); iter.hasNext(); )
|
||||
{
|
||||
Artifact artifact = iter.next();
|
||||
if (Artifact.SCOPE_PROVIDED.equals(artifact.getScope()) && !isPluginArtifact(artifact))
|
||||
{
|
||||
provided.add(artifact.getFile().getAbsolutePath());
|
||||
if (getLog().isDebugEnabled()) { getLog().debug("Adding provided artifact: "+artifact);}
|
||||
}
|
||||
}
|
||||
return provided;
|
||||
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @throws MojoExecutionException
|
||||
*/
|
||||
public File prepareConfiguration() throws MojoExecutionException
|
||||
{
|
||||
try
|
||||
{
|
||||
//work out the configuration based on what is configured in the pom
|
||||
File propsFile = new File (target, "fork.props");
|
||||
if (propsFile.exists())
|
||||
propsFile.delete();
|
||||
|
||||
propsFile.createNewFile();
|
||||
//propsFile.deleteOnExit();
|
||||
|
||||
Properties props = new Properties();
|
||||
|
||||
|
||||
//web.xml
|
||||
if (webApp.getDescriptor() != null)
|
||||
{
|
||||
props.put("web.xml", webApp.getDescriptor());
|
||||
}
|
||||
|
||||
if (webApp.getQuickStartWebDescriptor() != null)
|
||||
{
|
||||
props.put("quickstart.web.xml", webApp.getQuickStartWebDescriptor().getFile().getAbsolutePath());
|
||||
}
|
||||
|
||||
//sort out the context path
|
||||
if (webApp.getContextPath() != null)
|
||||
{
|
||||
props.put("context.path", webApp.getContextPath());
|
||||
}
|
||||
|
||||
//tmp dir
|
||||
props.put("tmp.dir", webApp.getTempDirectory().getAbsolutePath());
|
||||
props.put("tmp.dir.persist", Boolean.toString(webApp.isPersistTempDirectory()));
|
||||
|
||||
//resource bases - these are what has been configured BEFORE the webapp started and
|
||||
//potentially reordered them and included any resources from META-INF
|
||||
if (originalBaseResource != null)
|
||||
{
|
||||
StringBuffer rb = new StringBuffer();
|
||||
if (originalBaseResource instanceof ResourceCollection)
|
||||
{
|
||||
ResourceCollection resources = ((ResourceCollection)originalBaseResource);
|
||||
for (Resource r:resources.getResources())
|
||||
{
|
||||
if (rb.length() > 0) rb.append(",");
|
||||
rb.append(r.toString());
|
||||
}
|
||||
}
|
||||
else
|
||||
rb.append(originalBaseResource.toString());
|
||||
|
||||
props.put("base.dirs", rb.toString());
|
||||
}
|
||||
|
||||
//sort out the resource base directories of the webapp
|
||||
props.put("base.first", Boolean.toString(webApp.getBaseAppFirst()));
|
||||
|
||||
//web-inf classes
|
||||
if (webApp.getClasses() != null)
|
||||
{
|
||||
props.put("classes.dir",webApp.getClasses().getAbsolutePath());
|
||||
}
|
||||
|
||||
if (useTestScope && webApp.getTestClasses() != null)
|
||||
{
|
||||
props.put("testClasses.dir", webApp.getTestClasses().getAbsolutePath());
|
||||
}
|
||||
|
||||
//web-inf lib
|
||||
List<File> deps = webApp.getWebInfLib();
|
||||
StringBuffer strbuff = new StringBuffer();
|
||||
for (int i=0; i<deps.size(); i++)
|
||||
{
|
||||
File d = deps.get(i);
|
||||
strbuff.append(d.getAbsolutePath());
|
||||
if (i < deps.size()-1)
|
||||
strbuff.append(",");
|
||||
}
|
||||
props.put("lib.jars", strbuff.toString());
|
||||
|
||||
//any war files
|
||||
List<Artifact> warArtifacts = getWarArtifacts();
|
||||
for (int i=0; i<warArtifacts.size(); i++)
|
||||
{
|
||||
strbuff.setLength(0);
|
||||
Artifact a = warArtifacts.get(i);
|
||||
strbuff.append(a.getGroupId()+",");
|
||||
strbuff.append(a.getArtifactId()+",");
|
||||
strbuff.append(a.getFile().getAbsolutePath());
|
||||
props.put("maven.war.artifact."+i, strbuff.toString());
|
||||
}
|
||||
|
||||
|
||||
//any overlay configuration
|
||||
WarPluginInfo warPlugin = new WarPluginInfo(project);
|
||||
|
||||
//add in the war plugins default includes and excludes
|
||||
props.put("maven.war.includes", toCSV(warPlugin.getDependentMavenWarIncludes()));
|
||||
props.put("maven.war.excludes", toCSV(warPlugin.getDependentMavenWarExcludes()));
|
||||
|
||||
|
||||
List<OverlayConfig> configs = warPlugin.getMavenWarOverlayConfigs();
|
||||
int i=0;
|
||||
for (OverlayConfig c:configs)
|
||||
{
|
||||
props.put("maven.war.overlay."+(i++), c.toString());
|
||||
}
|
||||
|
||||
try (OutputStream out = new BufferedOutputStream(new FileOutputStream(propsFile)))
|
||||
{
|
||||
props.store(out, "properties for forked webapp");
|
||||
}
|
||||
return propsFile;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new MojoExecutionException("Prepare webapp configuration", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @throws MalformedURLException
|
||||
* @throws IOException
|
||||
*/
|
||||
private List<Artifact> getWarArtifacts()
|
||||
throws MalformedURLException, IOException
|
||||
{
|
||||
List<Artifact> warArtifacts = new ArrayList<Artifact>();
|
||||
for ( Iterator<Artifact> iter = project.getArtifacts().iterator(); iter.hasNext(); )
|
||||
{
|
||||
Artifact artifact = (Artifact) iter.next();
|
||||
|
||||
if (artifact.getType().equals("war"))
|
||||
warArtifacts.add(artifact);
|
||||
}
|
||||
|
||||
return warArtifacts;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param artifact
|
||||
* @return
|
||||
*/
|
||||
public boolean isPluginArtifact(Artifact artifact)
|
||||
{
|
||||
if (pluginArtifacts == null || pluginArtifacts.isEmpty())
|
||||
return false;
|
||||
|
||||
boolean isPluginArtifact = false;
|
||||
for (Iterator<Artifact> iter = pluginArtifacts.iterator(); iter.hasNext() && !isPluginArtifact; )
|
||||
{
|
||||
Artifact pluginArtifact = iter.next();
|
||||
if (getLog().isDebugEnabled()) { getLog().debug("Checking "+pluginArtifact);}
|
||||
if (pluginArtifact.getGroupId().equals(artifact.getGroupId()) && pluginArtifact.getArtifactId().equals(artifact.getArtifactId()))
|
||||
isPluginArtifact = true;
|
||||
}
|
||||
|
||||
return isPluginArtifact;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public String getClassPath() throws Exception
|
||||
private Set<Artifact> getExtraJars()
|
||||
throws Exception
|
||||
{
|
||||
Set<Artifact> extraJars = new HashSet<Artifact>();
|
||||
|
||||
|
||||
List l = pluginArtifacts;
|
||||
Artifact pluginArtifact = null;
|
||||
|
||||
if (l != null)
|
||||
{
|
||||
Iterator itor = l.iterator();
|
||||
while (itor.hasNext() && pluginArtifact == null)
|
||||
{
|
||||
Artifact a = (Artifact)itor.next();
|
||||
if (a.getArtifactId().equals(plugin.getArtifactId())) //get the jetty-maven-plugin jar
|
||||
{
|
||||
extraJars.add(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return extraJars;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public String getContainerClassPath() throws Exception
|
||||
{
|
||||
StringBuilder classPath = new StringBuilder();
|
||||
for (Object obj : pluginArtifacts)
|
||||
|
|
|
@ -32,6 +32,8 @@ import java.util.TreeSet;
|
|||
import org.eclipse.jetty.annotations.AnnotationConfiguration;
|
||||
import org.eclipse.jetty.plus.webapp.EnvConfiguration;
|
||||
import org.eclipse.jetty.plus.webapp.PlusConfiguration;
|
||||
import org.eclipse.jetty.quickstart.PreconfigureDescriptorProcessor;
|
||||
import org.eclipse.jetty.quickstart.QuickStartDescriptorGenerator;
|
||||
import org.eclipse.jetty.servlet.FilterHolder;
|
||||
import org.eclipse.jetty.servlet.FilterMapping;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
|
@ -62,19 +64,39 @@ public class JettyWebAppContext extends WebAppContext
|
|||
{
|
||||
private static final Logger LOG = Log.getLogger(JettyWebAppContext.class);
|
||||
|
||||
|
||||
|
||||
private static final String DEFAULT_CONTAINER_INCLUDE_JAR_PATTERN = ".*/javax.servlet-[^/]*\\.jar$|.*/servlet-api-[^/]*\\.jar$|.*javax.servlet.jsp.jstl-[^/]*\\.jar";
|
||||
private static final String WEB_INF_CLASSES_PREFIX = "/WEB-INF/classes";
|
||||
private static final String WEB_INF_LIB_PREFIX = "/WEB-INF/lib";
|
||||
|
||||
private final Configuration[] _defaultConfigurations = {
|
||||
new MavenWebInfConfiguration(),
|
||||
new WebXmlConfiguration(),
|
||||
new MetaInfConfiguration(),
|
||||
new FragmentConfiguration(),
|
||||
new EnvConfiguration(),
|
||||
new PlusConfiguration(),
|
||||
new AnnotationConfiguration(),
|
||||
new JettyWebXmlConfiguration()
|
||||
};
|
||||
|
||||
private final Configuration[] _quickStartConfigurations = {
|
||||
new MavenQuickStartConfiguration(),
|
||||
new EnvConfiguration(),
|
||||
new PlusConfiguration(),
|
||||
new JettyWebXmlConfiguration()
|
||||
};
|
||||
|
||||
private File _classes = null;
|
||||
private File _testClasses = null;
|
||||
private final List<File> _webInfClasses = new ArrayList<File>();
|
||||
private final List<File> _webInfJars = new ArrayList<File>();
|
||||
private final Map<String, File> _webInfJarMap = new HashMap<String, File>();
|
||||
private final EnvConfiguration _envConfig;
|
||||
private List<File> _classpathFiles; //webInfClasses+testClasses+webInfJars
|
||||
private String _jettyEnvXml;
|
||||
private List<Overlay> _overlays;
|
||||
private Resource _quickStartWebXml;
|
||||
|
||||
|
||||
|
||||
|
@ -101,20 +123,16 @@ public class JettyWebAppContext extends WebAppContext
|
|||
|
||||
|
||||
|
||||
private boolean _isGenerateQuickStart;
|
||||
private PreconfigureDescriptorProcessor _preconfigProcessor;
|
||||
private File _quickStartDir;
|
||||
|
||||
|
||||
|
||||
public JettyWebAppContext ()
|
||||
throws Exception
|
||||
{
|
||||
super();
|
||||
setConfigurations(new Configuration[]{
|
||||
new MavenWebInfConfiguration(),
|
||||
new WebXmlConfiguration(),
|
||||
new MetaInfConfiguration(),
|
||||
new FragmentConfiguration(),
|
||||
_envConfig = new EnvConfiguration(),
|
||||
new PlusConfiguration(),
|
||||
new AnnotationConfiguration(),
|
||||
new JettyWebXmlConfiguration()
|
||||
});
|
||||
// Turn off copyWebInf option as it is not applicable for plugin.
|
||||
super.setCopyWebInf(false);
|
||||
}
|
||||
|
@ -210,6 +228,18 @@ public class JettyWebAppContext extends WebAppContext
|
|||
return _baseAppFirst;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void setQuickStartWebDescriptor (Resource quickStartWebXml)
|
||||
{
|
||||
_quickStartWebXml = quickStartWebXml;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public Resource getQuickStartWebDescriptor ()
|
||||
{
|
||||
return _quickStartWebXml;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* This method is provided as a convenience for jetty maven plugin configuration
|
||||
|
@ -234,8 +264,67 @@ public class JettyWebAppContext extends WebAppContext
|
|||
return _webInfJars;
|
||||
}
|
||||
|
||||
public void setGenerateQuickStart (boolean quickStart)
|
||||
{
|
||||
_isGenerateQuickStart = quickStart;
|
||||
}
|
||||
|
||||
public boolean isGenerateQuickStart()
|
||||
{
|
||||
return _isGenerateQuickStart;
|
||||
}
|
||||
|
||||
public void setQuickStartDir (File dir)
|
||||
{
|
||||
_quickStartDir = dir;
|
||||
}
|
||||
|
||||
public File getQuickStartDir()
|
||||
{
|
||||
return _quickStartDir;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void startWebapp() throws Exception
|
||||
{
|
||||
if (isGenerateQuickStart())
|
||||
{
|
||||
QuickStartDescriptorGenerator generator = new QuickStartDescriptorGenerator(this, (getQuickStartDir()==null?getTempDirectory():getQuickStartDir()), _preconfigProcessor.getXML());
|
||||
File f = generator.generateQuickStartWebXml();
|
||||
setQuickStartWebDescriptor(Resource.newResource(f));
|
||||
}
|
||||
else
|
||||
super.startWebapp();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void doStart () throws Exception
|
||||
{
|
||||
//choose if this will be a quickstart or normal start
|
||||
if (getQuickStartWebDescriptor() == null)
|
||||
{
|
||||
setConfigurations(_defaultConfigurations);
|
||||
if (isGenerateQuickStart())
|
||||
{
|
||||
_preconfigProcessor = new PreconfigureDescriptorProcessor();
|
||||
getMetaData().addDescriptorProcessor(_preconfigProcessor);
|
||||
}
|
||||
}
|
||||
else
|
||||
setConfigurations(_quickStartConfigurations);
|
||||
|
||||
|
||||
//inject configurations with config from maven plugin
|
||||
for (Configuration c:getConfigurations())
|
||||
{
|
||||
if (c instanceof EnvConfiguration && getJettyEnvXml() != null)
|
||||
((EnvConfiguration)c).setJettyEnvXml(Resource.toURL(new File(getJettyEnvXml())));
|
||||
else if (c instanceof MavenQuickStartConfiguration && getQuickStartWebDescriptor() != null)
|
||||
((MavenQuickStartConfiguration)c).setQuickStartWebXml(getQuickStartWebDescriptor());
|
||||
}
|
||||
|
||||
//Set up the pattern that tells us where the jars are that need scanning
|
||||
|
||||
//Allow user to set up pattern for names of jars from the container classpath
|
||||
|
@ -274,9 +363,6 @@ public class JettyWebAppContext extends WebAppContext
|
|||
_webInfJarMap.put(fileName, file);
|
||||
}
|
||||
|
||||
if (this._jettyEnvXml != null)
|
||||
_envConfig.setJettyEnvXml(Resource.toURL(new File(this._jettyEnvXml)));
|
||||
|
||||
// CHECK setShutdown(false);
|
||||
super.doStart();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// 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.maven.plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.eclipse.jetty.quickstart.QuickStartConfiguration;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.webapp.WebAppClassLoader;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
|
||||
/**
|
||||
* MavenQuickStartConfiguration
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class MavenQuickStartConfiguration extends QuickStartConfiguration
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(QuickStartConfiguration.class);
|
||||
|
||||
private Resource _quickStartWebXml;
|
||||
|
||||
|
||||
public void setQuickStartWebXml (Resource r)
|
||||
{
|
||||
_quickStartWebXml = r;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Resource getQuickStartWebXml(WebAppContext context) throws Exception
|
||||
{
|
||||
return _quickStartWebXml;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void configure(WebAppContext context) throws Exception
|
||||
{
|
||||
|
||||
JettyWebAppContext jwac = (JettyWebAppContext)context;
|
||||
|
||||
//put the classes dir and all dependencies into the classpath
|
||||
if (jwac.getClassPathFiles() != null)
|
||||
{
|
||||
if (LOG.isDebugEnabled()) LOG.debug("Setting up classpath ...");
|
||||
Iterator itor = jwac.getClassPathFiles().iterator();
|
||||
while (itor.hasNext())
|
||||
((WebAppClassLoader)context.getClassLoader()).addClassPath(((File)itor.next()).getCanonicalPath());
|
||||
}
|
||||
|
||||
//Set up the quickstart environment for the context
|
||||
super.configure(context);
|
||||
|
||||
// knock out environmental maven and plexus classes from webAppContext
|
||||
String[] existingServerClasses = context.getServerClasses();
|
||||
String[] newServerClasses = new String[2+(existingServerClasses==null?0:existingServerClasses.length)];
|
||||
newServerClasses[0] = "org.apache.maven.";
|
||||
newServerClasses[1] = "org.codehaus.plexus.";
|
||||
System.arraycopy( existingServerClasses, 0, newServerClasses, 2, existingServerClasses.length );
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("Server classes:");
|
||||
for (int i=0;i<newServerClasses.length;i++)
|
||||
LOG.debug(newServerClasses[i]);
|
||||
}
|
||||
context.setServerClasses( newServerClasses );
|
||||
}
|
||||
|
||||
}
|
|
@ -23,7 +23,6 @@ import java.io.FileInputStream;
|
|||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
@ -156,6 +155,14 @@ public class Starter
|
|||
//configure webapp from properties file describing unassembled webapp
|
||||
configureWebApp();
|
||||
|
||||
//make it a quickstart if the quickstart-web.xml file exists
|
||||
if (webApp.getTempDirectory() != null)
|
||||
{
|
||||
File qs = new File (webApp.getTempDirectory(), "quickstart-web.xml");
|
||||
if (qs.exists() && qs.isFile())
|
||||
webApp.setQuickStartWebDescriptor(Resource.newResource(qs));
|
||||
}
|
||||
|
||||
//set up the webapp from the context xml file provided
|
||||
//NOTE: just like jetty:run mojo this means that the context file can
|
||||
//potentially override settings made in the pom. Ideally, we'd like
|
||||
|
@ -203,6 +210,9 @@ public class Starter
|
|||
if (str != null)
|
||||
webApp.setDescriptor(str);
|
||||
|
||||
str = (String)props.get("quickstart.web.xml");
|
||||
if (str != null)
|
||||
webApp.setQuickStartWebDescriptor(Resource.newResource(new File(str)));
|
||||
|
||||
// - the tmp directory
|
||||
str = (String)props.getProperty("tmp.dir");
|
||||
|
@ -217,8 +227,9 @@ public class Starter
|
|||
str = (String)props.getProperty("base.dirs");
|
||||
if (str != null && !"".equals(str.trim()))
|
||||
{
|
||||
webApp.setWar(str);
|
||||
webApp.setBaseResource(new ResourceCollection(str.split(File.pathSeparator)));
|
||||
ResourceCollection bases = new ResourceCollection(str.split(","));
|
||||
webApp.setWar(bases.getResources()[0].toString());
|
||||
webApp.setBaseResource(bases);
|
||||
}
|
||||
|
||||
// - put virtual webapp base resource first on resource path or not
|
||||
|
|
|
@ -23,8 +23,6 @@ import java.net.UnknownHostException;
|
|||
import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.eclipse.jetty.plus.annotation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
|
|
@ -40,7 +40,6 @@ import org.eclipse.jetty.plus.jndi.NamingEntryUtil;
|
|||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.webapp.AbstractConfiguration;
|
||||
import org.eclipse.jetty.webapp.Configuration;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
import org.eclipse.jetty.xml.XmlConfiguration;
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@ import java.util.concurrent.TimeUnit;
|
|||
import java.util.concurrent.TimeoutException;
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.UnavailableException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
|
|
|
@ -72,7 +72,23 @@ public class QuickStartConfiguration extends WebInfConfiguration
|
|||
LOG.debug("webapp={}",webApp);
|
||||
|
||||
|
||||
//look for effective-web.xml in WEB-INF of webapp
|
||||
//look for quickstart-web.xml in WEB-INF of webapp
|
||||
Resource quickStartWebXml = getQuickStartWebXml(context);
|
||||
LOG.debug("quickStartWebXml={}",quickStartWebXml);
|
||||
|
||||
context.getMetaData().setWebXml(quickStartWebXml);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the quickstart-web.xml file as a Resource.
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public Resource getQuickStartWebXml (WebAppContext context) throws Exception
|
||||
{
|
||||
Resource webInf = context.getWebInf();
|
||||
if (webInf == null || !webInf.exists())
|
||||
throw new IllegalStateException("No WEB-INF");
|
||||
|
@ -81,12 +97,11 @@ public class QuickStartConfiguration extends WebInfConfiguration
|
|||
Resource quickStartWebXml = webInf.addPath("quickstart-web.xml");
|
||||
if (!quickStartWebXml.exists())
|
||||
throw new IllegalStateException ("No WEB-INF/quickstart-web.xml");
|
||||
LOG.debug("quickStartWebXml={}",quickStartWebXml);
|
||||
|
||||
context.getMetaData().setWebXml(quickStartWebXml);
|
||||
return quickStartWebXml;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @see org.eclipse.jetty.webapp.AbstractConfiguration#configure(org.eclipse.jetty.webapp.WebAppContext)
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,669 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// 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 java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.EventListener;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.DispatcherType;
|
||||
import javax.servlet.MultipartConfigElement;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.SessionCookieConfig;
|
||||
import javax.servlet.SessionTrackingMode;
|
||||
import javax.servlet.descriptor.JspPropertyGroupDescriptor;
|
||||
import javax.servlet.descriptor.TaglibDescriptor;
|
||||
|
||||
import org.eclipse.jetty.annotations.AnnotationConfiguration;
|
||||
import org.eclipse.jetty.http.MimeTypes;
|
||||
import org.eclipse.jetty.plus.annotation.LifeCycleCallback;
|
||||
import org.eclipse.jetty.plus.annotation.LifeCycleCallbackCollection;
|
||||
import org.eclipse.jetty.security.ConstraintAware;
|
||||
import org.eclipse.jetty.security.ConstraintMapping;
|
||||
import org.eclipse.jetty.security.SecurityHandler;
|
||||
import org.eclipse.jetty.security.authentication.FormAuthenticator;
|
||||
import org.eclipse.jetty.servlet.ErrorPageErrorHandler;
|
||||
import org.eclipse.jetty.servlet.FilterHolder;
|
||||
import org.eclipse.jetty.servlet.FilterMapping;
|
||||
import org.eclipse.jetty.servlet.Holder;
|
||||
import org.eclipse.jetty.servlet.ServletHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.eclipse.jetty.servlet.ServletMapping;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler.JspConfig;
|
||||
import org.eclipse.jetty.util.QuotedStringTokenizer;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.security.Constraint;
|
||||
import org.eclipse.jetty.webapp.MetaData;
|
||||
import org.eclipse.jetty.webapp.MetaData.OriginInfo;
|
||||
import org.eclipse.jetty.webapp.MetaInfConfiguration;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
import org.eclipse.jetty.xml.XmlAppendable;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* QuickStartDescriptorGenerator
|
||||
*
|
||||
* Generate an effective web.xml from a WebAppContext, including all components
|
||||
* from web.xml, web-fragment.xmls annotations etc.
|
||||
*/
|
||||
public class QuickStartDescriptorGenerator
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(QuickStartDescriptorGenerator.class);
|
||||
protected WebAppContext _webApp;
|
||||
protected File _descriptorDir;
|
||||
protected String _extraXML;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param w the source WebAppContext
|
||||
* @param descriptorDir the directory where quickstart-web.xml should be saved
|
||||
* @param extraXML any extra xml snippet to append
|
||||
*/
|
||||
public QuickStartDescriptorGenerator (WebAppContext w, File descriptorDir, String extraXML)
|
||||
{
|
||||
_webApp = w;
|
||||
_descriptorDir = descriptorDir;
|
||||
_extraXML = extraXML;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Perform the generation of the xml file
|
||||
* @throws IOException
|
||||
* @throws FileNotFoundException
|
||||
* @throws Exception
|
||||
*/
|
||||
public File generateQuickStartWebXml () throws FileNotFoundException, IOException
|
||||
{
|
||||
if (_webApp == null)
|
||||
throw new IllegalStateException("No webapp for quickstart-web.xml");
|
||||
if (_descriptorDir == null)
|
||||
throw new IllegalStateException("No location for quickstart-web.xml");
|
||||
|
||||
_webApp.getMetaData().getOrigins();
|
||||
|
||||
if (_webApp.getBaseResource()==null)
|
||||
throw new IllegalArgumentException("No base resource for "+this);
|
||||
|
||||
if (!_descriptorDir.exists())
|
||||
_descriptorDir.mkdirs();
|
||||
|
||||
File webXml = new File(_descriptorDir,"quickstart-web.xml");
|
||||
|
||||
LOG.info("Quickstart generate {}",webXml);
|
||||
|
||||
try (FileOutputStream fos = new FileOutputStream(webXml))
|
||||
{
|
||||
XmlAppendable out = new XmlAppendable(fos,"UTF-8");
|
||||
|
||||
MetaData md = _webApp.getMetaData();
|
||||
|
||||
Map<String, String> webappAttr = new HashMap<>();
|
||||
webappAttr.put("xmlns","http://xmlns.jcp.org/xml/ns/javaee");
|
||||
webappAttr.put("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance");
|
||||
webappAttr.put("xsi:schemaLocation","http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd");
|
||||
webappAttr.put("metadata-complete","true");
|
||||
webappAttr.put("version","3.1");
|
||||
|
||||
out.openTag("web-app",webappAttr);
|
||||
if (_webApp.getDisplayName() != null)
|
||||
out.tag("display-name",_webApp.getDisplayName());
|
||||
|
||||
// Set some special context parameters
|
||||
|
||||
// The location of the war file on disk
|
||||
String resourceBase = _webApp.getBaseResource().getFile().getCanonicalFile().getAbsoluteFile().toURI().toString();
|
||||
|
||||
// The library order
|
||||
addContextParamFromAttribute(out,ServletContext.ORDERED_LIBS);
|
||||
//the servlet container initializers
|
||||
addContextParamFromAttribute(out,AnnotationConfiguration.CONTAINER_INITIALIZERS);
|
||||
//the tlds discovered
|
||||
addContextParamFromAttribute(out,MetaInfConfiguration.METAINF_TLDS,resourceBase);
|
||||
//the META-INF/resources discovered
|
||||
addContextParamFromAttribute(out,MetaInfConfiguration.METAINF_RESOURCES,resourceBase);
|
||||
|
||||
|
||||
// init params
|
||||
for (String p : _webApp.getInitParams().keySet())
|
||||
out.openTag("context-param",origin(md,"context-param." + p))
|
||||
.tag("param-name",p)
|
||||
.tag("param-value",_webApp.getInitParameter(p))
|
||||
.closeTag();
|
||||
|
||||
if (_webApp.getEventListeners() != null)
|
||||
for (EventListener e : _webApp.getEventListeners())
|
||||
out.openTag("listener",origin(md,e.getClass().getCanonicalName() + ".listener"))
|
||||
.tag("listener-class",e.getClass().getCanonicalName())
|
||||
.closeTag();
|
||||
|
||||
ServletHandler servlets = _webApp.getServletHandler();
|
||||
|
||||
if (servlets.getFilters() != null)
|
||||
{
|
||||
for (FilterHolder holder : servlets.getFilters())
|
||||
outholder(out,md,"filter",holder);
|
||||
}
|
||||
|
||||
if (servlets.getFilterMappings() != null)
|
||||
{
|
||||
for (FilterMapping mapping : servlets.getFilterMappings())
|
||||
{
|
||||
out.openTag("filter-mapping");
|
||||
out.tag("filter-name",mapping.getFilterName());
|
||||
if (mapping.getPathSpecs() != null)
|
||||
for (String s : mapping.getPathSpecs())
|
||||
out.tag("url-pattern",s);
|
||||
if (mapping.getServletNames() != null)
|
||||
for (String n : mapping.getServletNames())
|
||||
out.tag("servlet-name",n);
|
||||
|
||||
if (!mapping.isDefaultDispatches())
|
||||
{
|
||||
if (mapping.appliesTo(DispatcherType.REQUEST))
|
||||
out.tag("dispatcher","REQUEST");
|
||||
if (mapping.appliesTo(DispatcherType.ASYNC))
|
||||
out.tag("dispatcher","ASYNC");
|
||||
if (mapping.appliesTo(DispatcherType.ERROR))
|
||||
out.tag("dispatcher","ERROR");
|
||||
if (mapping.appliesTo(DispatcherType.FORWARD))
|
||||
out.tag("dispatcher","FORWARD");
|
||||
if (mapping.appliesTo(DispatcherType.INCLUDE))
|
||||
out.tag("dispatcher","INCLUDE");
|
||||
}
|
||||
out.closeTag();
|
||||
}
|
||||
}
|
||||
|
||||
if (servlets.getServlets() != null)
|
||||
{
|
||||
for (ServletHolder holder : servlets.getServlets())
|
||||
outholder(out,md,"servlet",holder);
|
||||
}
|
||||
|
||||
if (servlets.getServletMappings() != null)
|
||||
{
|
||||
for (ServletMapping mapping : servlets.getServletMappings())
|
||||
{
|
||||
out.openTag("servlet-mapping",origin(md,mapping.getServletName() + ".servlet.mappings"));
|
||||
out.tag("servlet-name",mapping.getServletName());
|
||||
if (mapping.getPathSpecs() != null)
|
||||
for (String s : mapping.getPathSpecs())
|
||||
out.tag("url-pattern",s);
|
||||
out.closeTag();
|
||||
}
|
||||
}
|
||||
|
||||
// Security elements
|
||||
SecurityHandler security =_webApp. getSecurityHandler();
|
||||
|
||||
if (security!=null && (security.getRealmName()!=null || security.getAuthMethod()!=null))
|
||||
{
|
||||
out.openTag("login-config");
|
||||
if (security.getAuthMethod()!=null)
|
||||
out.tag("auth-method",origin(md,"auth-method"),security.getAuthMethod());
|
||||
if (security.getRealmName()!=null)
|
||||
out.tag("realm-name",origin(md,"realm-name"),security.getRealmName());
|
||||
|
||||
|
||||
if (Constraint.__FORM_AUTH.equalsIgnoreCase(security.getAuthMethod()))
|
||||
{
|
||||
out.openTag("form-login-config");
|
||||
out.tag("form-login-page",origin(md,"form-login-page"),security.getInitParameter(FormAuthenticator.__FORM_LOGIN_PAGE));
|
||||
out.tag("form-error-page",origin(md,"form-error-page"),security.getInitParameter(FormAuthenticator.__FORM_ERROR_PAGE));
|
||||
out.closeTag();
|
||||
}
|
||||
|
||||
out.closeTag();
|
||||
}
|
||||
|
||||
if (security instanceof ConstraintAware)
|
||||
{
|
||||
ConstraintAware ca = (ConstraintAware)security;
|
||||
for (String r:ca.getRoles())
|
||||
out.openTag("security-role")
|
||||
.tag("role-name",r)
|
||||
.closeTag();
|
||||
|
||||
for (ConstraintMapping m : ca.getConstraintMappings())
|
||||
{
|
||||
out.openTag("security-constraint");
|
||||
|
||||
if (m.getConstraint().getAuthenticate())
|
||||
{
|
||||
out.openTag("auth-constraint");
|
||||
if (m.getConstraint().getRoles()!=null)
|
||||
for (String r : m.getConstraint().getRoles())
|
||||
out.tag("role-name",r);
|
||||
|
||||
out.closeTag();
|
||||
}
|
||||
|
||||
switch (m.getConstraint().getDataConstraint())
|
||||
{
|
||||
case Constraint.DC_NONE:
|
||||
out.openTag("user-data-constraint").tag("transport-guarantee","NONE").closeTag();
|
||||
break;
|
||||
|
||||
case Constraint.DC_INTEGRAL:
|
||||
out.openTag("user-data-constraint").tag("transport-guarantee","INTEGRAL").closeTag();
|
||||
break;
|
||||
|
||||
case Constraint.DC_CONFIDENTIAL:
|
||||
out.openTag("user-data-constraint").tag("transport-guarantee","CONFIDENTIAL").closeTag();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (_webApp.getWelcomeFiles() != null)
|
||||
{
|
||||
out.openTag("welcome-file-list");
|
||||
for (String welcomeFile:_webApp.getWelcomeFiles())
|
||||
{
|
||||
out.tag("welcome-file", welcomeFile);
|
||||
}
|
||||
out.closeTag();
|
||||
}
|
||||
|
||||
Map<String,String> localeEncodings = _webApp.getLocaleEncodings();
|
||||
if (localeEncodings != null && !localeEncodings.isEmpty())
|
||||
{
|
||||
out.openTag("locale-encoding-mapping-list");
|
||||
for (Map.Entry<String, String> entry:localeEncodings.entrySet())
|
||||
{
|
||||
out.openTag("locale-encoding-mapping", origin(md,"locale-encoding."+entry.getKey()));
|
||||
out.tag("locale", entry.getKey());
|
||||
out.tag("encoding", entry.getValue());
|
||||
out.closeTag();
|
||||
}
|
||||
out.closeTag();
|
||||
}
|
||||
|
||||
//session-config
|
||||
if (_webApp.getSessionHandler().getSessionManager() != null)
|
||||
{
|
||||
out.openTag("session-config");
|
||||
int maxInactiveSec = _webApp.getSessionHandler().getSessionManager().getMaxInactiveInterval();
|
||||
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
|
||||
SessionCookieConfig cookieConfig = _webApp.getSessionHandler().getSessionManager().getSessionCookieConfig();
|
||||
if (cookieConfig != null)
|
||||
{
|
||||
out.openTag("cookie-config");
|
||||
if (cookieConfig.getName() != null)
|
||||
out.tag("name", origin(md,"cookie-config.name"), cookieConfig.getName());
|
||||
|
||||
if (cookieConfig.getDomain() != null)
|
||||
out.tag("domain", origin(md, "cookie-config.domain"), cookieConfig.getDomain());
|
||||
|
||||
if (cookieConfig.getPath() != null)
|
||||
out.tag("path", origin(md, "cookie-config.path"), cookieConfig.getPath());
|
||||
|
||||
if (cookieConfig.getComment() != null)
|
||||
out.tag("comment", origin(md, "cookie-config.comment"), cookieConfig.getComment());
|
||||
|
||||
out.tag("http-only", origin(md, "cookie-config.http-only"), Boolean.toString(cookieConfig.isHttpOnly()));
|
||||
out.tag("secure", origin(md, "cookie-config.secure"), Boolean.toString(cookieConfig.isSecure()));
|
||||
out.tag("max-age", origin(md, "cookie-config.max-age"), Integer.toString(cookieConfig.getMaxAge()));
|
||||
out.closeTag();
|
||||
}
|
||||
out.closeTag();
|
||||
}
|
||||
|
||||
//error-pages
|
||||
Map<String,String> errorPages = ((ErrorPageErrorHandler)_webApp.getErrorHandler()).getErrorPages();
|
||||
if (errorPages != null)
|
||||
{
|
||||
for (Map.Entry<String, String> entry:errorPages.entrySet())
|
||||
{
|
||||
out.openTag("error-page", origin(md, "error."+entry.getKey()));
|
||||
//a global or default error page has no code or exception
|
||||
if (!ErrorPageErrorHandler.GLOBAL_ERROR_PAGE.equals(entry.getKey()))
|
||||
{
|
||||
if (entry.getKey().matches("\\d{3}"))
|
||||
out.tag("error-code", entry.getKey());
|
||||
else
|
||||
out.tag("exception-type", entry.getKey());
|
||||
}
|
||||
out.tag("location", entry.getValue());
|
||||
out.closeTag();
|
||||
}
|
||||
}
|
||||
|
||||
//mime-types
|
||||
MimeTypes mimeTypes = _webApp.getMimeTypes();
|
||||
if (mimeTypes != null)
|
||||
{
|
||||
for (Map.Entry<String, String> entry:mimeTypes.getMimeMap().entrySet())
|
||||
{
|
||||
out.openTag("mime-mapping");
|
||||
out.tag("extension", origin(md, "extension."+entry.getKey()), entry.getKey());
|
||||
out.tag("mime-type", entry.getValue());
|
||||
out.closeTag();
|
||||
}
|
||||
}
|
||||
|
||||
//jsp-config
|
||||
JspConfig jspConfig = (JspConfig)_webApp.getServletContext().getJspConfigDescriptor();
|
||||
if (jspConfig != null)
|
||||
{
|
||||
out.openTag("jsp-config");
|
||||
Collection<TaglibDescriptor> tlds = jspConfig.getTaglibs();
|
||||
if (tlds != null && !tlds.isEmpty())
|
||||
{
|
||||
for (TaglibDescriptor tld:tlds)
|
||||
{
|
||||
out.openTag("taglib");
|
||||
out.tag("taglib-uri", tld.getTaglibURI());
|
||||
out.tag("taglib-location", tld.getTaglibLocation());
|
||||
out.closeTag();
|
||||
}
|
||||
}
|
||||
|
||||
Collection<JspPropertyGroupDescriptor> jspPropertyGroups = jspConfig.getJspPropertyGroups();
|
||||
if (jspPropertyGroups != null && !jspPropertyGroups.isEmpty())
|
||||
{
|
||||
for (JspPropertyGroupDescriptor jspPropertyGroup:jspPropertyGroups)
|
||||
{
|
||||
out.openTag("jsp-property-group");
|
||||
Collection<String> strings = jspPropertyGroup.getUrlPatterns();
|
||||
if (strings != null && !strings.isEmpty())
|
||||
{
|
||||
for (String urlPattern:strings)
|
||||
out.tag("url-pattern", urlPattern);
|
||||
}
|
||||
|
||||
if (jspPropertyGroup.getElIgnored() != null)
|
||||
out.tag("el-ignored", jspPropertyGroup.getElIgnored());
|
||||
|
||||
if (jspPropertyGroup.getPageEncoding() != null)
|
||||
out.tag("page-encoding", jspPropertyGroup.getPageEncoding());
|
||||
|
||||
if (jspPropertyGroup.getScriptingInvalid() != null)
|
||||
out.tag("scripting-invalid", jspPropertyGroup.getScriptingInvalid());
|
||||
|
||||
if (jspPropertyGroup.getIsXml() != null)
|
||||
out.tag("is-xml", jspPropertyGroup.getIsXml());
|
||||
|
||||
if (jspPropertyGroup.getDeferredSyntaxAllowedAsLiteral() != null)
|
||||
out.tag("deferred-syntax-allowed-as-literal", jspPropertyGroup.getDeferredSyntaxAllowedAsLiteral());
|
||||
|
||||
if (jspPropertyGroup.getTrimDirectiveWhitespaces() != null)
|
||||
out.tag("trim-directive-whitespaces", jspPropertyGroup.getTrimDirectiveWhitespaces());
|
||||
|
||||
if (jspPropertyGroup.getDefaultContentType() != null)
|
||||
out.tag("default-content-type", jspPropertyGroup.getDefaultContentType());
|
||||
|
||||
if (jspPropertyGroup.getBuffer() != null)
|
||||
out.tag("buffer", jspPropertyGroup.getBuffer());
|
||||
|
||||
if (jspPropertyGroup.getErrorOnUndeclaredNamespace() != null)
|
||||
out.tag("error-on-undeclared-namespace", jspPropertyGroup.getErrorOnUndeclaredNamespace());
|
||||
|
||||
strings = jspPropertyGroup.getIncludePreludes();
|
||||
if (strings != null && !strings.isEmpty())
|
||||
{
|
||||
for (String prelude:strings)
|
||||
out.tag("include-prelude", prelude);
|
||||
}
|
||||
|
||||
strings = jspPropertyGroup.getIncludeCodas();
|
||||
if (strings != null && !strings.isEmpty())
|
||||
{
|
||||
for (String coda:strings)
|
||||
out.tag("include-coda", coda);
|
||||
}
|
||||
|
||||
out.closeTag();
|
||||
}
|
||||
}
|
||||
|
||||
out.closeTag();
|
||||
}
|
||||
|
||||
//lifecycle: post-construct, pre-destroy
|
||||
LifeCycleCallbackCollection lifecycles = ((LifeCycleCallbackCollection)_webApp.getAttribute(LifeCycleCallbackCollection.LIFECYCLE_CALLBACK_COLLECTION));
|
||||
if (lifecycles != null)
|
||||
{
|
||||
Collection<LifeCycleCallback> tmp = lifecycles.getPostConstructCallbacks();
|
||||
|
||||
for (LifeCycleCallback c:tmp)
|
||||
{
|
||||
out.openTag("post-construct");
|
||||
out.tag("lifecycle-callback-class", c.getTargetClassName());
|
||||
out.tag("lifecycle-callback-method", c.getMethodName());
|
||||
out.closeTag();
|
||||
}
|
||||
|
||||
tmp = lifecycles.getPreDestroyCallbacks();
|
||||
for (LifeCycleCallback c:tmp)
|
||||
{
|
||||
out.openTag("pre-destroy");
|
||||
out.tag("lifecycle-callback-class", c.getTargetClassName());
|
||||
out.tag("lifecycle-callback-method", c.getMethodName());
|
||||
out.closeTag();
|
||||
}
|
||||
}
|
||||
|
||||
out.literal(_extraXML);
|
||||
|
||||
out.closeTag();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (e.getSuppressed() != null)
|
||||
{
|
||||
for (Throwable t:e.getSuppressed())
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return webXml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn attribute into context-param to store.
|
||||
*
|
||||
* @param out
|
||||
* @param attribute
|
||||
* @throws IOException
|
||||
*/
|
||||
private void addContextParamFromAttribute(XmlAppendable out, String attribute) throws IOException
|
||||
{
|
||||
addContextParamFromAttribute(out,attribute,null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn context attribute into context-param to store.
|
||||
*
|
||||
* @param out
|
||||
* @param attribute
|
||||
* @param resourceBase
|
||||
* @throws IOException
|
||||
*/
|
||||
private void addContextParamFromAttribute(XmlAppendable out, String attribute, String resourceBase) throws IOException
|
||||
{
|
||||
Object o = _webApp.getAttribute(attribute);
|
||||
if (o == null)
|
||||
return;
|
||||
|
||||
Collection<?> c = (o instanceof Collection)? (Collection<?>)o:Collections.singletonList(o);
|
||||
StringBuilder v=new StringBuilder();
|
||||
for (Object i:c)
|
||||
{
|
||||
if (i!=null)
|
||||
{
|
||||
if (v.length()>0)
|
||||
v.append(",\n ");
|
||||
else
|
||||
v.append("\n ");
|
||||
if (resourceBase==null)
|
||||
QuotedStringTokenizer.quote(v,i.toString());
|
||||
else
|
||||
QuotedStringTokenizer.quote(v,i.toString().replace(resourceBase,"${WAR}/"));
|
||||
}
|
||||
}
|
||||
out.openTag("context-param")
|
||||
.tag("param-name",attribute)
|
||||
.tagCDATA("param-value",v.toString())
|
||||
.closeTag();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate xml for a Holder (Filter/Servlet)
|
||||
*
|
||||
* @param out
|
||||
* @param md
|
||||
* @param tag
|
||||
* @param holder
|
||||
* @throws IOException
|
||||
*/
|
||||
private void outholder(XmlAppendable out, MetaData md, String tag, Holder<?> holder) throws IOException
|
||||
{
|
||||
out.openTag(tag,Collections.singletonMap("source",holder.getSource().toString()));
|
||||
String n = holder.getName();
|
||||
out.tag(tag + "-name",n);
|
||||
|
||||
String ot = n + "." + tag + ".";
|
||||
|
||||
out.tag(tag + "-class",origin(md,ot + tag + "-class"),holder.getClassName());
|
||||
|
||||
for (String p : holder.getInitParameters().keySet())
|
||||
{
|
||||
if ("scratchdir".equalsIgnoreCase(p)) //don't preconfigure the temp dir for jsp output
|
||||
continue;
|
||||
out.openTag("init-param",origin(md,ot + "init-param." + p))
|
||||
.tag("param-name",p)
|
||||
.tag("param-value",holder.getInitParameter(p))
|
||||
.closeTag();
|
||||
}
|
||||
|
||||
if (holder instanceof ServletHolder)
|
||||
{
|
||||
ServletHolder s = (ServletHolder)holder;
|
||||
if (s.getForcedPath() != null)
|
||||
out.tag("jsp-file",s.getForcedPath());
|
||||
|
||||
if (s.getInitOrder() != 0)
|
||||
out.tag("load-on-startup",Integer.toString(s.getInitOrder()));
|
||||
|
||||
if (s.getRunAsRole() != null)
|
||||
out.openTag("run-as",origin(md,ot + "run-as"))
|
||||
.tag("role-name",s.getRunAsRole())
|
||||
.closeTag();
|
||||
|
||||
Map<String,String> roles = s.getRoleRefMap();
|
||||
if (roles!=null)
|
||||
{
|
||||
for (Map.Entry<String, String> e : roles.entrySet())
|
||||
{
|
||||
out.openTag("security-role-ref",origin(md,ot+"role-name."+e.getKey()))
|
||||
.tag("role-name",e.getKey())
|
||||
.tag("role-link",e.getValue())
|
||||
.closeTag();
|
||||
}
|
||||
}
|
||||
|
||||
if (!s.isEnabled())
|
||||
out.tag("enabled",origin(md,ot + "enabled"),"false");
|
||||
|
||||
//multipart-config
|
||||
MultipartConfigElement multipartConfig = ((ServletHolder.Registration)s.getRegistration()).getMultipartConfig();
|
||||
if (multipartConfig != null)
|
||||
{
|
||||
out.openTag("multipart-config", origin(md, s.getName()+".servlet.multipart-config"));
|
||||
if (multipartConfig.getLocation() != null)
|
||||
out.tag("location", multipartConfig.getLocation());
|
||||
out.tag("max-file-size", Long.toString(multipartConfig.getMaxFileSize()));
|
||||
out.tag("max-request-size", Long.toString(multipartConfig.getMaxRequestSize()));
|
||||
out.tag("file-size-threshold", Long.toString(multipartConfig.getFileSizeThreshold()));
|
||||
out.closeTag();
|
||||
}
|
||||
}
|
||||
|
||||
out.tag("async-supported",origin(md,ot + "async-supported"),holder.isAsyncSupported()?"true":"false");
|
||||
out.closeTag();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Find the origin (web.xml, fragment, annotation etc) of a web artifact from MetaData.
|
||||
*
|
||||
* @param md
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public Map<String, String> origin(MetaData md, String name)
|
||||
{
|
||||
if (!LOG.isDebugEnabled())
|
||||
return Collections.emptyMap();
|
||||
if (name == null)
|
||||
return Collections.emptyMap();
|
||||
OriginInfo origin = md.getOriginInfo(name);
|
||||
if (LOG.isDebugEnabled()) LOG.debug("origin of "+name+" is "+origin);
|
||||
if (origin == null)
|
||||
return Collections.emptyMap();
|
||||
return Collections.singletonMap("origin",origin.toString());
|
||||
}
|
||||
|
||||
}
|
|
@ -18,51 +18,11 @@
|
|||
|
||||
package org.eclipse.jetty.quickstart;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.EventListener;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.DispatcherType;
|
||||
import javax.servlet.MultipartConfigElement;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.SessionCookieConfig;
|
||||
import javax.servlet.SessionTrackingMode;
|
||||
import javax.servlet.descriptor.JspPropertyGroupDescriptor;
|
||||
import javax.servlet.descriptor.TaglibDescriptor;
|
||||
|
||||
import org.eclipse.jetty.annotations.AnnotationConfiguration;
|
||||
import org.eclipse.jetty.http.MimeTypes;
|
||||
import org.eclipse.jetty.plus.annotation.LifeCycleCallback;
|
||||
import org.eclipse.jetty.plus.annotation.LifeCycleCallbackCollection;
|
||||
import org.eclipse.jetty.security.ConstraintAware;
|
||||
import org.eclipse.jetty.security.ConstraintMapping;
|
||||
import org.eclipse.jetty.security.SecurityHandler;
|
||||
import org.eclipse.jetty.security.authentication.FormAuthenticator;
|
||||
import org.eclipse.jetty.servlet.ErrorPageErrorHandler;
|
||||
import org.eclipse.jetty.servlet.FilterHolder;
|
||||
import org.eclipse.jetty.servlet.FilterMapping;
|
||||
import org.eclipse.jetty.servlet.Holder;
|
||||
import org.eclipse.jetty.servlet.ServletHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.eclipse.jetty.servlet.ServletMapping;
|
||||
import org.eclipse.jetty.util.QuotedStringTokenizer;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.resource.JarResource;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.util.security.Constraint;
|
||||
import org.eclipse.jetty.webapp.MetaData;
|
||||
import org.eclipse.jetty.webapp.MetaData.OriginInfo;
|
||||
import org.eclipse.jetty.webapp.MetaInfConfiguration;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
import org.eclipse.jetty.xml.XmlAppendable;
|
||||
|
||||
/**
|
||||
* QuickStartWar
|
||||
|
@ -191,7 +151,6 @@ public class QuickStartWebApp extends WebAppContext
|
|||
LOG.info("Quickstart preconfigure: {}(war={},dir={})",this,war,dir);
|
||||
|
||||
_preconfigProcessor = new PreconfigureDescriptorProcessor();
|
||||
|
||||
getMetaData().addDescriptorProcessor(_preconfigProcessor);
|
||||
setPreconfigure(true);
|
||||
_startWebapp=true;
|
||||
|
@ -203,518 +162,11 @@ public class QuickStartWebApp extends WebAppContext
|
|||
}
|
||||
|
||||
|
||||
public void generateQuickstartWebXml(String extraXML) throws IOException
|
||||
public void generateQuickstartWebXml(String extraXML) throws Exception
|
||||
{
|
||||
getMetaData().getOrigins();
|
||||
// dumpStdErr();
|
||||
|
||||
if (getBaseResource()==null)
|
||||
throw new IllegalArgumentException("No base resource for "+this);
|
||||
|
||||
File webxml = new File(getWebInf().getFile(),"quickstart-web.xml");
|
||||
|
||||
LOG.info("Quickstart generate {}",webxml);
|
||||
|
||||
XmlAppendable out = new XmlAppendable(new FileOutputStream(webxml),"UTF-8");
|
||||
MetaData md = getMetaData();
|
||||
|
||||
Map<String, String> webappAttr = new HashMap<>();
|
||||
webappAttr.put("xmlns","http://xmlns.jcp.org/xml/ns/javaee");
|
||||
webappAttr.put("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance");
|
||||
webappAttr.put("xsi:schemaLocation","http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd");
|
||||
webappAttr.put("metadata-complete","true");
|
||||
webappAttr.put("version","3.1");
|
||||
|
||||
out.open("web-app",webappAttr);
|
||||
|
||||
if (getDisplayName() != null)
|
||||
out.tag("display-name",getDisplayName());
|
||||
|
||||
// Set some special context parameters
|
||||
|
||||
// The location of the war file on disk
|
||||
String resourceBase=getBaseResource().getFile().getCanonicalFile().getAbsoluteFile().toURI().toString();
|
||||
|
||||
// The library order
|
||||
addContextParamFromAttribute(out,ServletContext.ORDERED_LIBS);
|
||||
//the servlet container initializers
|
||||
addContextParamFromAttribute(out,AnnotationConfiguration.CONTAINER_INITIALIZERS);
|
||||
//the tlds discovered
|
||||
addContextParamFromAttribute(out,MetaInfConfiguration.METAINF_TLDS,resourceBase);
|
||||
//the META-INF/resources discovered
|
||||
addContextParamFromAttribute(out,MetaInfConfiguration.METAINF_RESOURCES,resourceBase);
|
||||
|
||||
|
||||
// init params
|
||||
for (String p : getInitParams().keySet())
|
||||
out.open("context-param",origin(md,"context-param." + p))
|
||||
.tag("param-name",p)
|
||||
.tag("param-value",getInitParameter(p))
|
||||
.close();
|
||||
|
||||
if (getEventListeners() != null)
|
||||
for (EventListener e : getEventListeners())
|
||||
out.open("listener",origin(md,e.getClass().getCanonicalName() + ".listener"))
|
||||
.tag("listener-class",e.getClass().getCanonicalName())
|
||||
.close();
|
||||
|
||||
ServletHandler servlets = getServletHandler();
|
||||
|
||||
if (servlets.getFilters() != null)
|
||||
{
|
||||
for (FilterHolder holder : servlets.getFilters())
|
||||
outholder(out,md,"filter",holder);
|
||||
}
|
||||
|
||||
if (servlets.getFilterMappings() != null)
|
||||
{
|
||||
for (FilterMapping mapping : servlets.getFilterMappings())
|
||||
{
|
||||
out.open("filter-mapping");
|
||||
out.tag("filter-name",mapping.getFilterName());
|
||||
if (mapping.getPathSpecs() != null)
|
||||
for (String s : mapping.getPathSpecs())
|
||||
out.tag("url-pattern",s);
|
||||
if (mapping.getServletNames() != null)
|
||||
for (String n : mapping.getServletNames())
|
||||
out.tag("servlet-name",n);
|
||||
|
||||
if (!mapping.isDefaultDispatches())
|
||||
{
|
||||
if (mapping.appliesTo(DispatcherType.REQUEST))
|
||||
out.tag("dispatcher","REQUEST");
|
||||
if (mapping.appliesTo(DispatcherType.ASYNC))
|
||||
out.tag("dispatcher","ASYNC");
|
||||
if (mapping.appliesTo(DispatcherType.ERROR))
|
||||
out.tag("dispatcher","ERROR");
|
||||
if (mapping.appliesTo(DispatcherType.FORWARD))
|
||||
out.tag("dispatcher","FORWARD");
|
||||
if (mapping.appliesTo(DispatcherType.INCLUDE))
|
||||
out.tag("dispatcher","INCLUDE");
|
||||
}
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
|
||||
if (servlets.getServlets() != null)
|
||||
{
|
||||
for (ServletHolder holder : servlets.getServlets())
|
||||
outholder(out,md,"servlet",holder);
|
||||
}
|
||||
|
||||
if (servlets.getServletMappings() != null)
|
||||
{
|
||||
for (ServletMapping mapping : servlets.getServletMappings())
|
||||
{
|
||||
out.open("servlet-mapping",origin(md,mapping.getServletName() + ".servlet.mappings"));
|
||||
out.tag("servlet-name",mapping.getServletName());
|
||||
if (mapping.getPathSpecs() != null)
|
||||
for (String s : mapping.getPathSpecs())
|
||||
out.tag("url-pattern",s);
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
|
||||
// Security elements
|
||||
SecurityHandler security = getSecurityHandler();
|
||||
|
||||
if (security!=null && (security.getRealmName()!=null || security.getAuthMethod()!=null))
|
||||
{
|
||||
out.open("login-config");
|
||||
if (security.getAuthMethod()!=null)
|
||||
out.tag("auth-method",origin(md,"auth-method"),security.getAuthMethod());
|
||||
if (security.getRealmName()!=null)
|
||||
out.tag("realm-name",origin(md,"realm-name"),security.getRealmName());
|
||||
|
||||
|
||||
if (Constraint.__FORM_AUTH.equalsIgnoreCase(security.getAuthMethod()))
|
||||
{
|
||||
out.open("form-login-config");
|
||||
out.tag("form-login-page",origin(md,"form-login-page"),security.getInitParameter(FormAuthenticator.__FORM_LOGIN_PAGE));
|
||||
out.tag("form-error-page",origin(md,"form-error-page"),security.getInitParameter(FormAuthenticator.__FORM_ERROR_PAGE));
|
||||
out.close();
|
||||
}
|
||||
|
||||
out.close();
|
||||
}
|
||||
|
||||
if (security instanceof ConstraintAware)
|
||||
{
|
||||
ConstraintAware ca = (ConstraintAware)security;
|
||||
for (String r:ca.getRoles())
|
||||
out.open("security-role")
|
||||
.tag("role-name",r)
|
||||
.close();
|
||||
|
||||
for (ConstraintMapping m : ca.getConstraintMappings())
|
||||
{
|
||||
out.open("security-constraint");
|
||||
|
||||
if (m.getConstraint().getAuthenticate())
|
||||
{
|
||||
out.open("auth-constraint");
|
||||
if (m.getConstraint().getRoles()!=null)
|
||||
for (String r : m.getConstraint().getRoles())
|
||||
out.tag("role-name",r);
|
||||
|
||||
out.close();
|
||||
}
|
||||
|
||||
switch (m.getConstraint().getDataConstraint())
|
||||
{
|
||||
case Constraint.DC_NONE:
|
||||
out.open("user-data-constraint").tag("transport-guarantee","NONE").close();
|
||||
break;
|
||||
|
||||
case Constraint.DC_INTEGRAL:
|
||||
out.open("user-data-constraint").tag("transport-guarantee","INTEGRAL").close();
|
||||
break;
|
||||
|
||||
case Constraint.DC_CONFIDENTIAL:
|
||||
out.open("user-data-constraint").tag("transport-guarantee","CONFIDENTIAL").close();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
out.open("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.close();
|
||||
}
|
||||
|
||||
out.close();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (getWelcomeFiles() != null)
|
||||
{
|
||||
out.open("welcome-file-list");
|
||||
for (String welcomeFile:getWelcomeFiles())
|
||||
{
|
||||
out.tag("welcome-file", welcomeFile);
|
||||
}
|
||||
out.close();
|
||||
}
|
||||
|
||||
Map<String,String> localeEncodings = getLocaleEncodings();
|
||||
if (localeEncodings != null && !localeEncodings.isEmpty())
|
||||
{
|
||||
out.open("locale-encoding-mapping-list");
|
||||
for (Map.Entry<String, String> entry:localeEncodings.entrySet())
|
||||
{
|
||||
out.open("locale-encoding-mapping", origin(md,"locale-encoding."+entry.getKey()));
|
||||
out.tag("locale", entry.getKey());
|
||||
out.tag("encoding", entry.getValue());
|
||||
out.close();
|
||||
}
|
||||
out.close();
|
||||
}
|
||||
|
||||
//session-config
|
||||
if (getSessionHandler().getSessionManager() != null)
|
||||
{
|
||||
out.open("session-config");
|
||||
int maxInactiveSec = getSessionHandler().getSessionManager().getMaxInactiveInterval();
|
||||
out.tag("session-timeout", (maxInactiveSec==0?"0":Integer.toString(maxInactiveSec/60)));
|
||||
|
||||
Set<SessionTrackingMode> modes = getSessionHandler().getSessionManager().getEffectiveSessionTrackingModes();
|
||||
if (modes != null)
|
||||
{
|
||||
for (SessionTrackingMode mode:modes)
|
||||
out.tag("tracking-mode", mode.toString());
|
||||
}
|
||||
|
||||
//cookie-config
|
||||
SessionCookieConfig cookieConfig = getSessionHandler().getSessionManager().getSessionCookieConfig();
|
||||
if (cookieConfig != null)
|
||||
{
|
||||
out.open("cookie-config");
|
||||
if (cookieConfig.getName() != null)
|
||||
out.tag("name", origin(md,"cookie-config.name"), cookieConfig.getName());
|
||||
|
||||
if (cookieConfig.getDomain() != null)
|
||||
out.tag("domain", origin(md, "cookie-config.domain"), cookieConfig.getDomain());
|
||||
|
||||
if (cookieConfig.getPath() != null)
|
||||
out.tag("path", origin(md, "cookie-config.path"), cookieConfig.getPath());
|
||||
|
||||
if (cookieConfig.getComment() != null)
|
||||
out.tag("comment", origin(md, "cookie-config.comment"), cookieConfig.getComment());
|
||||
|
||||
out.tag("http-only", origin(md, "cookie-config.http-only"), Boolean.toString(cookieConfig.isHttpOnly()));
|
||||
out.tag("secure", origin(md, "cookie-config.secure"), Boolean.toString(cookieConfig.isSecure()));
|
||||
out.tag("max-age", origin(md, "cookie-config.max-age"), Integer.toString(cookieConfig.getMaxAge()));
|
||||
out.close();
|
||||
}
|
||||
out.close();
|
||||
}
|
||||
|
||||
//error-pages
|
||||
Map<String,String> errorPages = ((ErrorPageErrorHandler)getErrorHandler()).getErrorPages();
|
||||
if (errorPages != null)
|
||||
{
|
||||
for (Map.Entry<String, String> entry:errorPages.entrySet())
|
||||
{
|
||||
out.open("error-page", origin(md, "error."+entry.getKey()));
|
||||
//a global or default error page has no code or exception
|
||||
if (!ErrorPageErrorHandler.GLOBAL_ERROR_PAGE.equals(entry.getKey()))
|
||||
{
|
||||
if (entry.getKey().matches("\\d{3}"))
|
||||
out.tag("error-code", entry.getKey());
|
||||
else
|
||||
out.tag("exception-type", entry.getKey());
|
||||
}
|
||||
out.tag("location", entry.getValue());
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
|
||||
//mime-types
|
||||
MimeTypes mimeTypes = getMimeTypes();
|
||||
if (mimeTypes != null)
|
||||
{
|
||||
for (Map.Entry<String, String> entry:mimeTypes.getMimeMap().entrySet())
|
||||
{
|
||||
out.open("mime-mapping");
|
||||
out.tag("extension", origin(md, "extension."+entry.getKey()), entry.getKey());
|
||||
out.tag("mime-type", entry.getValue());
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
|
||||
//jsp-config
|
||||
JspConfig jspConfig = (JspConfig)getServletContext().getJspConfigDescriptor();
|
||||
if (jspConfig != null)
|
||||
{
|
||||
out.open("jsp-config");
|
||||
Collection<TaglibDescriptor> tlds = jspConfig.getTaglibs();
|
||||
if (tlds != null && !tlds.isEmpty())
|
||||
{
|
||||
for (TaglibDescriptor tld:tlds)
|
||||
{
|
||||
out.open("taglib");
|
||||
out.tag("taglib-uri", tld.getTaglibURI());
|
||||
out.tag("taglib-location", tld.getTaglibLocation());
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
|
||||
Collection<JspPropertyGroupDescriptor> jspPropertyGroups = jspConfig.getJspPropertyGroups();
|
||||
if (jspPropertyGroups != null && !jspPropertyGroups.isEmpty())
|
||||
{
|
||||
for (JspPropertyGroupDescriptor jspPropertyGroup:jspPropertyGroups)
|
||||
{
|
||||
out.open("jsp-property-group");
|
||||
Collection<String> strings = jspPropertyGroup.getUrlPatterns();
|
||||
if (strings != null && !strings.isEmpty())
|
||||
{
|
||||
for (String urlPattern:strings)
|
||||
out.tag("url-pattern", urlPattern);
|
||||
}
|
||||
|
||||
if (jspPropertyGroup.getElIgnored() != null)
|
||||
out.tag("el-ignored", jspPropertyGroup.getElIgnored());
|
||||
|
||||
if (jspPropertyGroup.getPageEncoding() != null)
|
||||
out.tag("page-encoding", jspPropertyGroup.getPageEncoding());
|
||||
|
||||
if (jspPropertyGroup.getScriptingInvalid() != null)
|
||||
out.tag("scripting-invalid", jspPropertyGroup.getScriptingInvalid());
|
||||
|
||||
if (jspPropertyGroup.getIsXml() != null)
|
||||
out.tag("is-xml", jspPropertyGroup.getIsXml());
|
||||
|
||||
if (jspPropertyGroup.getDeferredSyntaxAllowedAsLiteral() != null)
|
||||
out.tag("deferred-syntax-allowed-as-literal", jspPropertyGroup.getDeferredSyntaxAllowedAsLiteral());
|
||||
|
||||
if (jspPropertyGroup.getTrimDirectiveWhitespaces() != null)
|
||||
out.tag("trim-directive-whitespaces", jspPropertyGroup.getTrimDirectiveWhitespaces());
|
||||
|
||||
if (jspPropertyGroup.getDefaultContentType() != null)
|
||||
out.tag("default-content-type", jspPropertyGroup.getDefaultContentType());
|
||||
|
||||
if (jspPropertyGroup.getBuffer() != null)
|
||||
out.tag("buffer", jspPropertyGroup.getBuffer());
|
||||
|
||||
if (jspPropertyGroup.getErrorOnUndeclaredNamespace() != null)
|
||||
out.tag("error-on-undeclared-namespace", jspPropertyGroup.getErrorOnUndeclaredNamespace());
|
||||
|
||||
strings = jspPropertyGroup.getIncludePreludes();
|
||||
if (strings != null && !strings.isEmpty())
|
||||
{
|
||||
for (String prelude:strings)
|
||||
out.tag("include-prelude", prelude);
|
||||
}
|
||||
|
||||
strings = jspPropertyGroup.getIncludeCodas();
|
||||
if (strings != null && !strings.isEmpty())
|
||||
{
|
||||
for (String coda:strings)
|
||||
out.tag("include-coda", coda);
|
||||
}
|
||||
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
|
||||
out.close();
|
||||
}
|
||||
|
||||
//lifecycle: post-construct, pre-destroy
|
||||
LifeCycleCallbackCollection lifecycles = ((LifeCycleCallbackCollection)getAttribute(LifeCycleCallbackCollection.LIFECYCLE_CALLBACK_COLLECTION));
|
||||
if (lifecycles != null)
|
||||
{
|
||||
Collection<LifeCycleCallback> tmp = lifecycles.getPostConstructCallbacks();
|
||||
|
||||
for (LifeCycleCallback c:tmp)
|
||||
{
|
||||
out.open("post-construct");
|
||||
out.tag("lifecycle-callback-class", c.getTargetClassName());
|
||||
out.tag("lifecycle-callback-method", c.getMethodName());
|
||||
out.close();
|
||||
}
|
||||
|
||||
tmp = lifecycles.getPreDestroyCallbacks();
|
||||
for (LifeCycleCallback c:tmp)
|
||||
{
|
||||
out.open("pre-destroy");
|
||||
out.tag("lifecycle-callback-class", c.getTargetClassName());
|
||||
out.tag("lifecycle-callback-method", c.getMethodName());
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
|
||||
out.literal(extraXML);
|
||||
|
||||
out.close();
|
||||
QuickStartDescriptorGenerator generator = new QuickStartDescriptorGenerator(this, this.getWebInf().getFile(), extraXML);
|
||||
generator.generateQuickStartWebXml();
|
||||
}
|
||||
|
||||
private void addContextParamFromAttribute(XmlAppendable out, String attribute) throws IOException
|
||||
{
|
||||
addContextParamFromAttribute(out,attribute,null);
|
||||
}
|
||||
|
||||
private void addContextParamFromAttribute(XmlAppendable out, String attribute, String resourceBase) throws IOException
|
||||
{
|
||||
Object o=getAttribute(attribute);
|
||||
if (o==null)
|
||||
return;
|
||||
|
||||
Collection<?> c = (o instanceof Collection)? (Collection<?>)o:Collections.singletonList(o);
|
||||
StringBuilder v=new StringBuilder();
|
||||
for (Object i:c)
|
||||
{
|
||||
if (i!=null)
|
||||
{
|
||||
if (v.length()>0)
|
||||
v.append(",\n ");
|
||||
else
|
||||
v.append("\n ");
|
||||
if (resourceBase==null)
|
||||
QuotedStringTokenizer.quote(v,i.toString());
|
||||
else
|
||||
QuotedStringTokenizer.quote(v,i.toString().replace(resourceBase,"${WAR}/"));
|
||||
}
|
||||
}
|
||||
out.open("context-param")
|
||||
.tag("param-name",attribute)
|
||||
.tagCDATA("param-value",v.toString())
|
||||
.close();
|
||||
}
|
||||
|
||||
private static void outholder(XmlAppendable out, MetaData md, String tag, Holder<?> holder) throws IOException
|
||||
{
|
||||
out.open(tag,Collections.singletonMap("source",holder.getSource().toString()));
|
||||
String n = holder.getName();
|
||||
out.tag(tag + "-name",n);
|
||||
|
||||
String ot = n + "." + tag + ".";
|
||||
|
||||
out.tag(tag + "-class",origin(md,ot + tag + "-class"),holder.getClassName());
|
||||
|
||||
for (String p : holder.getInitParameters().keySet())
|
||||
{
|
||||
if ("scratchdir".equalsIgnoreCase(p)) //don't preconfigure the temp dir for jsp output
|
||||
continue;
|
||||
out.open("init-param",origin(md,ot + "init-param." + p))
|
||||
.tag("param-name",p)
|
||||
.tag("param-value",holder.getInitParameter(p))
|
||||
.close();
|
||||
}
|
||||
|
||||
if (holder instanceof ServletHolder)
|
||||
{
|
||||
ServletHolder s = (ServletHolder)holder;
|
||||
if (s.getForcedPath() != null)
|
||||
out.tag("jsp-file",s.getForcedPath());
|
||||
|
||||
if (s.getInitOrder() != 0)
|
||||
out.tag("load-on-startup",Integer.toString(s.getInitOrder()));
|
||||
|
||||
if (s.getRunAsRole() != null)
|
||||
out.open("run-as",origin(md,ot + "run-as"))
|
||||
.tag("role-name",s.getRunAsRole())
|
||||
.close();
|
||||
|
||||
Map<String,String> roles = s.getRoleRefMap();
|
||||
if (roles!=null)
|
||||
{
|
||||
for (Map.Entry<String, String> e : roles.entrySet())
|
||||
{
|
||||
out.open("security-role-ref",origin(md,ot+"role-name."+e.getKey()))
|
||||
.tag("role-name",e.getKey())
|
||||
.tag("role-link",e.getValue())
|
||||
.close();
|
||||
}
|
||||
}
|
||||
|
||||
if (!s.isEnabled())
|
||||
out.tag("enabled",origin(md,ot + "enabled"),"false");
|
||||
|
||||
//multipart-config
|
||||
MultipartConfigElement multipartConfig = ((ServletHolder.Registration)s.getRegistration()).getMultipartConfig();
|
||||
if (multipartConfig != null)
|
||||
{
|
||||
out.open("multipart-config", origin(md, s.getName()+".servlet.multipart-config"));
|
||||
if (multipartConfig.getLocation() != null)
|
||||
out.tag("location", multipartConfig.getLocation());
|
||||
out.tag("max-file-size", Long.toString(multipartConfig.getMaxFileSize()));
|
||||
out.tag("max-request-size", Long.toString(multipartConfig.getMaxRequestSize()));
|
||||
out.tag("file-size-threshold", Long.toString(multipartConfig.getFileSizeThreshold()));
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
|
||||
out.tag("async-supported",origin(md,ot + "async-supported"),holder.isAsyncSupported()?"true":"false");
|
||||
out.close();
|
||||
}
|
||||
|
||||
public static Map<String, String> origin(MetaData md, String name)
|
||||
{
|
||||
if (!LOG.isDebugEnabled())
|
||||
return Collections.emptyMap();
|
||||
if (name == null)
|
||||
return Collections.emptyMap();
|
||||
OriginInfo origin = md.getOriginInfo(name);
|
||||
// System.err.println("origin of "+name+" is "+origin);
|
||||
if (origin == null)
|
||||
return Collections.emptyMap();
|
||||
return Collections.singletonMap("origin",origin.toString());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ import org.eclipse.jetty.server.HttpChannel;
|
|||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.util.ArrayUtil;
|
||||
import org.eclipse.jetty.util.URIUtil;
|
||||
import org.eclipse.jetty.util.UrlEncoded;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.security.Principal;
|
|||
|
||||
import javax.security.auth.Subject;
|
||||
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.UserIdentity;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
|
@ -43,7 +43,6 @@ import org.eclipse.jetty.server.handler.ContextHandler;
|
|||
import org.eclipse.jetty.server.handler.ContextHandler.Context;
|
||||
import org.eclipse.jetty.server.handler.HandlerWrapper;
|
||||
import org.eclipse.jetty.server.session.AbstractSession;
|
||||
import org.eclipse.jetty.util.component.LifeCycle;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.security.SecurityHandler;
|
||||
import org.eclipse.jetty.security.ServerAuthException;
|
||||
import org.eclipse.jetty.security.UserAuthentication;
|
||||
import org.eclipse.jetty.server.Authentication;
|
||||
|
|
|
@ -31,7 +31,6 @@ import org.eclipse.jetty.http.HttpStatus;
|
|||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.AllowSymLinkAliasChecker;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.server.handler.ResourceHandler;
|
||||
import org.eclipse.jetty.server.session.SessionHandler;
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
package org.eclipse.jetty.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
@ -37,9 +35,7 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import org.eclipse.jetty.io.ArrayByteBufferPool;
|
||||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.io.Connection;
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.io.ssl.SslConnection;
|
||||
import org.eclipse.jetty.util.FutureCallback;
|
||||
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||
|
@ -47,7 +43,6 @@ import org.eclipse.jetty.util.component.ContainerLifeCycle;
|
|||
import org.eclipse.jetty.util.component.Dumpable;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
import org.eclipse.jetty.util.thread.ScheduledExecutorScheduler;
|
||||
import org.eclipse.jetty.util.thread.Scheduler;
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ import javax.servlet.http.Cookie;
|
|||
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.PathMap;
|
||||
import org.eclipse.jetty.server.handler.StatisticsHandler;
|
||||
import org.eclipse.jetty.util.DateCache;
|
||||
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||
import org.eclipse.jetty.util.component.AbstractLifeCycle;
|
||||
|
|
|
@ -24,7 +24,6 @@ import java.util.concurrent.Executor;
|
|||
|
||||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||
import org.eclipse.jetty.util.component.Graceful;
|
||||
|
|
|
@ -20,8 +20,6 @@ package org.eclipse.jetty.server;
|
|||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.HttpScheme;
|
||||
|
|
|
@ -24,8 +24,6 @@ import javax.servlet.ServletException;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.server.handler.HandlerCollection;
|
||||
import org.eclipse.jetty.server.handler.HandlerWrapper;
|
||||
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||
import org.eclipse.jetty.util.annotation.ManagedOperation;
|
||||
|
|
|
@ -20,8 +20,6 @@ package org.eclipse.jetty.server;
|
|||
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* Customizes requests that lack the {@code Host} header (for example, HTTP 1.0 requests).
|
||||
* <p />
|
||||
|
|
|
@ -24,10 +24,7 @@ import java.nio.ByteBuffer;
|
|||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.nio.channels.WritePendingException;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.WriteListener;
|
||||
|
||||
import org.eclipse.jetty.http.HttpContent;
|
||||
|
|
|
@ -33,7 +33,6 @@ import java.util.concurrent.atomic.AtomicReference;
|
|||
|
||||
import org.eclipse.jetty.http.DateGenerator;
|
||||
import org.eclipse.jetty.http.HttpContent;
|
||||
import org.eclipse.jetty.http.HttpContent.ResourceAsHttpContent;
|
||||
import org.eclipse.jetty.http.MimeTypes;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
|
|
|
@ -20,12 +20,10 @@ package org.eclipse.jetty.server;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketException;
|
||||
import java.nio.channels.Channel;
|
||||
import java.nio.channels.SelectionKey;
|
||||
import java.nio.channels.Selector;
|
||||
import java.nio.channels.ServerSocketChannel;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.util.concurrent.Executor;
|
||||
|
@ -37,7 +35,6 @@ import org.eclipse.jetty.io.EndPoint;
|
|||
import org.eclipse.jetty.io.SelectChannelEndPoint;
|
||||
import org.eclipse.jetty.io.SelectorManager;
|
||||
import org.eclipse.jetty.io.SelectorManager.ManagedSelector;
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||
import org.eclipse.jetty.util.annotation.Name;
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.util.Set;
|
|||
|
||||
import javax.servlet.SessionCookieConfig;
|
||||
import javax.servlet.SessionTrackingMode;
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
|
|
|
@ -67,7 +67,6 @@ import javax.servlet.http.HttpServletResponse;
|
|||
|
||||
import org.eclipse.jetty.http.MimeTypes;
|
||||
import org.eclipse.jetty.server.ClassLoaderDump;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Dispatcher;
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.server.HandlerContainer;
|
||||
|
|
|
@ -30,7 +30,6 @@ import org.eclipse.jetty.server.Request;
|
|||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||
import org.eclipse.jetty.util.component.LifeCycle;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** A <code>HandlerWrapper</code> acts as a {@link Handler} but delegates the {@link Handler#handle handle} method and
|
||||
|
|
|
@ -32,8 +32,6 @@ import java.util.Set;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.eclipse.jetty.server.SessionIdManager;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* HashSessionIdManager. An in-memory implementation of the session ID manager.
|
||||
|
|
|
@ -34,7 +34,6 @@ import java.util.concurrent.TimeUnit;
|
|||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.eclipse.jetty.server.SessionIdManager;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.util.ClassLoadingObjectInputStream;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
|
|
|
@ -37,10 +37,6 @@ import java.util.concurrent.TimeUnit;
|
|||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSessionEvent;
|
||||
import javax.servlet.http.HttpSessionListener;
|
||||
|
||||
import org.eclipse.jetty.server.SessionIdManager;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.server.session.JDBCSessionIdManager.SessionTableSchema;
|
||||
import org.eclipse.jetty.util.ClassLoadingObjectInputStream;
|
||||
|
|
|
@ -41,7 +41,6 @@ import org.eclipse.jetty.io.NetworkTrafficListener;
|
|||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.junit.After;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
public class NetworkTrafficListenerTest
|
||||
|
|
|
@ -27,9 +27,7 @@ import java.net.URL;
|
|||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
|
@ -1061,6 +1059,14 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
|
|||
/* ------------------------------------------------------------ */
|
||||
protected void writeHeaders(HttpServletResponse response,HttpContent content,long count)
|
||||
{
|
||||
if (content == null)
|
||||
{
|
||||
// No content, then no headers to process
|
||||
// This is possible during bypass write because of wrapping
|
||||
// See .sendData() for more details.
|
||||
return;
|
||||
}
|
||||
|
||||
if (content.getContentType()!=null && response.getContentType()==null)
|
||||
response.setContentType(content.getContentType().toString());
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ import java.util.EnumSet;
|
|||
import javax.servlet.DispatcherType;
|
||||
|
||||
import org.eclipse.jetty.http.PathMap;
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||
|
|
|
@ -35,8 +35,6 @@ import javax.servlet.Filter;
|
|||
import javax.servlet.FilterRegistration;
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.Servlet;
|
||||
import javax.servlet.ServletContainerInitializer;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
import javax.servlet.ServletException;
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
package org.eclipse.jetty.servlet;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
|
@ -46,7 +44,6 @@ import org.eclipse.jetty.server.Server;
|
|||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.toolchain.test.http.SimpleHttpParser;
|
||||
import org.eclipse.jetty.toolchain.test.http.SimpleHttpResponse;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
|
|
@ -40,7 +40,6 @@ import javax.servlet.http.HttpServletResponse;
|
|||
|
||||
import org.eclipse.jetty.security.ConstraintSecurityHandler;
|
||||
import org.eclipse.jetty.security.SecurityHandler;
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
|
@ -51,7 +50,6 @@ import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
|||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.eclipse.jetty.server.handler.ResourceHandler;
|
||||
import org.eclipse.jetty.server.session.SessionHandler;
|
||||
import org.eclipse.jetty.util.component.LifeCycle.Listener;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
|
|
|
@ -324,12 +324,16 @@ public class AsyncGzipFilter extends UserAgentFilter implements GzipFactory
|
|||
{
|
||||
String mimeType = _context.getMimeType(request.getRequestURI());
|
||||
|
||||
if (mimeType!=null && _mimeTypes.contains(mimeType))
|
||||
if (mimeType!=null)
|
||||
{
|
||||
LOG.debug("{} excluded by path suffix {}",this,request);
|
||||
// handle normally without setting vary header
|
||||
super.doFilter(request,response,chain);
|
||||
return;
|
||||
mimeType = MimeTypes.getContentTypeWithoutCharset(mimeType);
|
||||
if (_mimeTypes.contains(mimeType))
|
||||
{
|
||||
LOG.debug("{} excluded by path suffix {}",this,request);
|
||||
// handle normally without setting vary header
|
||||
super.doFilter(request,response,chain);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,6 @@ import javax.servlet.http.HttpSessionEvent;
|
|||
import org.eclipse.jetty.continuation.Continuation;
|
||||
import org.eclipse.jetty.continuation.ContinuationListener;
|
||||
import org.eclipse.jetty.continuation.ContinuationSupport;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||
import org.eclipse.jetty.util.annotation.ManagedOperation;
|
||||
|
|
|
@ -308,11 +308,15 @@ public class GzipFilter extends UserAgentFilter
|
|||
{
|
||||
String mimeType = _context.getMimeType(request.getRequestURI());
|
||||
|
||||
if (mimeType!=null && _mimeTypes.contains(mimeType))
|
||||
if (mimeType!=null)
|
||||
{
|
||||
// handle normally without setting vary header
|
||||
super.doFilter(request,response,chain);
|
||||
return;
|
||||
mimeType = MimeTypes.getContentTypeWithoutCharset(mimeType);
|
||||
if (_mimeTypes.contains(mimeType))
|
||||
{
|
||||
// handle normally without setting vary header
|
||||
super.doFilter(request,response,chain);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,6 @@ import javax.servlet.http.HttpSession;
|
|||
import org.eclipse.jetty.continuation.Continuation;
|
||||
import org.eclipse.jetty.continuation.ContinuationListener;
|
||||
import org.eclipse.jetty.continuation.ContinuationSupport;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ import java.util.List;
|
|||
|
||||
import javax.servlet.Filter;
|
||||
|
||||
import org.eclipse.jetty.servlet.DefaultServlet;
|
||||
import org.eclipse.jetty.servlet.FilterHolder;
|
||||
import org.eclipse.jetty.servlets.gzip.GzipTester;
|
||||
import org.eclipse.jetty.servlets.gzip.TestStaticMimeTypeServlet;
|
||||
|
|
|
@ -20,7 +20,6 @@ package org.eclipse.jetty.servlets;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
|
@ -389,6 +388,60 @@ public class GzipFilterDefaultTest
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testIsNotGzipCompressedByExcludedContentType() throws Exception
|
||||
{
|
||||
GzipTester tester = new GzipTester(testingdir, compressionType);
|
||||
tester.setGzipFilterClass(testFilter);
|
||||
|
||||
int filesize = tester.getOutputBufferSize() * 4;
|
||||
tester.prepareServerFile("test_quotes.txt", filesize);
|
||||
|
||||
|
||||
FilterHolder holder = tester.setContentServlet(org.eclipse.jetty.servlet.DefaultServlet.class);
|
||||
holder.setInitParameter("excludedMimeTypes","text/plain");
|
||||
|
||||
try
|
||||
{
|
||||
tester.start();
|
||||
HttpTester.Response http = tester.assertIsResponseNotGzipCompressed("GET","test_quotes.txt", filesize, HttpStatus.OK_200);
|
||||
Assert.assertNull(http.get("Vary"));
|
||||
}
|
||||
finally
|
||||
{
|
||||
tester.stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testIsNotGzipCompressedByExcludedContentTypeWithCharset() throws Exception
|
||||
{
|
||||
GzipTester tester = new GzipTester(testingdir, compressionType);
|
||||
tester.setGzipFilterClass(testFilter);
|
||||
|
||||
int filesize = tester.getOutputBufferSize() * 4;
|
||||
tester.prepareServerFile("test_quotes.txt", filesize);
|
||||
tester.addMimeType("txt","text/plain;charset=UTF-8");
|
||||
|
||||
FilterHolder holder = tester.setContentServlet(org.eclipse.jetty.servlet.DefaultServlet.class);
|
||||
holder.setInitParameter("excludedMimeTypes","text/plain");
|
||||
|
||||
try
|
||||
{
|
||||
tester.start();
|
||||
HttpTester.Response http = tester.assertIsResponseNotGzipCompressed("GET","test_quotes.txt", filesize, HttpStatus.OK_200);
|
||||
Assert.assertNull(http.get("Vary"));
|
||||
}
|
||||
finally
|
||||
{
|
||||
tester.stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testGzipCompressedByContentTypeWithEncoding() throws Exception
|
||||
{
|
||||
|
|
|
@ -395,7 +395,6 @@ public class GzipTester
|
|||
String uri = "/context/"+filename;
|
||||
HttpTester.Response response = executeRequest(method,uri);
|
||||
assertResponseHeaders(expectedFilesize,status,response);
|
||||
|
||||
// Assert that the contents are what we expect.
|
||||
if (filename != null)
|
||||
{
|
||||
|
@ -637,6 +636,11 @@ public class GzipTester
|
|||
this.userAgent = ua;
|
||||
}
|
||||
|
||||
public void addMimeType (String extension, String mimetype)
|
||||
{
|
||||
this.tester.getContext().getMimeTypes().addMimeMapping(extension, mimetype);
|
||||
}
|
||||
|
||||
public void start() throws Exception
|
||||
{
|
||||
Assert.assertThat("No servlet defined yet. Did you use #setContentServlet()?",tester,notNullValue());
|
||||
|
|
|
@ -27,7 +27,6 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.server.HttpOutput;
|
||||
import org.eclipse.jetty.servlets.GzipFilter;
|
||||
|
||||
/**
|
||||
* A sample servlet to serve static content, using a order of construction that has caused problems for
|
||||
|
|
|
@ -25,8 +25,6 @@ import javax.servlet.ServletOutputStream;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.servlets.GzipFilter;
|
||||
|
||||
/**
|
||||
* A sample servlet to serve static content, using a order of construction that has caused problems for
|
||||
* {@link GzipFilter} in the past.
|
||||
|
|
|
@ -25,8 +25,6 @@ import javax.servlet.ServletOutputStream;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.servlets.GzipFilter;
|
||||
|
||||
/**
|
||||
* A sample servlet to serve static content, using a order of construction that has caused problems for
|
||||
* {@link GzipFilter} in the past.
|
||||
|
|
|
@ -25,8 +25,6 @@ import javax.servlet.ServletOutputStream;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.servlets.GzipFilter;
|
||||
|
||||
/**
|
||||
* A sample servlet to serve static content, using a order of construction that has caused problems for
|
||||
* {@link GzipFilter} in the past.
|
||||
|
|
|
@ -25,8 +25,6 @@ import javax.servlet.ServletOutputStream;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.servlets.GzipFilter;
|
||||
|
||||
/**
|
||||
* A sample servlet to serve static content, using a order of construction that has caused problems for
|
||||
* {@link GzipFilter} in the past.
|
||||
|
|
|
@ -25,8 +25,6 @@ import javax.servlet.ServletOutputStream;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.servlets.GzipFilter;
|
||||
|
||||
/**
|
||||
* A sample servlet to serve static content, using a order of construction that has caused problems for
|
||||
* {@link GzipFilter} in the past.
|
||||
|
|
|
@ -25,8 +25,6 @@ import javax.servlet.ServletOutputStream;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.servlets.GzipFilter;
|
||||
|
||||
/**
|
||||
* A sample servlet to serve static content, using a order of construction that has caused problems for
|
||||
* {@link GzipFilter} in the past.
|
||||
|
|
|
@ -25,8 +25,6 @@ import javax.servlet.ServletOutputStream;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.servlets.GzipFilter;
|
||||
|
||||
/**
|
||||
* A sample servlet to serve static content, using a order of construction that has caused problems for
|
||||
* {@link GzipFilter} in the past.
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.io.ByteArrayOutputStream;
|
|||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.charset.UnsupportedCharsetException;
|
||||
|
||||
|
||||
/** Fast B64 Encoder/Decoder as described in RFC 1421.
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.nio.Buffer;
|
||||
import java.nio.BufferOverflowException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
|
@ -930,7 +929,7 @@ public class BufferUtil
|
|||
buf.append(buffer.getClass().getSimpleName());
|
||||
buf.append("@");
|
||||
if (buffer.hasArray())
|
||||
buf.append(Integer.toHexString(((Object)buffer.array()).hashCode()));
|
||||
buf.append(Integer.toHexString(Arrays.hashCode(buffer.array())));
|
||||
else
|
||||
buf.append(Integer.toHexString(buf.hashCode()));
|
||||
buf.append("[p=");
|
||||
|
|
|
@ -25,8 +25,6 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Objects;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.atomic.AtomicIntegerArray;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||
|
|
|
@ -151,7 +151,7 @@ public class FutureCallback implements Future<Void>,Callback
|
|||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return String.format("FutureCallback@%x{%b,%b}",hashCode(),_done,_cause==COMPLETED);
|
||||
return String.format("FutureCallback@%x{%b,%b}",hashCode(),_done.get(),_cause==COMPLETED);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ public class FuturePromise<C> implements Future<C>,Promise<C>
|
|||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return String.format("FutureCallback@%x{%b,%b,%s}",hashCode(),_done,_cause==COMPLETED,_result);
|
||||
return String.format("FutureCallback@%x{%b,%b,%s}",hashCode(),_done.get(),_cause==COMPLETED,_result);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.util;
|
||||
|
||||
import java.io.EOFException;
|
||||
import java.nio.channels.ClosedChannelException;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ package org.eclipse.jetty.util;
|
|||
|
||||
import java.lang.ref.PhantomReference;
|
||||
import java.lang.ref.ReferenceQueue;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.io.IOException;
|
|||
import java.io.InterruptedIOException;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.concurrent.locks.Condition;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
|
|
|
@ -20,8 +20,6 @@ package org.eclipse.jetty.util;
|
|||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.eclipse.jetty.util.Utf8Appendable.NotUtf8Exception;
|
||||
|
||||
/**
|
||||
* Stateful parser for lines of UTF8 formatted text, looking for <code>"\n"</code> as a line termination character.
|
||||
* <p>
|
||||
|
|
|
@ -79,6 +79,8 @@ public abstract class AbstractLogger implements Logger
|
|||
public void debug(String msg, long arg)
|
||||
{
|
||||
if (isDebugEnabled())
|
||||
debug(msg,new Long(arg));
|
||||
{
|
||||
debug(msg,new Object[] { new Long(arg) });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -239,6 +239,12 @@ public class StdErrLog extends AbstractLogger
|
|||
*/
|
||||
public static int getLoggingLevel(Properties props, final String name)
|
||||
{
|
||||
if ((props == null) || (props.isEmpty()))
|
||||
{
|
||||
// Default Logging Level
|
||||
return getLevelId("log.LEVEL","INFO");
|
||||
}
|
||||
|
||||
// Calculate the level this named logger should operate under.
|
||||
// Checking with FQCN first, then each package segment from longest to shortest.
|
||||
String nameSegment = name;
|
||||
|
|
|
@ -39,7 +39,6 @@ import org.eclipse.jetty.util.annotation.Name;
|
|||
import org.eclipse.jetty.util.component.AbstractLifeCycle;
|
||||
import org.eclipse.jetty.util.component.ContainerLifeCycle;
|
||||
import org.eclipse.jetty.util.component.Dumpable;
|
||||
import org.eclipse.jetty.util.component.LifeCycle;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.thread.ThreadPool.SizedThreadPool;
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.util.concurrent.Executor;
|
|||
|
||||
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||
import org.eclipse.jetty.util.component.LifeCycle;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** ThreadPool.
|
||||
|
|
|
@ -24,7 +24,6 @@ import static org.junit.Assert.assertTrue;
|
|||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue