Merge remote-tracking branch 'origin/jetty-9.4.x' into backport-jws11
This commit is contained in:
commit
5b6b80ef81
|
@ -53,7 +53,7 @@ node {
|
|||
withEnv(mvnEnv) {
|
||||
timeout(time: 90, unit: 'MINUTES') {
|
||||
// Run test phase / ignore test failures
|
||||
sh "mvn -B install -Dmaven.test.failure.ignore=true"
|
||||
sh "mvn -B install -Dmaven.test.failure.ignore=true -Prun-its"
|
||||
// Report failures in the jenkins UI
|
||||
step([$class: 'JUnitResultArchiver',
|
||||
testResults: '**/target/surefire-reports/TEST-*.xml'])
|
||||
|
|
|
@ -0,0 +1,183 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2017 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.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.net.SocketException;
|
||||
import java.nio.channels.SelectableChannel;
|
||||
import java.nio.channels.SelectionKey;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.jetty.client.api.Connection;
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.io.ManagedSelector;
|
||||
import org.eclipse.jetty.io.SelectorManager;
|
||||
import org.eclipse.jetty.io.SocketChannelEndPoint;
|
||||
import org.eclipse.jetty.io.ssl.SslClientConnectionFactory;
|
||||
import org.eclipse.jetty.util.Promise;
|
||||
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||
|
||||
public abstract class AbstractConnectorHttpClientTransport extends AbstractHttpClientTransport
|
||||
{
|
||||
private final int selectors;
|
||||
private SelectorManager selectorManager;
|
||||
|
||||
protected AbstractConnectorHttpClientTransport(int selectors)
|
||||
{
|
||||
this.selectors = selectors;
|
||||
}
|
||||
|
||||
@ManagedAttribute(value = "The number of selectors", readonly = true)
|
||||
public int getSelectors()
|
||||
{
|
||||
return selectors;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStart() throws Exception
|
||||
{
|
||||
HttpClient httpClient = getHttpClient();
|
||||
selectorManager = newSelectorManager(httpClient);
|
||||
selectorManager.setConnectTimeout(httpClient.getConnectTimeout());
|
||||
addBean(selectorManager);
|
||||
super.doStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStop() throws Exception
|
||||
{
|
||||
super.doStop();
|
||||
removeBean(selectorManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect(InetSocketAddress address, Map<String, Object> context)
|
||||
{
|
||||
SocketChannel channel = null;
|
||||
try
|
||||
{
|
||||
channel = SocketChannel.open();
|
||||
HttpDestination destination = (HttpDestination)context.get(HTTP_DESTINATION_CONTEXT_KEY);
|
||||
HttpClient client = destination.getHttpClient();
|
||||
SocketAddress bindAddress = client.getBindAddress();
|
||||
if (bindAddress != null)
|
||||
channel.bind(bindAddress);
|
||||
configure(client, channel);
|
||||
|
||||
context.put(SslClientConnectionFactory.SSL_PEER_HOST_CONTEXT_KEY, destination.getHost());
|
||||
context.put(SslClientConnectionFactory.SSL_PEER_PORT_CONTEXT_KEY, destination.getPort());
|
||||
|
||||
if (client.isConnectBlocking())
|
||||
{
|
||||
channel.socket().connect(address, (int)client.getConnectTimeout());
|
||||
channel.configureBlocking(false);
|
||||
selectorManager.accept(channel, context);
|
||||
}
|
||||
else
|
||||
{
|
||||
channel.configureBlocking(false);
|
||||
if (channel.connect(address))
|
||||
selectorManager.accept(channel, context);
|
||||
else
|
||||
selectorManager.connect(channel, context);
|
||||
}
|
||||
}
|
||||
// Must catch all exceptions, since some like
|
||||
// UnresolvedAddressException are not IOExceptions.
|
||||
catch (Throwable x)
|
||||
{
|
||||
// If IPv6 is not deployed, a generic SocketException "Network is unreachable"
|
||||
// exception is being thrown, so we attempt to provide a better error message.
|
||||
if (x.getClass() == SocketException.class)
|
||||
x = new SocketException("Could not connect to " + address).initCause(x);
|
||||
|
||||
try
|
||||
{
|
||||
if (channel != null)
|
||||
channel.close();
|
||||
}
|
||||
catch (IOException xx)
|
||||
{
|
||||
LOG.ignore(xx);
|
||||
}
|
||||
finally
|
||||
{
|
||||
connectFailed(context, x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void connectFailed(Map<String, Object> context, Throwable x)
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Could not connect to {}", context.get(HTTP_DESTINATION_CONTEXT_KEY));
|
||||
@SuppressWarnings("unchecked")
|
||||
Promise<Connection> promise = (Promise<Connection>)context.get(HTTP_CONNECTION_PROMISE_CONTEXT_KEY);
|
||||
promise.failed(x);
|
||||
}
|
||||
|
||||
protected void configure(HttpClient client, SocketChannel channel) throws IOException
|
||||
{
|
||||
channel.socket().setTcpNoDelay(client.isTCPNoDelay());
|
||||
}
|
||||
|
||||
protected SelectorManager newSelectorManager(HttpClient client)
|
||||
{
|
||||
return new ClientSelectorManager(client, getSelectors());
|
||||
}
|
||||
|
||||
protected class ClientSelectorManager extends SelectorManager
|
||||
{
|
||||
private final HttpClient client;
|
||||
|
||||
protected ClientSelectorManager(HttpClient client, int selectors)
|
||||
{
|
||||
super(client.getExecutor(), client.getScheduler(), selectors);
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EndPoint newEndPoint(SelectableChannel channel, ManagedSelector selector, SelectionKey key)
|
||||
{
|
||||
SocketChannelEndPoint endp = new SocketChannelEndPoint(channel, selector, key, getScheduler());
|
||||
endp.setIdleTimeout(client.getIdleTimeout());
|
||||
return endp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.eclipse.jetty.io.Connection newConnection(SelectableChannel channel, EndPoint endPoint, Object attachment) throws IOException
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> context = (Map<String, Object>)attachment;
|
||||
HttpDestination destination = (HttpDestination)context.get(HTTP_DESTINATION_CONTEXT_KEY);
|
||||
return destination.getClientConnectionFactory().newConnection(endPoint, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void connectionFailed(SelectableChannel channel, Throwable x, Object attachment)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> context = (Map<String, Object>)attachment;
|
||||
connectFailed(context, x);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,24 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.net.SocketException;
|
||||
import java.nio.channels.SelectableChannel;
|
||||
import java.nio.channels.SelectionKey;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.jetty.client.api.Connection;
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.io.ManagedSelector;
|
||||
import org.eclipse.jetty.io.SelectChannelEndPoint;
|
||||
import org.eclipse.jetty.io.SelectorManager;
|
||||
import org.eclipse.jetty.io.SocketChannelEndPoint;
|
||||
import org.eclipse.jetty.io.ssl.SslClientConnectionFactory;
|
||||
import org.eclipse.jetty.util.Promise;
|
||||
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||
import org.eclipse.jetty.util.component.ContainerLifeCycle;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
|
@ -46,14 +28,8 @@ public abstract class AbstractHttpClientTransport extends ContainerLifeCycle imp
|
|||
{
|
||||
protected static final Logger LOG = Log.getLogger(HttpClientTransport.class);
|
||||
|
||||
private final int selectors;
|
||||
private volatile HttpClient client;
|
||||
private volatile SelectorManager selectorManager;
|
||||
|
||||
protected AbstractHttpClientTransport(int selectors)
|
||||
{
|
||||
this.selectors = selectors;
|
||||
}
|
||||
private HttpClient client;
|
||||
private ConnectionPool.Factory factory;
|
||||
|
||||
protected HttpClient getHttpClient()
|
||||
{
|
||||
|
@ -66,137 +42,15 @@ public abstract class AbstractHttpClientTransport extends ContainerLifeCycle imp
|
|||
this.client = client;
|
||||
}
|
||||
|
||||
@ManagedAttribute(value = "The number of selectors", readonly = true)
|
||||
public int getSelectors()
|
||||
@Override
|
||||
public ConnectionPool.Factory getConnectionPoolFactory()
|
||||
{
|
||||
return selectors;
|
||||
return factory;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStart() throws Exception
|
||||
public void setConnectionPoolFactory(ConnectionPool.Factory factory)
|
||||
{
|
||||
selectorManager = newSelectorManager(client);
|
||||
selectorManager.setConnectTimeout(client.getConnectTimeout());
|
||||
addBean(selectorManager);
|
||||
super.doStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStop() throws Exception
|
||||
{
|
||||
super.doStop();
|
||||
removeBean(selectorManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect(InetSocketAddress address, Map<String, Object> context)
|
||||
{
|
||||
SocketChannel channel = null;
|
||||
try
|
||||
{
|
||||
channel = SocketChannel.open();
|
||||
HttpDestination destination = (HttpDestination)context.get(HTTP_DESTINATION_CONTEXT_KEY);
|
||||
HttpClient client = destination.getHttpClient();
|
||||
SocketAddress bindAddress = client.getBindAddress();
|
||||
if (bindAddress != null)
|
||||
channel.bind(bindAddress);
|
||||
configure(client, channel);
|
||||
|
||||
context.put(SslClientConnectionFactory.SSL_PEER_HOST_CONTEXT_KEY, destination.getHost());
|
||||
context.put(SslClientConnectionFactory.SSL_PEER_PORT_CONTEXT_KEY, destination.getPort());
|
||||
|
||||
if (client.isConnectBlocking())
|
||||
{
|
||||
channel.socket().connect(address, (int)client.getConnectTimeout());
|
||||
channel.configureBlocking(false);
|
||||
selectorManager.accept(channel, context);
|
||||
}
|
||||
else
|
||||
{
|
||||
channel.configureBlocking(false);
|
||||
if (channel.connect(address))
|
||||
selectorManager.accept(channel, context);
|
||||
else
|
||||
selectorManager.connect(channel, context);
|
||||
}
|
||||
}
|
||||
// Must catch all exceptions, since some like
|
||||
// UnresolvedAddressException are not IOExceptions.
|
||||
catch (Throwable x)
|
||||
{
|
||||
// If IPv6 is not deployed, a generic SocketException "Network is unreachable"
|
||||
// exception is being thrown, so we attempt to provide a better error message.
|
||||
if (x.getClass() == SocketException.class)
|
||||
x = new SocketException("Could not connect to " + address).initCause(x);
|
||||
|
||||
try
|
||||
{
|
||||
if (channel != null)
|
||||
channel.close();
|
||||
}
|
||||
catch (IOException xx)
|
||||
{
|
||||
LOG.ignore(xx);
|
||||
}
|
||||
finally
|
||||
{
|
||||
connectFailed(context, x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void connectFailed(Map<String, Object> context, Throwable x)
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Could not connect to {}", context.get(HTTP_DESTINATION_CONTEXT_KEY));
|
||||
@SuppressWarnings("unchecked")
|
||||
Promise<Connection> promise = (Promise<Connection>)context.get(HTTP_CONNECTION_PROMISE_CONTEXT_KEY);
|
||||
promise.failed(x);
|
||||
}
|
||||
|
||||
protected void configure(HttpClient client, SocketChannel channel) throws IOException
|
||||
{
|
||||
channel.socket().setTcpNoDelay(client.isTCPNoDelay());
|
||||
}
|
||||
|
||||
protected SelectorManager newSelectorManager(HttpClient client)
|
||||
{
|
||||
return new ClientSelectorManager(client, selectors);
|
||||
}
|
||||
|
||||
protected class ClientSelectorManager extends SelectorManager
|
||||
{
|
||||
private final HttpClient client;
|
||||
|
||||
protected ClientSelectorManager(HttpClient client, int selectors)
|
||||
{
|
||||
super(client.getExecutor(), client.getScheduler(), selectors);
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EndPoint newEndPoint(SelectableChannel channel, ManagedSelector selector, SelectionKey key)
|
||||
{
|
||||
SocketChannelEndPoint endp = new SocketChannelEndPoint(channel, selector, key, getScheduler());
|
||||
endp.setIdleTimeout(client.getIdleTimeout());
|
||||
return endp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.eclipse.jetty.io.Connection newConnection(SelectableChannel channel, EndPoint endPoint, Object attachment) throws IOException
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> context = (Map<String, Object>)attachment;
|
||||
HttpDestination destination = (HttpDestination)context.get(HTTP_DESTINATION_CONTEXT_KEY);
|
||||
return destination.getClientConnectionFactory().newConnection(endPoint, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void connectionFailed(SelectableChannel channel, Throwable x, Object attachment)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> context = (Map<String, Object>)attachment;
|
||||
connectFailed(context, x);
|
||||
}
|
||||
this.factory = factory;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,20 +22,73 @@ import java.io.Closeable;
|
|||
|
||||
import org.eclipse.jetty.client.api.Connection;
|
||||
|
||||
/**
|
||||
* <p>Client-side connection pool abstraction.</p>
|
||||
*/
|
||||
public interface ConnectionPool extends Closeable
|
||||
{
|
||||
/**
|
||||
* @param connection the connection to test
|
||||
* @return whether the given connection is currently in use
|
||||
*/
|
||||
boolean isActive(Connection connection);
|
||||
|
||||
/**
|
||||
* @return whether this ConnectionPool has no open connections
|
||||
*/
|
||||
boolean isEmpty();
|
||||
|
||||
/**
|
||||
* @return whether this ConnectionPool has been closed
|
||||
* @see #close()
|
||||
*/
|
||||
boolean isClosed();
|
||||
|
||||
/**
|
||||
* <p>Returns an idle connection, if available, or schedules the opening
|
||||
* of a new connection and returns {@code null}.</p>
|
||||
*
|
||||
* @return an available connection, or null
|
||||
*/
|
||||
Connection acquire();
|
||||
|
||||
/**
|
||||
* <p>Returns the given connection, previously obtained via {@link #acquire()},
|
||||
* back to this ConnectionPool.</p>
|
||||
*
|
||||
* @param connection the connection to release
|
||||
* @return true if the connection has been released, false if the connection
|
||||
* was not obtained from the this ConnectionPool
|
||||
*/
|
||||
boolean release(Connection connection);
|
||||
|
||||
/**
|
||||
* <p>Removes the given connection from this ConnectionPool.</p>
|
||||
*
|
||||
* @param connection the connection to remove
|
||||
* @return true if the connection was removed from this ConnectionPool
|
||||
*/
|
||||
boolean remove(Connection connection);
|
||||
|
||||
/**
|
||||
* Closes this ConnectionPool.
|
||||
*
|
||||
* @see #isClosed()
|
||||
*/
|
||||
@Override
|
||||
void close();
|
||||
|
||||
/**
|
||||
* Factory for ConnectionPool instances.
|
||||
*/
|
||||
interface Factory
|
||||
{
|
||||
/**
|
||||
* Creates a new ConnectionPool for the given destination.
|
||||
*
|
||||
* @param destination the destination to create the ConnectionPool for
|
||||
* @return the newly created ConnectionPool
|
||||
*/
|
||||
ConnectionPool newConnectionPool(HttpDestination destination);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,4 +68,14 @@ public interface HttpClientTransport extends ClientConnectionFactory
|
|||
* @param context the context information to establish the connection
|
||||
*/
|
||||
public void connect(InetSocketAddress address, Map<String, Object> context);
|
||||
|
||||
/**
|
||||
* @return the factory for ConnectionPool instances
|
||||
*/
|
||||
public ConnectionPool.Factory getConnectionPoolFactory();
|
||||
|
||||
/**
|
||||
* @param factory the factory for ConnectionPool instances
|
||||
*/
|
||||
public void setConnectionPoolFactory(ConnectionPool.Factory factory);
|
||||
}
|
||||
|
|
|
@ -114,7 +114,10 @@ public abstract class HttpDestination extends ContainerLifeCycle implements Dest
|
|||
removeBean(connectionPool);
|
||||
}
|
||||
|
||||
protected abstract ConnectionPool newConnectionPool(HttpClient client);
|
||||
protected ConnectionPool newConnectionPool(HttpClient client)
|
||||
{
|
||||
return client.getTransport().getConnectionPoolFactory().newConnectionPool(this);
|
||||
}
|
||||
|
||||
protected Queue<HttpExchange> newExchangeQueue(HttpClient client)
|
||||
{
|
||||
|
|
|
@ -25,12 +25,6 @@ public abstract class MultiplexHttpDestination extends HttpDestination
|
|||
super(client, origin);
|
||||
}
|
||||
|
||||
protected ConnectionPool newConnectionPool(HttpClient client)
|
||||
{
|
||||
return new MultiplexConnectionPool(this, client.getMaxConnectionsPerDestination(), this,
|
||||
client.getMaxRequestsQueuedPerDestination());
|
||||
}
|
||||
|
||||
public int getMaxRequestsPerConnection()
|
||||
{
|
||||
ConnectionPool connectionPool = getConnectionPool();
|
||||
|
|
|
@ -24,9 +24,4 @@ public abstract class PoolingHttpDestination extends HttpDestination
|
|||
{
|
||||
super(client, origin);
|
||||
}
|
||||
|
||||
protected ConnectionPool newConnectionPool(HttpClient client)
|
||||
{
|
||||
return new DuplexConnectionPool(this, client.getMaxConnectionsPerDestination(), this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,8 @@ package org.eclipse.jetty.client.http;
|
|||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.jetty.client.AbstractHttpClientTransport;
|
||||
import org.eclipse.jetty.client.AbstractConnectorHttpClientTransport;
|
||||
import org.eclipse.jetty.client.DuplexConnectionPool;
|
||||
import org.eclipse.jetty.client.HttpDestination;
|
||||
import org.eclipse.jetty.client.Origin;
|
||||
import org.eclipse.jetty.client.api.Connection;
|
||||
|
@ -30,7 +31,7 @@ import org.eclipse.jetty.util.Promise;
|
|||
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||
|
||||
@ManagedObject("The HTTP/1.1 client transport")
|
||||
public class HttpClientTransportOverHTTP extends AbstractHttpClientTransport
|
||||
public class HttpClientTransportOverHTTP extends AbstractConnectorHttpClientTransport
|
||||
{
|
||||
public HttpClientTransportOverHTTP()
|
||||
{
|
||||
|
@ -40,6 +41,7 @@ public class HttpClientTransportOverHTTP extends AbstractHttpClientTransport
|
|||
public HttpClientTransportOverHTTP(int selectors)
|
||||
{
|
||||
super(selectors);
|
||||
setConnectionPoolFactory(destination -> new DuplexConnectionPool(destination, getHttpClient().getMaxConnectionsPerDestination(), destination));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -29,7 +29,6 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import org.eclipse.jetty.client.api.ContentResponse;
|
||||
import org.eclipse.jetty.client.api.Request;
|
||||
import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP;
|
||||
import org.eclipse.jetty.client.http.HttpDestinationOverHTTP;
|
||||
import org.eclipse.jetty.client.util.FutureResponseListener;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.HttpHeaderValue;
|
||||
|
@ -50,7 +49,11 @@ public class ValidatingConnectionPoolTest extends AbstractHttpClientServerTest
|
|||
@Override
|
||||
protected void startClient() throws Exception
|
||||
{
|
||||
startClient(new ValidatingHttpClientTransportOverHTTP(1000));
|
||||
long timeout = 1000;
|
||||
HttpClientTransportOverHTTP transport = new HttpClientTransportOverHTTP(1);
|
||||
transport.setConnectionPoolFactory(destination ->
|
||||
new ValidatingConnectionPool(destination, destination.getHttpClient().getMaxConnectionsPerDestination(), destination, destination.getHttpClient().getScheduler(), timeout));
|
||||
startClient(transport);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -177,28 +180,4 @@ public class ValidatingConnectionPoolTest extends AbstractHttpClientServerTest
|
|||
ContentResponse response2 = listener2.get(5, TimeUnit.SECONDS);
|
||||
Assert.assertEquals(200, response2.getStatus());
|
||||
}
|
||||
|
||||
private static class ValidatingHttpClientTransportOverHTTP extends HttpClientTransportOverHTTP
|
||||
{
|
||||
private final long timeout;
|
||||
|
||||
public ValidatingHttpClientTransportOverHTTP(long timeout)
|
||||
{
|
||||
super(1);
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpDestination newHttpDestination(Origin origin)
|
||||
{
|
||||
return new HttpDestinationOverHTTP(getHttpClient(), origin)
|
||||
{
|
||||
@Override
|
||||
protected DuplexConnectionPool newConnectionPool(HttpClient client)
|
||||
{
|
||||
return new ValidatingConnectionPool(this, client.getMaxConnectionsPerDestination(), this, client.getScheduler(), timeout);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,6 +41,8 @@ link:{GITBROWSEURL}/jetty-server/src/main/config/etc/jetty-ssl.xml[`jetty-ssl.xm
|
|||
On it's own, this connector is not functional and requires one or more of the following files to also be configured to add link:{JDURL}/org/eclipse/jetty/server/ConnectionFactory.html[`ConnectionFactories`] to make the connector functional.
|
||||
link:{GITBROWSEURL}/jetty-server/src/main/config/etc/jetty-https.xml[`jetty-https.xml`]::
|
||||
Adds a link:{JDURL}/org/eclipse/jetty/server/HttpConnectionFactory.html[`HttpConnectionFactory`] to the link:{JDURL}/org/eclipse/jetty/server/ServerConnector.html[`ServerConnector`] configured by `jetty-ssl.xml` which combine to provide support for HTTPS.
|
||||
link:{GITBROWSEURL}/jetty-server/src/main/config/etc/jetty-http-forwarded.xml[`jetty-http-forwarded.xml`]::
|
||||
Adds a link:{JDURL}/org/eclipse/jetty/server/ForwardedRequestCustomizer.html[`ForwardedRequestCustomizer`]to the HTTP Connector to process forwarded-for style headers from a proxy.
|
||||
link:{GITBROWSEURL}/jetty-http2/http2-server/src/main/config/etc/jetty-http2.xml[`jetty-http2.xml`]::
|
||||
Adds a link:{JDURL}/org/eclipse/jetty/http2/server/HTTP2ServerConnectionFactory.html[`Http2ServerConnectionFactory`] to the link:{JDURL}/org/eclipse/jetty/server/ServerConnector.html[`ServerConnector`] configured by `jetty-ssl.xml` to support the http2 protocol. Also prepends either `protonego-alpn.xml` or `protonego-npn.xml` so that the next protocol can be negotiated, which allows the same SSL port to handle multiple protocols.
|
||||
link:{GITBROWSEURL}/jetty-alpn/jetty-alpn-server/src/main/config/etc/jetty-alpn.xml[`jetty-alpn.xml`]::
|
||||
|
@ -49,6 +51,12 @@ link:{GITBROWSEURL}/jetty-alpn/jetty-alpn-server/src/main/config/etc/jetty-alpn.
|
|||
Typically connectors require very little configuration aside from setting the listening port (see link:#jetty-connectors-network-settings[Network Settings]), and enabling `X-Forwarded-For` customization when applicable. (see link:#jetty-connectors-http-configuration[HTTP Configuration]).
|
||||
Additional settings are for expert configuration only.
|
||||
|
||||
____
|
||||
[NOTE]
|
||||
All the connectors discussed in this chapter can be enabled in the Jetty Distribution by enabling them via the module system.
|
||||
Please refer to our chapter on link:#startup-modules[Managing Startup Modules] for more information.
|
||||
____
|
||||
|
||||
==== Constructing a ServerConnector
|
||||
|
||||
The services a link:{JDURL}/org/eclipse/jetty/server/ServerConnector.html[`ServerConnector`] instance uses are set by constructor injection and once instantiated cannot be changed.
|
||||
|
|
|
@ -86,3 +86,33 @@ public class GoogleOnlyCookieStore extends HttpCookieStore
|
|||
----
|
||||
|
||||
The example above will retain only cookies that come from the `google.com` domain or sub-domains.
|
||||
|
||||
==== Special Characters in Cookies
|
||||
Jetty is compliant with link:https://tools.ietf.org/html/rfc6265[RFC6265], and as such care must be taken when setting a cookie value that includes special characters such as `;`.
|
||||
|
||||
Previously, Version=1 cookies defined in link:https://tools.ietf.org/html/rfc2109[RFC2109] (and continued in link:https://tools.ietf.org/html/rfc2965[RFC2965]) allowed for special/reserved characters to be enclosed within double quotes when declared in a `Set-Cookie` response header:
|
||||
|
||||
[source, java, subs="{sub-order}"]
|
||||
----
|
||||
Set-Cookie: foo="bar;baz";Version=1;Path="/secur"
|
||||
----
|
||||
|
||||
This was added to the HTTP Response header as follows:
|
||||
|
||||
[source, java, subs="{sub-order}"]
|
||||
----
|
||||
Cookie cookie = new Cookie("foo", "bar;baz");
|
||||
cookie.setPath("/secur");
|
||||
response.addCookie(cookie);
|
||||
----
|
||||
|
||||
The introduction of RFC6265 has rendered this approach no longer possible; users are now required to encode cookie values that use these special characters.
|
||||
This can be done utilizing `javax.servlet.http.Cookie` as follows:
|
||||
|
||||
[source, java, subs="{sub-order}"]
|
||||
----
|
||||
Cookie cookie = new Cookie("foo", URLEncoder.encode("bar;baz", "utf-8"));
|
||||
----
|
||||
|
||||
Jetty validates all cookie names and values being added to the `HttpServletResponse` via the `addCookie(Cookie)` method.
|
||||
If an illegal value is discovered Jetty will throw an `IllegalArgumentException` with the details.
|
||||
|
|
|
@ -21,8 +21,11 @@ package org.eclipse.jetty.fcgi.client.http;
|
|||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.jetty.client.AbstractHttpClientTransport;
|
||||
import org.eclipse.jetty.client.AbstractConnectorHttpClientTransport;
|
||||
import org.eclipse.jetty.client.DuplexConnectionPool;
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.eclipse.jetty.client.HttpDestination;
|
||||
import org.eclipse.jetty.client.MultiplexConnectionPool;
|
||||
import org.eclipse.jetty.client.Origin;
|
||||
import org.eclipse.jetty.client.api.Connection;
|
||||
import org.eclipse.jetty.client.api.Request;
|
||||
|
@ -34,7 +37,7 @@ import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
|||
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||
|
||||
@ManagedObject("The FastCGI/1.0 client transport")
|
||||
public class HttpClientTransportOverFCGI extends AbstractHttpClientTransport
|
||||
public class HttpClientTransportOverFCGI extends AbstractConnectorHttpClientTransport
|
||||
{
|
||||
private final boolean multiplexed;
|
||||
private final String scriptRoot;
|
||||
|
@ -49,6 +52,14 @@ public class HttpClientTransportOverFCGI extends AbstractHttpClientTransport
|
|||
super(selectors);
|
||||
this.multiplexed = multiplexed;
|
||||
this.scriptRoot = scriptRoot;
|
||||
setConnectionPoolFactory(destination ->
|
||||
{
|
||||
HttpClient httpClient = getHttpClient();
|
||||
int maxConnections = httpClient.getMaxConnectionsPerDestination();
|
||||
return isMultiplexed() ?
|
||||
new MultiplexConnectionPool(destination, maxConnections, destination, httpClient.getMaxRequestsQueuedPerDestination()) :
|
||||
new DuplexConnectionPool(destination, maxConnections, destination);
|
||||
});
|
||||
}
|
||||
|
||||
public boolean isMultiplexed()
|
||||
|
|
|
@ -45,23 +45,23 @@ import org.eclipse.jetty.proxy.AsyncProxyServlet;
|
|||
* Specific implementation of {@link org.eclipse.jetty.proxy.AsyncProxyServlet.Transparent} for FastCGI.
|
||||
* <p>
|
||||
* This servlet accepts a HTTP request and transforms it into a FastCGI request
|
||||
* that is sent to the FastCGI server specified in the <code>proxyTo</code>
|
||||
* that is sent to the FastCGI server specified in the {@code proxyTo}
|
||||
* init-param.
|
||||
* <p>
|
||||
* This servlet accepts two additional init-params:
|
||||
* <ul>
|
||||
* <li><code>scriptRoot</code>, mandatory, that must be set to the directory where
|
||||
* <li>{@code scriptRoot}, mandatory, that must be set to the directory where
|
||||
* the application that must be served via FastCGI is installed and corresponds to
|
||||
* the FastCGI DOCUMENT_ROOT parameter</li>
|
||||
* <li><code>scriptPattern</code>, optional, defaults to <code>(.+?\.php)</code>,
|
||||
* <li>{@code scriptPattern}, optional, defaults to {@code (.+?\.php)},
|
||||
* that specifies a regular expression with at least 1 and at most 2 groups that specify
|
||||
* respectively:
|
||||
* <ul>
|
||||
* <li>the FastCGI SCRIPT_NAME parameter</li>
|
||||
* <li>the FastCGI PATH_INFO parameter</li>
|
||||
* </ul></li>
|
||||
* <li><code>fastCGI.HTTPS</code>, optional, defaults to false, that specifies whether
|
||||
* to force the FastCGI <code>HTTPS</code> parameter to the value <code>on</code></li>
|
||||
* <li>{@code fastCGI.HTTPS}, optional, defaults to false, that specifies whether
|
||||
* to force the FastCGI {@code HTTPS} parameter to the value {@code on}</li>
|
||||
* </ul>
|
||||
*
|
||||
* @see TryFilesFilter
|
||||
|
@ -111,7 +111,11 @@ public class FastCGIProxyServlet extends AsyncProxyServlet.Transparent
|
|||
String scriptRoot = config.getInitParameter(SCRIPT_ROOT_INIT_PARAM);
|
||||
if (scriptRoot == null)
|
||||
throw new IllegalArgumentException("Mandatory parameter '" + SCRIPT_ROOT_INIT_PARAM + "' not configured");
|
||||
return new HttpClient(new ProxyHttpClientTransportOverFCGI(scriptRoot), null);
|
||||
int selectors = Math.max(1, Runtime.getRuntime().availableProcessors() / 2);
|
||||
String value = config.getInitParameter("selectors");
|
||||
if (value != null)
|
||||
selectors = Integer.parseInt(value);
|
||||
return new HttpClient(new ProxyHttpClientTransportOverFCGI(selectors, scriptRoot), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -238,9 +242,9 @@ public class FastCGIProxyServlet extends AsyncProxyServlet.Transparent
|
|||
|
||||
private class ProxyHttpClientTransportOverFCGI extends HttpClientTransportOverFCGI
|
||||
{
|
||||
public ProxyHttpClientTransportOverFCGI(String scriptRoot)
|
||||
private ProxyHttpClientTransportOverFCGI(int selectors, String scriptRoot)
|
||||
{
|
||||
super(scriptRoot);
|
||||
super(selectors, false, scriptRoot);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,13 +20,10 @@ package org.eclipse.jetty.fcgi.server;
|
|||
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import org.eclipse.jetty.client.DuplexConnectionPool;
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.eclipse.jetty.client.HttpDestination;
|
||||
import org.eclipse.jetty.client.HttpClientTransport;
|
||||
import org.eclipse.jetty.client.LeakTrackingConnectionPool;
|
||||
import org.eclipse.jetty.client.Origin;
|
||||
import org.eclipse.jetty.fcgi.client.http.HttpClientTransportOverFCGI;
|
||||
import org.eclipse.jetty.fcgi.client.http.HttpDestinationOverFCGI;
|
||||
import org.eclipse.jetty.http.HttpScheme;
|
||||
import org.eclipse.jetty.io.LeakTrackingByteBufferPool;
|
||||
import org.eclipse.jetty.io.MappedByteBufferPool;
|
||||
|
@ -72,28 +69,16 @@ public abstract class AbstractHttpClientServerTest
|
|||
QueuedThreadPool executor = new QueuedThreadPool();
|
||||
executor.setName(executor.getName() + "-client");
|
||||
|
||||
client = new HttpClient(new HttpClientTransportOverFCGI(1, false, "")
|
||||
HttpClientTransport transport = new HttpClientTransportOverFCGI(1, false, "");
|
||||
transport.setConnectionPoolFactory(destination -> new LeakTrackingConnectionPool(destination, client.getMaxConnectionsPerDestination(), destination)
|
||||
{
|
||||
@Override
|
||||
public HttpDestination newHttpDestination(Origin origin)
|
||||
protected void leaked(LeakDetector.LeakInfo leakInfo)
|
||||
{
|
||||
return new HttpDestinationOverFCGI(client, origin)
|
||||
{
|
||||
@Override
|
||||
protected DuplexConnectionPool newConnectionPool(HttpClient client)
|
||||
{
|
||||
return new LeakTrackingConnectionPool(this, client.getMaxConnectionsPerDestination(), this)
|
||||
{
|
||||
@Override
|
||||
protected void leaked(LeakDetector.LeakInfo leakInfo)
|
||||
{
|
||||
connectionLeaks.incrementAndGet();
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
connectionLeaks.incrementAndGet();
|
||||
}
|
||||
}, null);
|
||||
});
|
||||
client = new HttpClient(transport, null);
|
||||
client.setExecutor(executor);
|
||||
clientBufferPool = new LeakTrackingByteBufferPool(new MappedByteBufferPool.Tagged());
|
||||
client.setByteBufferPool(clientBufferPool);
|
||||
|
|
|
@ -24,9 +24,10 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
import org.eclipse.jetty.alpn.client.ALPNClientConnectionFactory;
|
||||
import org.eclipse.jetty.client.AbstractHttpClientTransport;
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.eclipse.jetty.client.HttpClientTransport;
|
||||
import org.eclipse.jetty.client.HttpDestination;
|
||||
import org.eclipse.jetty.client.MultiplexConnectionPool;
|
||||
import org.eclipse.jetty.client.Origin;
|
||||
import org.eclipse.jetty.client.ProxyConfiguration;
|
||||
import org.eclipse.jetty.client.api.Connection;
|
||||
|
@ -42,20 +43,23 @@ import org.eclipse.jetty.io.EndPoint;
|
|||
import org.eclipse.jetty.util.Promise;
|
||||
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||
import org.eclipse.jetty.util.component.ContainerLifeCycle;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
|
||||
@ManagedObject("The HTTP/2 client transport")
|
||||
public class HttpClientTransportOverHTTP2 extends ContainerLifeCycle implements HttpClientTransport
|
||||
public class HttpClientTransportOverHTTP2 extends AbstractHttpClientTransport
|
||||
{
|
||||
private final HTTP2Client client;
|
||||
private ClientConnectionFactory connectionFactory;
|
||||
private HttpClient httpClient;
|
||||
private boolean useALPN = true;
|
||||
|
||||
public HttpClientTransportOverHTTP2(HTTP2Client client)
|
||||
{
|
||||
this.client = client;
|
||||
setConnectionPoolFactory(destination ->
|
||||
{
|
||||
HttpClient httpClient = getHttpClient();
|
||||
return new MultiplexConnectionPool(destination, httpClient.getMaxConnectionsPerDestination(), destination, httpClient.getMaxRequestsQueuedPerDestination());
|
||||
});
|
||||
}
|
||||
|
||||
@ManagedAttribute(value = "The number of selectors", readonly = true)
|
||||
|
@ -79,6 +83,7 @@ public class HttpClientTransportOverHTTP2 extends ContainerLifeCycle implements
|
|||
{
|
||||
if (!client.isStarted())
|
||||
{
|
||||
HttpClient httpClient = getHttpClient();
|
||||
client.setExecutor(httpClient.getExecutor());
|
||||
client.setScheduler(httpClient.getScheduler());
|
||||
client.setByteBufferPool(httpClient.getByteBufferPool());
|
||||
|
@ -104,34 +109,23 @@ public class HttpClientTransportOverHTTP2 extends ContainerLifeCycle implements
|
|||
removeBean(client);
|
||||
}
|
||||
|
||||
protected HttpClient getHttpClient()
|
||||
{
|
||||
return httpClient;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHttpClient(HttpClient client)
|
||||
{
|
||||
httpClient = client;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpDestination newHttpDestination(Origin origin)
|
||||
{
|
||||
return new HttpDestinationOverHTTP2(httpClient, origin);
|
||||
return new HttpDestinationOverHTTP2(getHttpClient(), origin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect(InetSocketAddress address, Map<String, Object> context)
|
||||
{
|
||||
client.setConnectTimeout(httpClient.getConnectTimeout());
|
||||
client.setConnectTimeout(getHttpClient().getConnectTimeout());
|
||||
|
||||
SessionListenerPromise listenerPromise = new SessionListenerPromise(context);
|
||||
|
||||
HttpDestinationOverHTTP2 destination = (HttpDestinationOverHTTP2)context.get(HTTP_DESTINATION_CONTEXT_KEY);
|
||||
SslContextFactory sslContextFactory = null;
|
||||
if (HttpScheme.HTTPS.is(destination.getScheme()))
|
||||
sslContextFactory = httpClient.getSslContextFactory();
|
||||
sslContextFactory = getHttpClient().getSslContextFactory();
|
||||
|
||||
client.connect(sslContextFactory, address, listenerPromise, listenerPromise, context);
|
||||
}
|
||||
|
@ -139,7 +133,7 @@ public class HttpClientTransportOverHTTP2 extends ContainerLifeCycle implements
|
|||
@Override
|
||||
public org.eclipse.jetty.io.Connection newConnection(EndPoint endPoint, Map<String, Object> context) throws IOException
|
||||
{
|
||||
endPoint.setIdleTimeout(httpClient.getIdleTimeout());
|
||||
endPoint.setIdleTimeout(getHttpClient().getIdleTimeout());
|
||||
|
||||
ClientConnectionFactory factory = connectionFactory;
|
||||
HttpDestinationOverHTTP2 destination = (HttpDestinationOverHTTP2)context.get(HTTP_DESTINATION_CONTEXT_KEY);
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
<mavenVersion>3.0.3</mavenVersion>
|
||||
<pluginToolsVersion>3.4</pluginToolsVersion>
|
||||
<bundle-symbolic-name>${project.groupId}.maven.plugin</bundle-symbolic-name>
|
||||
<it.debug>false</it.debug>
|
||||
<jetty.stopKey>FOOBEER</jetty.stopKey>
|
||||
<jetty.jvmArgs></jetty.jvmArgs>
|
||||
</properties>
|
||||
<build>
|
||||
<plugins>
|
||||
|
@ -153,6 +156,12 @@
|
|||
<artifactId>javax.transaction-api</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-client</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<reporting>
|
||||
<plugins>
|
||||
|
@ -177,4 +186,79 @@
|
|||
</plugin>
|
||||
</plugins>
|
||||
</reporting>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>run-its</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-invoker-plugin</artifactId>
|
||||
<version>3.0.1-SNAPSHOT</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>integration-test</id>
|
||||
<goals>
|
||||
<goal>install</goal>
|
||||
<goal>integration-test</goal>
|
||||
<goal>verify</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<debug>${it.debug}</debug>
|
||||
<addTestClassPath>true</addTestClassPath>
|
||||
<projectsDirectory>src/it</projectsDirectory>
|
||||
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
|
||||
<pomIncludes>
|
||||
<pomInclude>*/pom.xml</pomInclude>
|
||||
</pomIncludes>
|
||||
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
|
||||
<settingsFile>src/it/settings.xml</settingsFile>
|
||||
<scriptVariables>
|
||||
<jettyStopKey>${jetty.stopKey}</jettyStopKey>
|
||||
<jettyStopPort>${jetty.stopPort}</jettyStopPort>
|
||||
<jettyRunPort>${jetty.runPort}</jettyRunPort>
|
||||
</scriptVariables>
|
||||
<goals>
|
||||
<goal>clean</goal>
|
||||
</goals>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>reserve-ports</id>
|
||||
<phase>pre-integration-test</phase>
|
||||
<goals>
|
||||
<goal>reserve-network-port</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<portNames>
|
||||
<portName>jetty.stopPort</portName>
|
||||
<portName>jetty.runPort</portName>
|
||||
</portNames>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>apache.snaphots</id>
|
||||
<url>https://repository.apache.org/content/repositories/snapshots</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
invoker.goals = test -fae
|
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-forked-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-project</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>jetty-simple-base</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Jetty :: Simple :: Base</name>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<type>jar</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.toolchain</groupId>
|
||||
<artifactId>jetty-perf-helper</artifactId>
|
||||
<version>1.0.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.8.1</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,45 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2017 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.its.jetty_run_mojo_it;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@WebServlet("/hello")
|
||||
public class HelloServlet
|
||||
extends HttpServlet
|
||||
{
|
||||
|
||||
@Override
|
||||
protected void doGet( HttpServletRequest req, HttpServletResponse resp )
|
||||
throws ServletException, IOException
|
||||
{
|
||||
String who = req.getParameter( "name" );
|
||||
|
||||
resp.getWriter().write( "hello " + (who == null ? "unknown" : who) );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2017 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.its.jetty_run_mojo_it;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
public class PingServlet
|
||||
extends HttpServlet
|
||||
{
|
||||
|
||||
@Override
|
||||
protected void doGet( HttpServletRequest req, HttpServletResponse resp )
|
||||
throws ServletException, IOException
|
||||
{
|
||||
String who = req.getParameter( "name" );
|
||||
|
||||
resp.getWriter().write( "pong " + (who == null ? "unknown" : who) );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<web-fragment
|
||||
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-fragment_3_1.xsd"
|
||||
version="3.1">
|
||||
|
||||
<name>FragmentA</name>
|
||||
|
||||
<ordering>
|
||||
<after><others/></after>
|
||||
</ordering>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>Ping</servlet-name>
|
||||
<servlet-class>org.eclipse.jetty.its.jetty_run_mojo_it.PingServlet</servlet-class>
|
||||
<init-param>
|
||||
<param-name>extra1</param-name><param-value>123</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>extra2</param-name><param-value>345</param-value>
|
||||
</init-param>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>Ping</servlet-name>
|
||||
<url-pattern>/ping</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
|
||||
</web-fragment>
|
|
@ -0,0 +1,137 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-forked-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-project</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>jetty-simple-webapp</artifactId>
|
||||
<packaging>war</packaging>
|
||||
|
||||
<name>Jetty :: Simple :: Webapp</name>
|
||||
|
||||
<properties>
|
||||
<jetty.runPort>@jetty.runPort@</jetty.runPort>
|
||||
<jetty.jvmArgs>@jetty.jvmArgs@</jetty.jvmArgs>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-forked-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-base</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-client</artifactId>
|
||||
<version>@project.version@</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>${maven-war-plugin-version}</version>
|
||||
<configuration>
|
||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.20</version>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<jetty.runPort>@jetty.runPort@</jetty.runPort>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<stopPort>@jetty.stopPort@</stopPort>
|
||||
<stopKey>@jetty.stopKey@</stopKey>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>start-jetty</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals>
|
||||
<goal>run-forked</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<nonBlocking>true</nonBlocking>
|
||||
<waitForChild>false</waitForChild>
|
||||
<jettyXml>${project.build.directory}/config/jetty.xml</jettyXml>
|
||||
<jvmArgs>${jetty.jvmArgs}</jvmArgs>
|
||||
</configuration>
|
||||
</execution>
|
||||
<!--
|
||||
<execution>
|
||||
<id>stop-jetty</id>
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>stop</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
-->
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-resources-jetty</id>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}/config</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${basedir}/src/config/</directory>
|
||||
<filtering>true</filtering>
|
||||
<includes>
|
||||
<include>**/**</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
|
||||
|
||||
<Configure id="Server" class="org.eclipse.jetty.server.Server">
|
||||
<New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
|
||||
<Set name="secureScheme">https</Set>
|
||||
<Set name="securePort"><Property name="jetty.secure.port" default="8443" /></Set>
|
||||
<Set name="outputBufferSize">32768</Set>
|
||||
<Set name="requestHeaderSize">8192</Set>
|
||||
<Set name="responseHeaderSize">8192</Set>
|
||||
<Set name="headerCacheSize">512</Set>
|
||||
</New>
|
||||
|
||||
<Call name="addConnector">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.server.ServerConnector">
|
||||
<Arg name="server"><Ref refid="Server" /></Arg>
|
||||
<Arg name="factories">
|
||||
<Array type="org.eclipse.jetty.server.ConnectionFactory">
|
||||
<Item>
|
||||
<New class="org.eclipse.jetty.server.HttpConnectionFactory">
|
||||
<Arg name="config"><Ref refid="httpConfig" /></Arg>
|
||||
</New>
|
||||
</Item>
|
||||
</Array>
|
||||
</Arg>
|
||||
<Set name="host"><Property name="jetty.host" /></Set>
|
||||
<Set name="port"><Property name="jetty.port" default="${jetty.runPort}" /></Set>
|
||||
<Set name="idleTimeout">30000</Set>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
</Configure>
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0"?>
|
||||
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
|
||||
version="3.1">
|
||||
<display-name>Jetty Simple Webapp run-mojo-it</display-name>
|
||||
</web-app>
|
|
@ -0,0 +1,58 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2017 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.its.jetty_run_mojo_it;
|
||||
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class TestHelloServlet
|
||||
{
|
||||
@Test
|
||||
public void hello_servlet()
|
||||
throws Exception
|
||||
{
|
||||
int port = Integer.getInteger( "jetty.runPort" );
|
||||
System.out.println( "port used:" + port );
|
||||
HttpClient httpClient = new HttpClient();
|
||||
try
|
||||
{
|
||||
httpClient.start();
|
||||
|
||||
String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
|
||||
|
||||
System.out.println( "httpResponse:" + response );
|
||||
|
||||
Assert.assertEquals( "hello beer", response.trim() );
|
||||
|
||||
response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
|
||||
|
||||
System.out.println( "httpResponse:" + response );
|
||||
|
||||
Assert.assertEquals( "pong beer", response.trim() );
|
||||
}
|
||||
finally
|
||||
{
|
||||
httpClient.stop();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-forked-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-project</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Jetty :: Simple</name>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<maven-war-plugin-version>3.0.0</maven-war-plugin-version>
|
||||
<jetty.version>@project.version@</jetty.version>
|
||||
</properties>
|
||||
|
||||
<modules>
|
||||
<module>jetty-simple-base</module>
|
||||
<module>jetty-simple-webapp</module>
|
||||
</modules>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-forked-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-base</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<type>jar</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.21</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<target>1.8</target>
|
||||
<source>1.8</source>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
|
||||
System.out.println( "running postbuild.groovy port " + jettyStopPort + ", key:" + jettyStopKey )
|
||||
|
||||
int port = Integer.parseInt( jettyStopPort )
|
||||
|
||||
Socket s=new Socket(InetAddress.getByName("127.0.0.1"),port )
|
||||
s.setSoLinger(false, 0)
|
||||
|
||||
OutputStream out=s.getOutputStream()
|
||||
out.write(( jettyStopKey +"\r\nforcestop\r\n").getBytes())
|
||||
out.flush()
|
||||
s.close()
|
|
@ -0,0 +1 @@
|
|||
invoker.goals = test
|
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-project</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>jetty-simple-base</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Jetty :: Simple :: Base</name>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<type>jar</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.toolchain</groupId>
|
||||
<artifactId>jetty-perf-helper</artifactId>
|
||||
<version>1.0.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.8.1</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,45 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2017 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.its.jetty_run_mojo_it;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@WebServlet("/hello")
|
||||
public class HelloServlet
|
||||
extends HttpServlet
|
||||
{
|
||||
|
||||
@Override
|
||||
protected void doGet( HttpServletRequest req, HttpServletResponse resp )
|
||||
throws ServletException, IOException
|
||||
{
|
||||
String who = req.getParameter( "name" );
|
||||
|
||||
resp.getWriter().write( "hello " + (who == null ? "unknown" : who) );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2017 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.its.jetty_run_mojo_it;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
public class PingServlet
|
||||
extends HttpServlet
|
||||
{
|
||||
|
||||
@Override
|
||||
protected void doGet( HttpServletRequest req, HttpServletResponse resp )
|
||||
throws ServletException, IOException
|
||||
{
|
||||
String who = req.getParameter( "name" );
|
||||
|
||||
resp.getWriter().write( "pong " + (who == null ? "unknown" : who) );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<web-fragment
|
||||
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-fragment_3_1.xsd"
|
||||
version="3.1">
|
||||
|
||||
<name>FragmentA</name>
|
||||
|
||||
<ordering>
|
||||
<after><others/></after>
|
||||
</ordering>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>Ping</servlet-name>
|
||||
<servlet-class>org.eclipse.jetty.its.jetty_run_mojo_it.PingServlet</servlet-class>
|
||||
<init-param>
|
||||
<param-name>extra1</param-name><param-value>123</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>extra2</param-name><param-value>345</param-value>
|
||||
</init-param>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>Ping</servlet-name>
|
||||
<url-pattern>/ping</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
|
||||
</web-fragment>
|
|
@ -0,0 +1,93 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-project</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>jetty-simple-webapp</artifactId>
|
||||
<packaging>war</packaging>
|
||||
|
||||
<name>Jetty :: Simple :: Webapp</name>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-base</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-client</artifactId>
|
||||
<version>@project.version@</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>${maven-war-plugin-version}</version>
|
||||
<configuration>
|
||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.20</version>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<jetty.runPort>@jetty.runPort@</jetty.runPort>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>start-jetty</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<nonBlocking>true</nonBlocking>
|
||||
<httpConnector>
|
||||
<port>@jetty.runPort@</port>
|
||||
</httpConnector>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0"?>
|
||||
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
|
||||
version="3.1">
|
||||
<display-name>Jetty Simple Webapp run-mojo-it</display-name>
|
||||
</web-app>
|
|
@ -0,0 +1,59 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2017 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.its.jetty_run_mojo_it;
|
||||
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class TestHelloServlet
|
||||
{
|
||||
@Test
|
||||
public void hello_servlet()
|
||||
throws Exception
|
||||
{
|
||||
int port = Integer.getInteger( "jetty.runPort" );
|
||||
System.out.println( "port used:" + port );
|
||||
HttpClient httpClient = new HttpClient();
|
||||
try
|
||||
{
|
||||
httpClient.start();
|
||||
|
||||
String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
|
||||
|
||||
System.out.println( "httpResponse:" + response );
|
||||
|
||||
Assert.assertEquals( "hello beer", response.trim() );
|
||||
|
||||
response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
|
||||
|
||||
System.out.println( "httpResponse:" + response );
|
||||
|
||||
Assert.assertEquals( "pong beer", response.trim() );
|
||||
}
|
||||
finally
|
||||
{
|
||||
httpClient.stop();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-project</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Jetty :: Simple</name>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<maven-war-plugin-version>3.0.0</maven-war-plugin-version>
|
||||
<jetty.version>@project.version@</jetty.version>
|
||||
</properties>
|
||||
|
||||
<modules>
|
||||
<module>jetty-simple-base</module>
|
||||
<module>jetty-simple-webapp</module>
|
||||
</modules>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-base</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<type>jar</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.21</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<target>1.8</target>
|
||||
<source>1.8</source>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,2 @@
|
|||
invoker.goals = verify
|
||||
#test-compile failsafe:integration-test
|
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-war-exploded-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-project</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>jetty-simple-base</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Jetty :: Simple :: Base</name>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<type>jar</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.toolchain</groupId>
|
||||
<artifactId>jetty-perf-helper</artifactId>
|
||||
<version>1.0.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.8.1</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,45 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2017 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.its.jetty_run_mojo_it;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@WebServlet("/hello")
|
||||
public class HelloServlet
|
||||
extends HttpServlet
|
||||
{
|
||||
|
||||
@Override
|
||||
protected void doGet( HttpServletRequest req, HttpServletResponse resp )
|
||||
throws ServletException, IOException
|
||||
{
|
||||
String who = req.getParameter( "name" );
|
||||
|
||||
resp.getWriter().write( "hello " + (who == null ? "unknown" : who) );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2017 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.its.jetty_run_mojo_it;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
public class PingServlet
|
||||
extends HttpServlet
|
||||
{
|
||||
|
||||
@Override
|
||||
protected void doGet( HttpServletRequest req, HttpServletResponse resp )
|
||||
throws ServletException, IOException
|
||||
{
|
||||
String who = req.getParameter( "name" );
|
||||
|
||||
resp.getWriter().write( "pong " + (who == null ? "unknown" : who) );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<web-fragment
|
||||
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-fragment_3_1.xsd"
|
||||
version="3.1">
|
||||
|
||||
<name>FragmentA</name>
|
||||
|
||||
<ordering>
|
||||
<after><others/></after>
|
||||
</ordering>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>Ping</servlet-name>
|
||||
<servlet-class>org.eclipse.jetty.its.jetty_run_mojo_it.PingServlet</servlet-class>
|
||||
<init-param>
|
||||
<param-name>extra1</param-name><param-value>123</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>extra2</param-name><param-value>345</param-value>
|
||||
</init-param>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>Ping</servlet-name>
|
||||
<url-pattern>/ping</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
|
||||
</web-fragment>
|
|
@ -0,0 +1,121 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-war-exploded-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-project</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>jetty-simple-webapp</artifactId>
|
||||
<packaging>war</packaging>
|
||||
|
||||
<name>Jetty :: Simple :: Webapp</name>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-war-exploded-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-base</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-client</artifactId>
|
||||
<version>@project.version@</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>${maven-war-plugin-version}</version>
|
||||
<configuration>
|
||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.20</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
<systemPropertyVariables>
|
||||
<jetty.runPort>@jetty.runPort@</jetty.runPort>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>2.20</version>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<jetty.runPort>@jetty.runPort@</jetty.runPort>
|
||||
</systemPropertyVariables>
|
||||
<includes>
|
||||
<include>**/*TestHelloServlet*</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>integration-test</id>
|
||||
<goals>
|
||||
<goal>integration-test</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>verify</id>
|
||||
<goals>
|
||||
<goal>verify</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>start-jetty</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals>
|
||||
<goal>run-exploded</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<nonBlocking>true</nonBlocking>
|
||||
<httpConnector>
|
||||
<port>@jetty.runPort@</port>
|
||||
</httpConnector>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0"?>
|
||||
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
|
||||
version="3.1">
|
||||
<display-name>Jetty Simple Webapp run-mojo-it</display-name>
|
||||
</web-app>
|
|
@ -0,0 +1,59 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2017 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.its.jetty_run_mojo_it;
|
||||
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class TestHelloServlet
|
||||
{
|
||||
@Test
|
||||
public void hello_servlet()
|
||||
throws Exception
|
||||
{
|
||||
int port = Integer.getInteger( "jetty.runPort" );
|
||||
System.out.println( "port used:" + port );
|
||||
HttpClient httpClient = new HttpClient();
|
||||
try
|
||||
{
|
||||
httpClient.start();
|
||||
|
||||
String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
|
||||
|
||||
System.out.println( "httpResponse:" + response );
|
||||
|
||||
Assert.assertEquals( "hello beer", response.trim() );
|
||||
|
||||
response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
|
||||
|
||||
System.out.println( "httpResponse:" + response );
|
||||
|
||||
Assert.assertEquals( "pong beer", response.trim() );
|
||||
}
|
||||
finally
|
||||
{
|
||||
httpClient.stop();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-war-exploded-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-project</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Jetty :: Simple</name>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<maven-war-plugin-version>3.0.0</maven-war-plugin-version>
|
||||
<jetty.version>@project.version@</jetty.version>
|
||||
</properties>
|
||||
|
||||
<modules>
|
||||
<module>jetty-simple-base</module>
|
||||
<module>jetty-simple-webapp</module>
|
||||
</modules>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-war-exploded-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-base</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<type>jar</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.21</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<target>1.8</target>
|
||||
<source>1.8</source>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,2 @@
|
|||
invoker.goals = verify
|
||||
#test-compile failsafe:integration-test
|
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-war-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-project</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>jetty-simple-base</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Jetty :: Simple :: Base</name>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<type>jar</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.toolchain</groupId>
|
||||
<artifactId>jetty-perf-helper</artifactId>
|
||||
<version>1.0.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.8.1</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,45 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2017 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.its.jetty_run_mojo_it;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@WebServlet("/hello")
|
||||
public class HelloServlet
|
||||
extends HttpServlet
|
||||
{
|
||||
|
||||
@Override
|
||||
protected void doGet( HttpServletRequest req, HttpServletResponse resp )
|
||||
throws ServletException, IOException
|
||||
{
|
||||
String who = req.getParameter( "name" );
|
||||
|
||||
resp.getWriter().write( "hello " + (who == null ? "unknown" : who) );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2017 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.its.jetty_run_mojo_it;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
public class PingServlet
|
||||
extends HttpServlet
|
||||
{
|
||||
|
||||
@Override
|
||||
protected void doGet( HttpServletRequest req, HttpServletResponse resp )
|
||||
throws ServletException, IOException
|
||||
{
|
||||
String who = req.getParameter( "name" );
|
||||
|
||||
resp.getWriter().write( "pong " + (who == null ? "unknown" : who) );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<web-fragment
|
||||
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-fragment_3_1.xsd"
|
||||
version="3.1">
|
||||
|
||||
<name>FragmentA</name>
|
||||
|
||||
<ordering>
|
||||
<after><others/></after>
|
||||
</ordering>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>Ping</servlet-name>
|
||||
<servlet-class>org.eclipse.jetty.its.jetty_run_mojo_it.PingServlet</servlet-class>
|
||||
<init-param>
|
||||
<param-name>extra1</param-name><param-value>123</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>extra2</param-name><param-value>345</param-value>
|
||||
</init-param>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>Ping</servlet-name>
|
||||
<url-pattern>/ping</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
|
||||
</web-fragment>
|
|
@ -0,0 +1,121 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-war-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-project</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>jetty-simple-webapp</artifactId>
|
||||
<packaging>war</packaging>
|
||||
|
||||
<name>Jetty :: Simple :: Webapp</name>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-war-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-base</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-client</artifactId>
|
||||
<version>@project.version@</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>${maven-war-plugin-version}</version>
|
||||
<configuration>
|
||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.20</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
<systemPropertyVariables>
|
||||
<jetty.runPort>@jetty.runPort@</jetty.runPort>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>2.20</version>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<jetty.runPort>@jetty.runPort@</jetty.runPort>
|
||||
</systemPropertyVariables>
|
||||
<includes>
|
||||
<include>**/*TestHelloServlet*</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>integration-test</id>
|
||||
<goals>
|
||||
<goal>integration-test</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>verify</id>
|
||||
<goals>
|
||||
<goal>verify</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>start-jetty</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals>
|
||||
<goal>run-war</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<nonBlocking>true</nonBlocking>
|
||||
<httpConnector>
|
||||
<port>@jetty.runPort@</port>
|
||||
</httpConnector>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0"?>
|
||||
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
|
||||
version="3.1">
|
||||
<display-name>Jetty Simple Webapp run-mojo-it</display-name>
|
||||
</web-app>
|
|
@ -0,0 +1,59 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2017 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.its.jetty_run_mojo_it;
|
||||
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class TestHelloServlet
|
||||
{
|
||||
@Test
|
||||
public void hello_servlet()
|
||||
throws Exception
|
||||
{
|
||||
int port = Integer.getInteger( "jetty.runPort" );
|
||||
System.out.println( "port used:" + port );
|
||||
HttpClient httpClient = new HttpClient();
|
||||
try
|
||||
{
|
||||
httpClient.start();
|
||||
|
||||
String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
|
||||
|
||||
System.out.println( "httpResponse:" + response );
|
||||
|
||||
Assert.assertEquals( "hello beer", response.trim() );
|
||||
|
||||
response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
|
||||
|
||||
System.out.println( "httpResponse:" + response );
|
||||
|
||||
Assert.assertEquals( "pong beer", response.trim() );
|
||||
}
|
||||
finally
|
||||
{
|
||||
httpClient.stop();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-war-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-project</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Jetty :: Simple</name>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<maven-war-plugin-version>3.0.0</maven-war-plugin-version>
|
||||
<jetty.version>@project.version@</jetty.version>
|
||||
</properties>
|
||||
|
||||
<modules>
|
||||
<module>jetty-simple-base</module>
|
||||
<module>jetty-simple-webapp</module>
|
||||
</modules>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-war-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-base</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<type>jar</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.21</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<target>1.8</target>
|
||||
<source>1.8</source>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -0,0 +1 @@
|
|||
invoker.goals = test
|
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.eclipse.jetty.its.jetty-start-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-project</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>jetty-simple-base</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Jetty :: Simple :: Base</name>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<type>jar</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.toolchain</groupId>
|
||||
<artifactId>jetty-perf-helper</artifactId>
|
||||
<version>1.0.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.8.1</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,45 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2017 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.its.jetty_run_mojo_it;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@WebServlet("/hello")
|
||||
public class HelloServlet
|
||||
extends HttpServlet
|
||||
{
|
||||
|
||||
@Override
|
||||
protected void doGet( HttpServletRequest req, HttpServletResponse resp )
|
||||
throws ServletException, IOException
|
||||
{
|
||||
String who = req.getParameter( "name" );
|
||||
|
||||
resp.getWriter().write( "hello " + (who == null ? "unknown" : who) );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2017 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.its.jetty_run_mojo_it;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
public class PingServlet
|
||||
extends HttpServlet
|
||||
{
|
||||
|
||||
@Override
|
||||
protected void doGet( HttpServletRequest req, HttpServletResponse resp )
|
||||
throws ServletException, IOException
|
||||
{
|
||||
String who = req.getParameter( "name" );
|
||||
|
||||
resp.getWriter().write( "pong " + (who == null ? "unknown" : who) );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<web-fragment
|
||||
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-fragment_3_1.xsd"
|
||||
version="3.1">
|
||||
|
||||
<name>FragmentA</name>
|
||||
|
||||
<ordering>
|
||||
<after><others/></after>
|
||||
</ordering>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>Ping</servlet-name>
|
||||
<servlet-class>org.eclipse.jetty.its.jetty_run_mojo_it.PingServlet</servlet-class>
|
||||
<init-param>
|
||||
<param-name>extra1</param-name><param-value>123</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>extra2</param-name><param-value>345</param-value>
|
||||
</init-param>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>Ping</servlet-name>
|
||||
<url-pattern>/ping</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
|
||||
</web-fragment>
|
|
@ -0,0 +1,92 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.eclipse.jetty.its.jetty-start-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-project</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>jetty-simple-webapp</artifactId>
|
||||
<packaging>war</packaging>
|
||||
|
||||
<name>Jetty :: Simple :: Webapp</name>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.its.jetty-start-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-base</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-client</artifactId>
|
||||
<version>@project.version@</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>${maven-war-plugin-version}</version>
|
||||
<configuration>
|
||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.20</version>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<jetty.runPort>@jetty.runPort@</jetty.runPort>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>start-jetty</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals>
|
||||
<goal>start</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<httpConnector>
|
||||
<port>@jetty.runPort@</port>
|
||||
</httpConnector>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0"?>
|
||||
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
|
||||
version="3.1">
|
||||
<display-name>Jetty Simple Webapp run-mojo-it</display-name>
|
||||
</web-app>
|
|
@ -0,0 +1,59 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2017 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.its.jetty_run_mojo_it;
|
||||
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class TestHelloServlet
|
||||
{
|
||||
@Test
|
||||
public void hello_servlet()
|
||||
throws Exception
|
||||
{
|
||||
int port = Integer.getInteger( "jetty.runPort" );
|
||||
System.out.println( "port used:" + port );
|
||||
HttpClient httpClient = new HttpClient();
|
||||
try
|
||||
{
|
||||
httpClient.start();
|
||||
|
||||
String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
|
||||
|
||||
System.out.println( "httpResponse:" + response );
|
||||
|
||||
Assert.assertEquals( "hello beer", response.trim() );
|
||||
|
||||
response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
|
||||
|
||||
System.out.println( "httpResponse:" + response );
|
||||
|
||||
Assert.assertEquals( "pong beer", response.trim() );
|
||||
}
|
||||
finally
|
||||
{
|
||||
httpClient.stop();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.eclipse.jetty.its.jetty-start-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-project</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Jetty :: Simple</name>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<maven-war-plugin-version>3.0.0</maven-war-plugin-version>
|
||||
<jetty.version>@project.version@</jetty.version>
|
||||
</properties>
|
||||
|
||||
<modules>
|
||||
<module>jetty-simple-base</module>
|
||||
<module>jetty-simple-webapp</module>
|
||||
</modules>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.its.jetty-start-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-base</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<type>jar</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.21</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<target>1.8</target>
|
||||
<source>1.8</source>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<settings>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>it-repo</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>local.central</id>
|
||||
<url>@localRepositoryUrl@</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>local.central</id>
|
||||
<url>@localRepositoryUrl@</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
</profile>
|
||||
</profiles>
|
||||
</settings>
|
|
@ -21,9 +21,13 @@ package org.eclipse.jetty.maven.plugin;
|
|||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Enumeration;
|
||||
|
@ -36,11 +40,14 @@ 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.plugins.annotations.Parameter;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
import org.eclipse.jetty.security.LoginService;
|
||||
import org.eclipse.jetty.server.NetworkConnector;
|
||||
import org.eclipse.jetty.server.RequestLog;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.ShutdownMonitor;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
||||
|
@ -272,10 +279,7 @@ public abstract class AbstractJettyMojo extends AbstractMojo
|
|||
protected Thread consoleScanner;
|
||||
|
||||
protected ServerSupport serverSupport;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Determines whether or not the server blocks when started. The default
|
||||
|
@ -287,8 +291,9 @@ public abstract class AbstractJettyMojo extends AbstractMojo
|
|||
* If true, the server will not block the execution of subsequent code. This
|
||||
* is the behaviour of the jetty:start and default behaviour of the jetty:deploy goals.
|
||||
* </p>
|
||||
* @parameter default-value="false"
|
||||
*/
|
||||
protected boolean nonblocking = false;
|
||||
protected boolean nonBlocking = false;
|
||||
|
||||
|
||||
public abstract void restartWebApp(boolean reconfigureScanner) throws Exception;
|
||||
|
@ -429,11 +434,13 @@ public abstract class AbstractJettyMojo extends AbstractMojo
|
|||
// if a <httpConnector> was specified in the pom, use it
|
||||
if (httpConnector != null)
|
||||
{
|
||||
|
||||
// check that its port was set
|
||||
if (httpConnector.getPort() <= 0)
|
||||
{
|
||||
//use any jetty.http.port settings provided
|
||||
String tmp = System.getProperty(MavenServerConnector.PORT_SYSPROPERTY, System.getProperty("jetty.port", MavenServerConnector.DEFAULT_PORT_STR));
|
||||
String tmp = System.getProperty(MavenServerConnector.PORT_SYSPROPERTY, //
|
||||
System.getProperty("jetty.port", MavenServerConnector.DEFAULT_PORT_STR));
|
||||
httpConnector.setPort(Integer.parseInt(tmp.trim()));
|
||||
}
|
||||
httpConnector.setServer(server);
|
||||
|
@ -459,7 +466,7 @@ public abstract class AbstractJettyMojo extends AbstractMojo
|
|||
// start Jetty
|
||||
this.server.start();
|
||||
|
||||
getLog().info("Started Jetty Server");
|
||||
getLog().info( "Started Jetty Server" );
|
||||
|
||||
if ( dumpOnStart )
|
||||
{
|
||||
|
@ -478,10 +485,11 @@ public abstract class AbstractJettyMojo extends AbstractMojo
|
|||
startConsoleScanner();
|
||||
|
||||
// keep the thread going if not in daemon mode
|
||||
if (!nonblocking )
|
||||
if (!nonBlocking )
|
||||
{
|
||||
server.join();
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -489,7 +497,7 @@ public abstract class AbstractJettyMojo extends AbstractMojo
|
|||
}
|
||||
finally
|
||||
{
|
||||
if (!nonblocking )
|
||||
if (!nonBlocking )
|
||||
{
|
||||
getLog().info("Jetty server exiting.");
|
||||
}
|
||||
|
@ -504,7 +512,7 @@ public abstract class AbstractJettyMojo extends AbstractMojo
|
|||
ShutdownMonitor monitor = ShutdownMonitor.getInstance();
|
||||
monitor.setPort(stopPort);
|
||||
monitor.setKey(stopKey);
|
||||
monitor.setExitVm(!nonblocking);
|
||||
monitor.setExitVm(!nonBlocking );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ public class JettyDeployWar extends JettyRunWarMojo
|
|||
@Override
|
||||
public void execute() throws MojoExecutionException, MojoFailureException
|
||||
{
|
||||
nonblocking = daemon;
|
||||
nonBlocking = daemon;
|
||||
super.execute();
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ public class JettyDeployWar extends JettyRunWarMojo
|
|||
{
|
||||
super.finishConfigurationBeforeStart();
|
||||
//only stop the server at shutdown if we are blocking
|
||||
server.setStopAtShutdown(!nonblocking);
|
||||
server.setStopAtShutdown(!nonBlocking );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,17 @@
|
|||
|
||||
package org.eclipse.jetty.maven.plugin;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugin.MojoFailureException;
|
||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||
import org.eclipse.jetty.annotations.AnnotationConfiguration;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
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;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
|
@ -40,17 +51,6 @@ import java.util.Properties;
|
|||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugin.MojoFailureException;
|
||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||
import org.eclipse.jetty.annotations.AnnotationConfiguration;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* This goal is used to deploy your unassembled webapp into a forked JVM.
|
||||
|
@ -169,10 +169,17 @@ public class JettyRunForkedMojo extends JettyRunMojo
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* we o
|
||||
*/
|
||||
// protected MavenProject getProjectReferences( Artifact artifact, MavenProject project )
|
||||
// {
|
||||
//
|
||||
// return null;
|
||||
// }
|
||||
|
||||
/**
|
||||
* ConsoleStreamer
|
||||
*
|
||||
|
@ -349,7 +356,7 @@ public class JettyRunForkedMojo extends JettyRunMojo
|
|||
builder.directory(project.getBasedir());
|
||||
|
||||
if (PluginLog.getLog().isDebugEnabled())
|
||||
PluginLog.getLog().debug(Arrays.toString(cmd.toArray()));
|
||||
PluginLog.getLog().debug("Forked cli:"+Arrays.toString(cmd.toArray()));
|
||||
|
||||
PluginLog.getLog().info("Forked process starting");
|
||||
|
||||
|
@ -510,6 +517,19 @@ public class JettyRunForkedMojo extends JettyRunMojo
|
|||
props.put("testClasses.dir", webApp.getTestClasses().getAbsolutePath());
|
||||
}
|
||||
|
||||
if ( !webApp.getClassPathFiles().isEmpty() )
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for ( File dependency : webApp.getClassPathFiles() )
|
||||
{
|
||||
if (dependency.isDirectory())
|
||||
{
|
||||
stringBuilder.append( dependency.getCanonicalPath() ).append( '|' );
|
||||
}
|
||||
}
|
||||
props.put( "projects.classes.dir", stringBuilder.toString() );
|
||||
}
|
||||
|
||||
//web-inf lib
|
||||
List<File> deps = webApp.getWebInfLib();
|
||||
StringBuffer strbuff = new StringBuffer();
|
||||
|
@ -578,7 +598,7 @@ public class JettyRunForkedMojo extends JettyRunMojo
|
|||
List<Artifact> warArtifacts = new ArrayList<Artifact>();
|
||||
for ( Iterator<Artifact> iter = project.getArtifacts().iterator(); iter.hasNext(); )
|
||||
{
|
||||
Artifact artifact = (Artifact) iter.next();
|
||||
Artifact artifact = iter.next();
|
||||
|
||||
if (artifact.getType().equals("war"))
|
||||
warArtifacts.add(artifact);
|
||||
|
|
|
@ -40,6 +40,8 @@ import java.util.HashSet;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collector;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* This goal is used in-situ on a Maven project without first requiring that the project
|
||||
|
@ -222,7 +224,7 @@ public class JettyRunMojo extends AbstractJettyMojo
|
|||
{
|
||||
getLog().info("Reload Mechanic: " + reload );
|
||||
}
|
||||
|
||||
getLog().info( "nonBlocking:" + nonBlocking );
|
||||
|
||||
// check the classes to form a classpath with
|
||||
try
|
||||
|
@ -281,14 +283,22 @@ public class JettyRunMojo extends AbstractJettyMojo
|
|||
if (useTestScope && (testClassesDirectory != null))
|
||||
webApp.setTestClasses (testClassesDirectory);
|
||||
|
||||
webApp.getClassPathFiles().addAll( getDependencyProjects() );
|
||||
List<File> dependencyProjects = getDependencyProjects();
|
||||
webApp.getClassPathFiles().addAll( dependencyProjects );
|
||||
List<Resource> dependencyResources = //
|
||||
dependencyProjects.stream() //
|
||||
.map( file -> Resource.newResource( file ) ) //
|
||||
.collect( Collectors.toList() );
|
||||
webApp.getMetaData().getContainerResources().addAll( dependencyResources );
|
||||
webApp.setWebInfLib (getDependencyFiles());
|
||||
|
||||
// webApp.getWebInfLib().addAll( dependencyResources //
|
||||
// .stream() //
|
||||
// .map( resource -> toFile(resource) ) //
|
||||
// .collect( Collectors.toList() ) );
|
||||
webApp.getDependentProjects().addAll( dependencyResources );
|
||||
//get copy of a list of war artifacts
|
||||
Set<Artifact> matchedWarArtifacts = new HashSet<Artifact>();
|
||||
|
||||
|
||||
|
||||
//process any overlays and the war type artifacts
|
||||
List<Overlay> overlays = new ArrayList<Overlay>();
|
||||
for (OverlayConfig config:warPluginInfo.getMavenWarOverlayConfigs())
|
||||
|
@ -367,7 +377,17 @@ public class JettyRunMojo extends AbstractJettyMojo
|
|||
getLog().info("Webapp directory = " + webAppSourceDirectory.getCanonicalPath());
|
||||
}
|
||||
|
||||
|
||||
private static File toFile(Resource resource)
|
||||
{
|
||||
try
|
||||
{
|
||||
return resource.getFile();
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new RuntimeException( e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -566,7 +586,7 @@ public class JettyRunMojo extends AbstractJettyMojo
|
|||
*/
|
||||
private List<File> getDependencyFiles()
|
||||
{
|
||||
List<File> dependencyFiles = new ArrayList<File>();
|
||||
List<File> dependencyFiles = new ArrayList<>();
|
||||
for ( Iterator<Artifact> iter = projectArtifacts.iterator(); iter.hasNext(); )
|
||||
{
|
||||
Artifact artifact = iter.next();
|
||||
|
@ -596,7 +616,7 @@ public class JettyRunMojo extends AbstractJettyMojo
|
|||
|
||||
private List<File> getDependencyProjects()
|
||||
{
|
||||
List<File> dependencyFiles = new ArrayList<File>();
|
||||
List<File> dependencyFiles = new ArrayList<>();
|
||||
for ( Iterator<Artifact> iter = projectArtifacts.iterator(); iter.hasNext(); )
|
||||
{
|
||||
Artifact artifact = iter.next();
|
||||
|
@ -626,7 +646,7 @@ public class JettyRunMojo extends AbstractJettyMojo
|
|||
}
|
||||
|
||||
|
||||
private MavenProject getProjectReferences( Artifact artifact, MavenProject project )
|
||||
protected MavenProject getProjectReferences( Artifact artifact, MavenProject project )
|
||||
{
|
||||
if ( project.getProjectReferences() == null || project.getProjectReferences().isEmpty() )
|
||||
{
|
||||
|
@ -656,10 +676,10 @@ public class JettyRunMojo extends AbstractJettyMojo
|
|||
if (warArtifacts != null)
|
||||
return warArtifacts;
|
||||
|
||||
warArtifacts = new ArrayList<Artifact>();
|
||||
warArtifacts = new ArrayList<>();
|
||||
for ( Iterator<Artifact> iter = projectArtifacts.iterator(); iter.hasNext(); )
|
||||
{
|
||||
Artifact artifact = (Artifact) iter.next();
|
||||
Artifact artifact = iter.next();
|
||||
if (artifact.getType().equals("war") || artifact.getType().equals("zip"))
|
||||
{
|
||||
try
|
||||
|
|
|
@ -61,6 +61,10 @@ public class JettyRunWarMojo extends AbstractJettyMojo
|
|||
*/
|
||||
public void execute() throws MojoExecutionException, MojoFailureException
|
||||
{
|
||||
if ( !"war".equals( project.getPackaging() ) || skip )
|
||||
{
|
||||
return;
|
||||
}
|
||||
super.execute();
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ public class JettyStartMojo extends JettyRunMojo
|
|||
@Override
|
||||
public void execute() throws MojoExecutionException, MojoFailureException
|
||||
{
|
||||
nonblocking = true; //ensure that starting jetty won't hold up the thread
|
||||
nonBlocking = true; //ensure that starting jetty won't hold up the thread
|
||||
super.execute();
|
||||
}
|
||||
|
||||
|
|
|
@ -104,9 +104,7 @@ public class JettyWebAppContext extends WebAppContext
|
|||
private Resource _quickStartWebXml;
|
||||
private String _originAttribute;
|
||||
private boolean _generateOrigin;
|
||||
|
||||
|
||||
|
||||
private List<Resource> dependentProjects = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Set the "org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern" with a pattern for matching jars on
|
||||
|
@ -321,6 +319,11 @@ public class JettyWebAppContext extends WebAppContext
|
|||
{
|
||||
return _webInfJars;
|
||||
}
|
||||
|
||||
public List<Resource> getDependentProjects()
|
||||
{
|
||||
return dependentProjects;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void setGenerateQuickStart (boolean quickStart)
|
||||
|
|
|
@ -270,6 +270,11 @@ public class MavenServerConnector extends ContainerLifeCycle implements Connecto
|
|||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public int getLocalPort()
|
||||
{
|
||||
return this.delegate.getLocalPort();
|
||||
}
|
||||
|
||||
private void checkDelegate() throws IllegalStateException
|
||||
{
|
||||
|
|
|
@ -93,6 +93,8 @@ public class MavenWebInfConfiguration extends WebInfConfiguration
|
|||
public void preConfigure(WebAppContext context) throws Exception
|
||||
{
|
||||
super.preConfigure(context);
|
||||
((JettyWebAppContext)context).getDependentProjects()
|
||||
.stream().forEach( resource -> context.getMetaData().addWebInfJar( resource ) );
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -164,7 +164,7 @@ public class ServerSupport
|
|||
if (server == null)
|
||||
return null;
|
||||
|
||||
return (ContextHandlerCollection)server.getChildHandlerByClass(ContextHandlerCollection.class);
|
||||
return server.getChildHandlerByClass(ContextHandlerCollection.class);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,9 @@ import java.io.File;
|
|||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
@ -30,6 +32,8 @@ import java.util.List;
|
|||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
|
@ -174,31 +178,31 @@ public class Starter
|
|||
|
||||
//apply a properties file that defines the things that we configure in the jetty:run plugin:
|
||||
// - the context path
|
||||
String str = (String)props.get("context.path");
|
||||
String str = props.getProperty("context.path");
|
||||
if (str != null)
|
||||
webApp.setContextPath(str);
|
||||
|
||||
|
||||
// - web.xml
|
||||
str = (String)props.get("web.xml");
|
||||
str = props.getProperty("web.xml");
|
||||
if (str != null)
|
||||
webApp.setDescriptor(str);
|
||||
|
||||
str = (String)props.get("quickstart.web.xml");
|
||||
str = props.getProperty("quickstart.web.xml");
|
||||
if (str != null)
|
||||
webApp.setQuickStartWebDescriptor(Resource.newResource(new File(str)));
|
||||
|
||||
// - the tmp directory
|
||||
str = (String)props.getProperty("tmp.dir");
|
||||
str = props.getProperty("tmp.dir");
|
||||
if (str != null)
|
||||
webApp.setTempDirectory(new File(str.trim()));
|
||||
|
||||
str = (String)props.getProperty("tmp.dir.persist");
|
||||
str = props.getProperty("tmp.dir.persist");
|
||||
if (str != null)
|
||||
webApp.setPersistTempDirectory(Boolean.valueOf(str));
|
||||
|
||||
//Get the calculated base dirs which includes the overlays
|
||||
str = (String)props.getProperty("base.dirs");
|
||||
str = props.getProperty("base.dirs");
|
||||
if (str != null && !"".equals(str.trim()))
|
||||
{
|
||||
ResourceCollection bases = new ResourceCollection(StringUtil.csvSplit(str));
|
||||
|
@ -207,7 +211,7 @@ public class Starter
|
|||
}
|
||||
|
||||
//Get the original base dirs without the overlays
|
||||
str = (String)props.get("base.dirs.orig");
|
||||
str = props.getProperty("base.dirs.orig");
|
||||
if (str != null && !"".equals(str.trim()))
|
||||
{
|
||||
ResourceCollection bases = new ResourceCollection(StringUtil.csvSplit(str));
|
||||
|
@ -215,9 +219,9 @@ public class Starter
|
|||
}
|
||||
|
||||
//For overlays
|
||||
str = (String)props.getProperty("maven.war.includes");
|
||||
str = props.getProperty("maven.war.includes");
|
||||
List<String> defaultWarIncludes = fromCSV(str);
|
||||
str = (String)props.getProperty("maven.war.excludes");
|
||||
str = props.getProperty("maven.war.excludes");
|
||||
List<String> defaultWarExcludes = fromCSV(str);
|
||||
|
||||
//List of war artifacts
|
||||
|
@ -246,7 +250,7 @@ public class Starter
|
|||
Set<Artifact> matchedWars = new HashSet<Artifact>();
|
||||
|
||||
//process any overlays and the war type artifacts
|
||||
List<Overlay> overlays = new ArrayList<Overlay>();
|
||||
List<Overlay> overlays = new ArrayList<>();
|
||||
for (OverlayConfig config:orderedConfigs.values())
|
||||
{
|
||||
//overlays can be individually skipped
|
||||
|
@ -288,21 +292,20 @@ public class Starter
|
|||
|
||||
|
||||
// - the equivalent of web-inf classes
|
||||
str = (String)props.getProperty("classes.dir");
|
||||
str = props.getProperty("classes.dir");
|
||||
if (str != null && !"".equals(str.trim()))
|
||||
{
|
||||
webApp.setClasses(new File(str));
|
||||
}
|
||||
|
||||
str = (String)props.getProperty("testClasses.dir");
|
||||
str = props.getProperty("testClasses.dir");
|
||||
if (str != null && !"".equals(str.trim()))
|
||||
{
|
||||
webApp.setTestClasses(new File(str));
|
||||
}
|
||||
|
||||
|
||||
// - the equivalent of web-inf lib
|
||||
str = (String)props.getProperty("lib.jars");
|
||||
str = props.getProperty("lib.jars");
|
||||
if (str != null && !"".equals(str.trim()))
|
||||
{
|
||||
List<File> jars = new ArrayList<File>();
|
||||
|
@ -311,6 +314,15 @@ public class Starter
|
|||
jars.add(new File(names[j].trim()));
|
||||
webApp.setWebInfLib(jars);
|
||||
}
|
||||
|
||||
str = props.getProperty( "projects.classes.dir" );
|
||||
if (str != null && !"".equals(str.trim()))
|
||||
{
|
||||
List<File> classesDirectories = //
|
||||
Arrays.stream(str.split( Pattern.quote("|") )) //
|
||||
.map( s -> Paths.get( s).toFile() ).collect( Collectors.toList() );
|
||||
webApp.getWebInfLib().addAll( classesDirectories );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@ import org.eclipse.jetty.client.HttpClient;
|
|||
import org.eclipse.jetty.client.ProtocolHandlers;
|
||||
import org.eclipse.jetty.client.api.Request;
|
||||
import org.eclipse.jetty.client.api.Response;
|
||||
import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP;
|
||||
import org.eclipse.jetty.http.HttpField;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.HttpHeaderValue;
|
||||
|
@ -257,9 +258,14 @@ public abstract class AbstractProxyServlet extends HttpServlet
|
|||
* <td>HttpClient's default</td>
|
||||
* <td>The response buffer size, see {@link HttpClient#setResponseBufferSize(int)}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>selectors</td>
|
||||
* <td>cores / 2</td>
|
||||
* <td>The number of NIO selectors used by {@link HttpClient}</td>
|
||||
* </tr>
|
||||
* </tbody>
|
||||
* </table>
|
||||
*
|
||||
* @see #newHttpClient()
|
||||
* @return a {@link HttpClient} configured from the {@link #getServletConfig() servlet configuration}
|
||||
* @throws ServletException if the {@link HttpClient} cannot be created
|
||||
*/
|
||||
|
@ -340,11 +346,17 @@ public abstract class AbstractProxyServlet extends HttpServlet
|
|||
}
|
||||
|
||||
/**
|
||||
* The servlet init parameter 'selectors' can be set for the number of
|
||||
* selector threads to be used by the HttpClient.
|
||||
* @return a new HttpClient instance
|
||||
*/
|
||||
protected HttpClient newHttpClient()
|
||||
{
|
||||
return new HttpClient();
|
||||
int selectors = Math.max(1, Runtime.getRuntime().availableProcessors() / 2);
|
||||
String value = getServletConfig().getInitParameter("selectors");
|
||||
if (value != null)
|
||||
selectors = Integer.parseInt(value);
|
||||
return new HttpClient(new HttpClientTransportOverHTTP(selectors),null);
|
||||
}
|
||||
|
||||
protected HttpClient getHttpClient()
|
||||
|
|
|
@ -266,7 +266,7 @@ public class ServerConnector extends AbstractNetworkConnector
|
|||
* <p>Use it with xinetd/inetd, to launch an instance of Jetty on demand. The port
|
||||
* used to access pages on the Jetty instance is the same as the port used to
|
||||
* launch Jetty.</p>
|
||||
*
|
||||
* @see ServerConnector#openAcceptChannel()
|
||||
* @param inheritChannel whether this connector uses a channel inherited from the JVM.
|
||||
*/
|
||||
public void setInheritChannel(boolean inheritChannel)
|
||||
|
@ -274,41 +274,67 @@ public class ServerConnector extends AbstractNetworkConnector
|
|||
_inheritChannel = inheritChannel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the connector using the passed ServerSocketChannel.
|
||||
* This open method can be called before starting the connector to pass it a ServerSocketChannel
|
||||
* that will be used instead of one returned from {@link #openAcceptChannel()}
|
||||
* @param acceptChannel the channel to use
|
||||
* @throws IOException
|
||||
*/
|
||||
public void open(ServerSocketChannel acceptChannel) throws IOException
|
||||
{
|
||||
if (isStarted())
|
||||
throw new IllegalStateException(getState());
|
||||
updateBean(_acceptChannel,acceptChannel);
|
||||
_acceptChannel = acceptChannel;
|
||||
_localPort = _acceptChannel.socket().getLocalPort();
|
||||
if (_localPort <= 0)
|
||||
throw new IOException("Server channel not bound");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() throws IOException
|
||||
{
|
||||
if (_acceptChannel == null)
|
||||
{
|
||||
ServerSocketChannel serverChannel = null;
|
||||
if (isInheritChannel())
|
||||
{
|
||||
Channel channel = System.inheritedChannel();
|
||||
if (channel instanceof ServerSocketChannel)
|
||||
serverChannel = (ServerSocketChannel)channel;
|
||||
else
|
||||
LOG.warn("Unable to use System.inheritedChannel() [{}]. Trying a new ServerSocketChannel at {}:{}", channel, getHost(), getPort());
|
||||
}
|
||||
|
||||
if (serverChannel == null)
|
||||
{
|
||||
serverChannel = ServerSocketChannel.open();
|
||||
|
||||
InetSocketAddress bindAddress = getHost() == null ? new InetSocketAddress(getPort()) : new InetSocketAddress(getHost(), getPort());
|
||||
serverChannel.socket().setReuseAddress(getReuseAddress());
|
||||
serverChannel.socket().bind(bindAddress, getAcceptQueueSize());
|
||||
|
||||
_localPort = serverChannel.socket().getLocalPort();
|
||||
if (_localPort <= 0)
|
||||
throw new IOException("Server channel not bound");
|
||||
}
|
||||
|
||||
serverChannel.configureBlocking(true);
|
||||
addBean(serverChannel);
|
||||
|
||||
_acceptChannel = serverChannel;
|
||||
_acceptChannel = openAcceptChannel();
|
||||
_acceptChannel.configureBlocking(true);
|
||||
_localPort = _acceptChannel.socket().getLocalPort();
|
||||
if (_localPort <= 0)
|
||||
throw new IOException("Server channel not bound");
|
||||
addBean(_acceptChannel);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by {@link #open()} to obtain the accepting channel.
|
||||
* @return ServerSocketChannel used to accept connections.
|
||||
* @throws IOException
|
||||
*/
|
||||
protected ServerSocketChannel openAcceptChannel() throws IOException
|
||||
{
|
||||
ServerSocketChannel serverChannel = null;
|
||||
if (isInheritChannel())
|
||||
{
|
||||
Channel channel = System.inheritedChannel();
|
||||
if (channel instanceof ServerSocketChannel)
|
||||
serverChannel = (ServerSocketChannel)channel;
|
||||
else
|
||||
LOG.warn("Unable to use System.inheritedChannel() [{}]. Trying a new ServerSocketChannel at {}:{}", channel, getHost(), getPort());
|
||||
}
|
||||
|
||||
if (serverChannel == null)
|
||||
{
|
||||
serverChannel = ServerSocketChannel.open();
|
||||
|
||||
InetSocketAddress bindAddress = getHost() == null ? new InetSocketAddress(getPort()) : new InetSocketAddress(getHost(), getPort());
|
||||
serverChannel.socket().setReuseAddress(getReuseAddress());
|
||||
serverChannel.socket().bind(bindAddress, getAcceptQueueSize());
|
||||
}
|
||||
|
||||
return serverChannel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Future<Void> shutdown()
|
||||
{
|
||||
|
|
|
@ -32,9 +32,11 @@ import java.io.InputStream;
|
|||
import java.io.PrintWriter;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.channels.ServerSocketChannel;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
@ -52,8 +54,11 @@ import org.eclipse.jetty.toolchain.test.OS;
|
|||
import org.eclipse.jetty.util.IO;
|
||||
import org.eclipse.jetty.util.log.StacklessLogging;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
public class ServerConnectorTest
|
||||
{
|
||||
public static class ReuseInfoHandler extends AbstractHandler
|
||||
|
@ -265,5 +270,39 @@ public class ServerConnectorTest
|
|||
{
|
||||
server.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOpenWithServerSocketChannel() throws Exception
|
||||
{
|
||||
Server server = new Server();
|
||||
ServerConnector connector = new ServerConnector(server);
|
||||
server.addConnector(connector);
|
||||
|
||||
ServerSocketChannel channel = ServerSocketChannel.open();
|
||||
channel.bind(new InetSocketAddress(0));
|
||||
|
||||
assertTrue(channel.isOpen());
|
||||
int port = channel.socket().getLocalPort();
|
||||
assertThat(port,greaterThan(0));
|
||||
|
||||
connector.open(channel);
|
||||
|
||||
assertThat(connector.getLocalPort(),is(port));
|
||||
|
||||
server.start();
|
||||
|
||||
assertThat(connector.getLocalPort(),is(port));
|
||||
assertThat(connector.getTransport(),is(channel));
|
||||
|
||||
server.stop();
|
||||
|
||||
assertThat(connector.getTransport(),Matchers.nullValue());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.eclipse.jetty.servlet;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
|
@ -231,10 +232,7 @@ public class DefaultServletTest
|
|||
createFile(index, "<h1>Hello Index</h1>");
|
||||
|
||||
File wackyDir = new File(resBase, "dir?");
|
||||
if (!OS.IS_WINDOWS)
|
||||
{
|
||||
FS.ensureDirExists(wackyDir);
|
||||
}
|
||||
assumeTrue("FileSystem should support question dirs", wackyDir.mkdirs());
|
||||
|
||||
wackyDir = new File(resBase, "dir;");
|
||||
assertTrue(wackyDir.mkdirs());
|
||||
|
@ -266,13 +264,8 @@ public class DefaultServletTest
|
|||
response = connector.getResponse("GET /context/dir?/ HTTP/1.0\r\n\r\n");
|
||||
assertResponseContains("404", response);
|
||||
|
||||
if (!OS.IS_WINDOWS)
|
||||
{
|
||||
response = connector.getResponse("GET /context/dir%3F/ HTTP/1.0\r\n\r\n");
|
||||
assertResponseContains("Directory: /context/dir?/<", response);
|
||||
}
|
||||
else
|
||||
assertResponseContains("404", response);
|
||||
response = connector.getResponse("GET /context/dir%3F/ HTTP/1.0\r\n\r\n");
|
||||
assertResponseContains("Directory: /context/dir?/<", response);
|
||||
|
||||
response = connector.getResponse("GET /context/index.html HTTP/1.0\r\n\r\n");
|
||||
assertResponseContains("Hello Index", response);
|
||||
|
@ -421,7 +414,8 @@ public class DefaultServletTest
|
|||
context.setBaseResource(Resource.newResource(resBase));
|
||||
|
||||
File dir = new File(resBase, "dir?");
|
||||
assertTrue(dir.mkdirs());
|
||||
assumeTrue("FileSystem should support question dirs", dir.mkdirs());
|
||||
|
||||
File index = new File(dir, "index.html");
|
||||
createFile(index, "<h1>Hello Index</h1>");
|
||||
|
||||
|
@ -437,7 +431,6 @@ public class DefaultServletTest
|
|||
response = connector.getResponse("GET /context/dir%3F/ HTTP/1.0\r\n\r\n");
|
||||
assertResponseContains("Location: http://0.0.0.0/context/dir%3F/index.html", response);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testWelcomeServlet() throws Exception
|
||||
|
|
|
@ -19,6 +19,12 @@
|
|||
package org.eclipse.jetty.util;
|
||||
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
|
@ -35,12 +41,6 @@ import org.junit.Assert;
|
|||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class BufferUtilTest
|
||||
{
|
||||
@Test
|
||||
|
@ -346,7 +346,7 @@ public class BufferUtilTest
|
|||
String data="Now is the time for all good men to come to the aid of the party";
|
||||
File file = File.createTempFile("test",".txt");
|
||||
file.deleteOnExit();
|
||||
try(FileWriter out = new FileWriter(file);)
|
||||
try(FileWriter out = new FileWriter(file))
|
||||
{
|
||||
out.write(data);
|
||||
}
|
||||
|
|
|
@ -37,7 +37,6 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import org.eclipse.jetty.toolchain.test.FS;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.util.resource.ResourceTest;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -182,9 +181,9 @@ public class RolloverFileOutputStreamTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFilehandling() throws Exception
|
||||
public void testFileHandling() throws Exception
|
||||
{
|
||||
File testDir = MavenTestingUtils.getTargetTestingDir(ResourceTest.class.getName());
|
||||
File testDir = MavenTestingUtils.getTargetTestingDir(RolloverFileOutputStreamTest.class.getName() + "_testFileHandling");
|
||||
Path testPath = testDir.toPath();
|
||||
FS.ensureEmpty(testDir);
|
||||
|
||||
|
@ -290,7 +289,7 @@ public class RolloverFileOutputStreamTest
|
|||
@Test
|
||||
public void testRollover() throws Exception
|
||||
{
|
||||
File testDir = MavenTestingUtils.getTargetTestingDir(ResourceTest.class.getName());
|
||||
File testDir = MavenTestingUtils.getTargetTestingDir(RolloverFileOutputStreamTest.class.getName() + "_testRollover");
|
||||
FS.ensureEmpty(testDir);
|
||||
|
||||
ZoneId zone = toZoneId("Australia/Sydney");
|
||||
|
|
|
@ -19,14 +19,16 @@
|
|||
package org.eclipse.jetty.util;
|
||||
|
||||
|
||||
import org.eclipse.jetty.toolchain.test.JDK;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import org.eclipse.jetty.toolchain.test.JDK;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TypeUtilTest
|
||||
{
|
||||
@Test
|
||||
|
@ -129,18 +131,19 @@ public class TypeUtilTest
|
|||
public void testGetLocationOfClass() throws Exception
|
||||
{
|
||||
Path mavenRepoPath = Paths.get( System.getProperty( "mavenRepoPath" ) );
|
||||
String mavenRepo = mavenRepoPath.toFile().getPath();
|
||||
String mavenRepo = mavenRepoPath.toFile().getPath().replaceAll("\\\\", "/");
|
||||
|
||||
// Classes from maven dependencies
|
||||
Assert.assertThat(TypeUtil.getLocationOfClass(Assert.class).toASCIIString(),Matchers.containsString(mavenRepo));
|
||||
assertThat(TypeUtil.getLocationOfClass(Assert.class).toASCIIString(),containsString(mavenRepo));
|
||||
|
||||
// Class from project dependencies
|
||||
Assert.assertThat(TypeUtil.getLocationOfClass(TypeUtil.class).toASCIIString(),Matchers.containsString("/classes/"));
|
||||
assertThat(TypeUtil.getLocationOfClass(TypeUtil.class).toASCIIString(),containsString("/classes/"));
|
||||
|
||||
// Class from JVM core
|
||||
String expectedJavaBase = "/rt.jar";
|
||||
if(JDK.IS_9)
|
||||
expectedJavaBase = "/java.base/";
|
||||
|
||||
Assert.assertThat(TypeUtil.getLocationOfClass(String.class).toASCIIString(),Matchers.containsString(expectedJavaBase));
|
||||
assertThat(TypeUtil.getLocationOfClass(String.class).toASCIIString(),containsString(expectedJavaBase));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1404,13 +1404,12 @@ public class FileSystemResourceTest
|
|||
assumeTrue("Only windows supports UNC paths", OS.IS_WINDOWS);
|
||||
assumeFalse("FileResource does not support this test", _class.equals(FileResource.class));
|
||||
|
||||
try (Resource base = newResource(URI.create("file://127.0.0.1/path")))
|
||||
try (Resource base = newResource(URI.create("file:////127.0.0.1/path")))
|
||||
{
|
||||
Resource resource = base.addPath("WEB-INF/");
|
||||
assertThat("getURI()", resource.getURI().toASCIIString(), containsString("path/WEB-INF/"));
|
||||
assertThat("isAlias()", resource.isAlias(), is(true));
|
||||
assertThat("getAlias()", resource.getAlias(), notNullValue());
|
||||
assertThat("getAlias()", resource.getAlias().toASCIIString(), containsString("path/WEB-INF"));
|
||||
assertThat("isAlias()", resource.isAlias(), is(false));
|
||||
assertThat("getAlias()", resource.getAlias(), nullValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -196,8 +196,9 @@ public class ResourceTest
|
|||
|
||||
File testDir = MavenTestingUtils.getTargetTestingDir(ResourceTest.class.getName());
|
||||
FS.ensureEmpty(testDir);
|
||||
File tmpFile = File.createTempFile("test",null,testDir);
|
||||
|
||||
File tmpFile = new File(testDir, "test.tmp");
|
||||
FS.touch(tmpFile);
|
||||
|
||||
cases.addCase(new Data(tmpFile.toString(),EXISTS,!DIR));
|
||||
|
||||
// Some resource references.
|
||||
|
|
|
@ -43,7 +43,7 @@ import org.eclipse.jetty.util.log.Logger;
|
|||
import org.eclipse.jetty.util.resource.Resource;
|
||||
|
||||
/**
|
||||
* Classpath classes list performs sequential pattern matching of a class name
|
||||
* Classpath classes list performs pattern matching of a class name
|
||||
* against an internal array of classpath pattern entries.
|
||||
* A class pattern is a string of one of the forms:<ul>
|
||||
* <li>'org.package.SomeClass' will match a specific class
|
||||
|
|
|
@ -276,8 +276,7 @@ public class MetaInfConfiguration extends AbstractConfiguration
|
|||
if (LOG.isDebugEnabled()) LOG.debug(jar+" META-INF/web-fragment.xml checked");
|
||||
if (jar.isDirectory())
|
||||
{
|
||||
//TODO ????
|
||||
webFrag = jar.addPath("/META-INF/web-fragment.xml");
|
||||
webFrag = Resource.newResource( new File (jar.getFile(),"/META-INF/web-fragment.xml"));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -702,6 +702,10 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
|||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @deprecated Use {@link #getServerClasspathPattern()}.{@link ClasspathPattern#add(String)}
|
||||
* @param classOrPackageOrLocation pattern (see {@link ClasspathPattern}
|
||||
*/
|
||||
@Deprecated
|
||||
public void addServerClass(String classOrPackageOrLocation)
|
||||
{
|
||||
|
@ -713,13 +717,10 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
|||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Prepend to the list of Server classes.
|
||||
* @param classOrPackage A fully qualified class name (eg com.foo.MyClass)
|
||||
* or a qualified package name ending with '.' (eg com.foo.). If the class
|
||||
* or package has '-' it is excluded from the server classes and order is thus
|
||||
* important when added system class patterns. This argument may also be a comma
|
||||
* separated list of classOrPackage patterns.
|
||||
* @param classOrPackage A pattern.
|
||||
* @see #setServerClasses(String[])
|
||||
* @see <a href="http://www.eclipse.org/jetty/documentation/current/jetty-classloading.html">Jetty Documentation: Classloading</a>
|
||||
* @deprecated Use {@link #getServerClasspathPattern()}.{@link ClasspathPattern#add(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void prependServerClass(String classOrPackage)
|
||||
|
@ -757,6 +758,11 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
|||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
*
|
||||
* @param classOrPackage pattern
|
||||
* @deprecated Use {@link #getSystemClasspathPattern()}.{@link ClasspathPattern#add(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void addSystemClass(String classOrPackage)
|
||||
{
|
||||
|
@ -769,13 +775,10 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
|||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Prepend to the list of System classes.
|
||||
* @param classOrPackage A fully qualified class name (eg com.foo.MyClass)
|
||||
* or a qualified package name ending with '.' (eg com.foo.). If the class
|
||||
* or package has '-' it is excluded from the system classes and order is thus
|
||||
* important when added system class patterns.This argument may also be a comma
|
||||
* separated list of classOrPackage patterns.
|
||||
* @param classOrPackage A pattern.
|
||||
* @see #setSystemClasses(String[])
|
||||
* @see <a href="http://www.eclipse.org/jetty/documentation/current/jetty-classloading.html">Jetty Documentation: Classloading</a>
|
||||
* @deprecated Use {@link #getSystemClasspathPattern()}.{@link ClasspathPattern#add(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void prependSystemClass(String classOrPackage)
|
||||
|
@ -787,6 +790,11 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
|||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param name class name
|
||||
* @return true if matched by {@link #getServerClasspathPattern()}
|
||||
* @deprecated Use {@link #getServerClasspathPattern()}.{@link ClasspathPattern#match(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isServerClass(String name)
|
||||
{
|
||||
|
@ -797,6 +805,11 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
|||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param name class name
|
||||
* @return true if matched by {@link #getServerClasspathPattern()}
|
||||
* @deprecated Use {@link #getSystemClasspathPattern()}.{@link ClasspathPattern#match(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isSystemClass(String name)
|
||||
{
|
||||
|
|
|
@ -34,20 +34,14 @@ import javax.servlet.ServletException;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.client.ConnectionPool;
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.eclipse.jetty.client.HttpClientTransport;
|
||||
import org.eclipse.jetty.client.HttpDestination;
|
||||
import org.eclipse.jetty.client.LeakTrackingConnectionPool;
|
||||
import org.eclipse.jetty.client.Origin;
|
||||
import org.eclipse.jetty.client.api.Request;
|
||||
import org.eclipse.jetty.client.api.Response;
|
||||
import org.eclipse.jetty.client.api.Result;
|
||||
import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP;
|
||||
import org.eclipse.jetty.client.http.HttpDestinationOverHTTP;
|
||||
import org.eclipse.jetty.client.util.BytesContentProvider;
|
||||
import org.eclipse.jetty.fcgi.client.http.HttpClientTransportOverFCGI;
|
||||
import org.eclipse.jetty.fcgi.client.http.HttpDestinationOverFCGI;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.HttpMethod;
|
||||
import org.eclipse.jetty.io.ArrayByteBufferPool;
|
||||
|
@ -97,55 +91,31 @@ public class HttpClientLoadTest extends AbstractTest
|
|||
case HTTP:
|
||||
case HTTPS:
|
||||
{
|
||||
return new HttpClientTransportOverHTTP(1)
|
||||
HttpClientTransport clientTransport = new HttpClientTransportOverHTTP(1);
|
||||
clientTransport.setConnectionPoolFactory(destination -> new LeakTrackingConnectionPool(destination, client.getMaxConnectionsPerDestination(), destination)
|
||||
{
|
||||
@Override
|
||||
public HttpDestination newHttpDestination(Origin origin)
|
||||
protected void leaked(LeakDetector.LeakInfo leakInfo)
|
||||
{
|
||||
return new HttpDestinationOverHTTP(getHttpClient(), origin)
|
||||
{
|
||||
@Override
|
||||
protected ConnectionPool newConnectionPool(HttpClient client)
|
||||
{
|
||||
return new LeakTrackingConnectionPool(this, client.getMaxConnectionsPerDestination(), this)
|
||||
{
|
||||
@Override
|
||||
protected void leaked(LeakDetector.LeakInfo leakInfo)
|
||||
{
|
||||
super.leaked(leakInfo);
|
||||
connectionLeaks.incrementAndGet();
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
super.leaked(leakInfo);
|
||||
connectionLeaks.incrementAndGet();
|
||||
}
|
||||
};
|
||||
});
|
||||
return clientTransport;
|
||||
}
|
||||
case FCGI:
|
||||
{
|
||||
return new HttpClientTransportOverFCGI(1, false, "")
|
||||
HttpClientTransport clientTransport = new HttpClientTransportOverFCGI(1, false, "");
|
||||
clientTransport.setConnectionPoolFactory(destination -> new LeakTrackingConnectionPool(destination, client.getMaxConnectionsPerDestination(), destination)
|
||||
{
|
||||
@Override
|
||||
public HttpDestination newHttpDestination(Origin origin)
|
||||
protected void leaked(LeakDetector.LeakInfo leakInfo)
|
||||
{
|
||||
return new HttpDestinationOverFCGI(getHttpClient(), origin)
|
||||
{
|
||||
@Override
|
||||
protected ConnectionPool newConnectionPool(HttpClient client)
|
||||
{
|
||||
return new LeakTrackingConnectionPool(this, client.getMaxConnectionsPerDestination(), this)
|
||||
{
|
||||
@Override
|
||||
protected void leaked(LeakDetector.LeakInfo leakInfo)
|
||||
{
|
||||
super.leaked(leakInfo);
|
||||
connectionLeaks.incrementAndGet();
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
super.leaked(leakInfo);
|
||||
connectionLeaks.incrementAndGet();
|
||||
}
|
||||
};
|
||||
});
|
||||
return clientTransport;
|
||||
}
|
||||
default:
|
||||
{
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
<servlet-name>Fragment</servlet-name>
|
||||
<url-pattern>/fragment/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
|
||||
</web-fragment>
|
||||
|
||||
|
|
Loading…
Reference in New Issue