Jetty-12 Remove usage of HandlerList and reduce usage of Handler.Collection (#9191)
* Remove usage of HandlerList and reduce usage of Handler.Collection "The best part is no part" - Elon Musk! The overwhelming usage of `HandlerList` and `Handler.Collection` was for adding the `DefaultHandler` after the main handler. This PR adds a getter/setter for a `DefaultHandler` on the server, so we no longer need to always create a `Handler.Collection` structure. This has allowed the deprecated `HandlerList` and `HandlerWrapper` classes to be removed. In implementing this PR, several problems were found in the calculation of `InvocationType`, not least that it was assumed that an empty `Handler.Collection` was `BLOCKING`. When this issue was fixed, any dynamic addition of contexts (deployer or SPI server) failed as the `InvocationType` changed. So this PR also introduces the `isDynamic()` attribute of all `Handler.Container`s. A dynamic container will always return `BLOCKING` from `getInvocationType()`, as there is always a race with a new handler being added. A non-dynamic container will return a real `InvocationType`, calculated from its children, but it's mutator methods will ISE if contained handlers are changed. Signed-off-by: Simone Bordet <simone.bordet@gmail.com> Co-authored-by: Jan Bartel <janb@webtide.com> Co-authored-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
parent
53fc33161d
commit
39e5667f1d
|
@ -50,5 +50,5 @@ A filtering `Handler` is a handler that perform some modification to the request
|
|||
include::../../{doc_code}/org/eclipse/jetty/docs/programming/server/http/HTTPServerDocs.java[tags=handlerFilter]
|
||||
----
|
||||
|
||||
Note how a filtering `Handler` extends from `HandlerWrapper` and as such needs another handler to forward the request processing to, and how the two ``Handler``s needs to be linked together to work properly.
|
||||
Note how a filtering `Handler` extends from `Handler.Wrapper` and as such needs another handler to forward the request processing to, and how the two ``Handler``s needs to be linked together to work properly.
|
||||
|
||||
|
|
|
@ -70,14 +70,14 @@ Server
|
|||
|
||||
Server applications may need to deploy to Jetty more than one web application.
|
||||
|
||||
Recall from the xref:pg-server-http-handler[introduction] that Jetty offers `HandlerCollection` and `HandlerList` that may contain a sequence of children ``Handler``s.
|
||||
However, both of these have no knowledge of the concept of _context_ and just iterate through the sequence of ``Handler``s.
|
||||
Recall from the xref:pg-server-http-handler[introduction] that Jetty offers `Handler.Collection` that contains a sequence of child ``Handler``s.
|
||||
However, this has no knowledge of the concept of _context_ and just iterates through the sequence of ``Handler``s.
|
||||
|
||||
A better choice for multiple web application is `ContextHandlerCollection`, that matches a _context_ from either its _context path_ or _virtual host_, without iterating through the ``Handler``s.
|
||||
|
||||
If `ContextHandlerCollection` does not find a match, it just returns.
|
||||
If `ContextHandlerCollection` does not find a match, it just returns `false` from its `process(\...)` method.
|
||||
What happens next depends on the `Handler` tree structure: other ``Handler``s may be invoked after `ContextHandlerCollection`, for example `DefaultHandler` (see xref:pg-server-http-handler-use-util-default-handler[this section]).
|
||||
Eventually, if `Request.setHandled(true)` is not called, Jetty returns an HTTP `404` response to the client.
|
||||
Eventually, if no `Handler` returns `true` from their own `process(\...)` method, then Jetty returns an HTTP `404` response to the client.
|
||||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
|
@ -132,7 +132,7 @@ If you need to serve static resources from multiple directories:
|
|||
include::../../{doc_code}/org/eclipse/jetty/docs/programming/server/http/HTTPServerDocs.java[tags=multipleResourcesHandler]
|
||||
----
|
||||
|
||||
If the resource is not found, `ResourceHandler` will not call `Request.setHandled(true)` so what happens next depends on the `Handler` tree structure.
|
||||
If the resource is not found, `ResourceHandler` will not return `true` from the `process(\...)` method, so what happens next depends on the `Handler` tree structure.
|
||||
See also xref:pg-server-http-handler-use-util-default-handler[how to use] `DefaultHandler`.
|
||||
|
||||
[[pg-server-http-handler-use-util-gzip-handler]]
|
||||
|
@ -277,7 +277,7 @@ include::../../{doc_code}/org/eclipse/jetty/docs/programming/server/http/HTTPSer
|
|||
[[pg-server-http-handler-use-util-default-handler]]
|
||||
====== DefaultHandler
|
||||
|
||||
`DefaultHandler` is a terminal `Handler` that always calls `Request.setHandled(true)` and performs the following:
|
||||
`DefaultHandler` is a terminal `Handler` that always returns `true` from its `process(\...)` method and performs the following:
|
||||
|
||||
* Serves the `favicon.ico` Jetty icon when it is requested
|
||||
* Sends a HTTP `404` response for any other request
|
||||
|
@ -295,12 +295,11 @@ The `Handler` tree structure looks like the following:
|
|||
[source,screen]
|
||||
----
|
||||
Server
|
||||
└── HandlerList
|
||||
├── ContextHandlerCollection
|
||||
│ ├── ContextHandler 1
|
||||
│ :── ...
|
||||
│ └── ContextHandler N
|
||||
└── DefaultHandler
|
||||
├── ContextHandlerCollection
|
||||
│ ├── ContextHandler 1
|
||||
│ :── ...
|
||||
│ └── ContextHandler N
|
||||
└── DefaultHandler
|
||||
----
|
||||
|
||||
In the example above, `ContextHandlerCollection` will try to match a request to one of the contexts; if the match fails, `HandlerList` will call the next `Handler` which is `DefaultHandler` that will return a HTTP `404` with an HTML page showing the existing contexts deployed on the `Server`.
|
||||
|
@ -350,8 +349,8 @@ Note also how adding a `Servlet` or a `Filter` returns a _holder_ object that ca
|
|||
|
||||
When a request arrives to `ServletContextHandler` the request URI will be matched against the ``Filter``s and ``Servlet`` mappings and only those that match will process the request, as dictated by the Servlet specification.
|
||||
|
||||
IMPORTANT: `ServletContextHandler` is a terminal `Handler`, that is it always calls `Request.setHandled(true)` when invoked.
|
||||
Server applications must be careful when creating the `Handler` tree to put ``ServletContextHandler``s as last ``Handler``s in a `HandlerList` or as children of `ContextHandlerCollection`.
|
||||
IMPORTANT: `ServletContextHandler` is a terminal `Handler`, that is it always returns `true` from its `process(\...)` method when invoked.
|
||||
Server applications must be careful when creating the `Handler` tree to put ``ServletContextHandler``s as last ``Handler``s in any `Handler.Collection` or as children of a `ContextHandlerCollection`.
|
||||
|
||||
// TODO: revise what above, as ServletContextHandler is not a terminal handler.
|
||||
// TODO: introduce the fact that ServletContextHandler can have a class loader that may be used to "isolate" web application classes.
|
||||
|
|
|
@ -16,21 +16,15 @@
|
|||
|
||||
An `org.eclipse.jetty.server.Handler` is the component that processes incoming HTTP requests and eventually produces HTTP responses.
|
||||
|
||||
``Handler``s can be organized in different ways:
|
||||
``Handler``s can process the HTTP request themselves, or they can be ``Handler.Container``s that delegate HTTP request processing to one or more contained ``Handler``s.
|
||||
This allows ``Handler``s to be organised as a tree comprised of:
|
||||
|
||||
* in a sequence, where ``Handler``s are invoked one after the other
|
||||
** `HandlerCollection` invokes _all_ ``Handler``s one after the other
|
||||
** `HandlerList` invokes ``Handlers``s until one calls `Request.setHandled(true)` to indicate that the request has been handled and no further `Handler` should be invoked
|
||||
* nested, where one `Handler` invokes the next, nested, `Handler`
|
||||
** `HandlerWrapper` implements this behavior
|
||||
* Leaf ``Handler``s that return `true` from the `process(\...)` method, generate a response and succeed the `Callback`.
|
||||
* A `Handler.Wrapper` can be used to form a chain of ``Handler``s where request, response or callback objects are wrapped in the `process(\...)` method before being passed down the chain.
|
||||
* A `Handler.Collection` that contains a sequence of ``Handler``s, with each `Handler` being called in sequence until one returns `true` from its `process(\..)` method.
|
||||
* A specialized `Handler.Container` that may use properties of the request (for example, the URI, or a header, etc.) to select from one or more contained ``Handler``s to delegate the HTTP request processing to.
|
||||
|
||||
The `HandlerCollection` behavior (invoking _all_ handlers) is useful when for example the last `Handler` is a logging `Handler` that logs the request (that may have been modified by previous handlers).
|
||||
|
||||
The `HandlerList` behavior (invoking handlers up to the first that calls `Request.setHandled(true)`) is useful when each handler processes a different URIs or a different virtual hosts: ``Handler``s are invoked one after the other until one matches the URI or virtual host.
|
||||
|
||||
The nested behavior is useful to enrich the request with additional services such as HTTP session support (`SessionHandler`), or with specific behaviors dictated by the Servlet specification (`ServletHandler`).
|
||||
|
||||
``Handler``s can be organized in a tree by composing them together:
|
||||
A `Handler` tree is created by composing ``Handler``s together:
|
||||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
|
@ -42,7 +36,7 @@ The corresponding `Handler` tree structure looks like the following:
|
|||
[source,screen]
|
||||
----
|
||||
Server
|
||||
└── LoggingHandler
|
||||
└── GzipHandler
|
||||
└── Handler.Collection
|
||||
├── App1Handler
|
||||
└── App2Handler
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.eclipse.jetty.http.HttpHeader;
|
|||
import org.eclipse.jetty.http.HttpHeaderValue;
|
||||
import org.eclipse.jetty.http.HttpMethod;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.http.HttpURI;
|
||||
import org.eclipse.jetty.http2.server.HTTP2CServerConnectionFactory;
|
||||
import org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory;
|
||||
import org.eclipse.jetty.http3.server.HTTP3ServerConnectionFactory;
|
||||
|
@ -205,7 +206,7 @@ public class HTTPServerDocs
|
|||
ServletContextHandler otherContext = new ServletContextHandler();
|
||||
mainContext.setContextPath("/other");
|
||||
|
||||
server.setHandler(new HandlerList(requestLogHandler, otherContext));
|
||||
server.setHandler(new Handler.Collection(requestLogHandler, otherContext));
|
||||
*/
|
||||
// end::contextRequestLog[]
|
||||
}
|
||||
|
@ -505,14 +506,14 @@ public class HTTPServerDocs
|
|||
}
|
||||
|
||||
// tag::handlerTree[]
|
||||
// Create a Server instance.
|
||||
Server server = new Server();
|
||||
|
||||
LoggingHandler loggingHandler = new LoggingHandler();
|
||||
// Link the root Handler with the Server.
|
||||
server.setHandler(loggingHandler);
|
||||
GzipHandler gzipHandler = new GzipHandler();
|
||||
server.setHandler(gzipHandler);
|
||||
|
||||
Handler.Collection collection = new Handler.Collection();
|
||||
gzipHandler.setHandler(collection);
|
||||
|
||||
collection.addHandler(new App1Handler());
|
||||
collection.addHandler(new App2Handler());
|
||||
// end::handlerTree[]
|
||||
|
@ -582,29 +583,32 @@ public class HTTPServerDocs
|
|||
}
|
||||
|
||||
// tag::handlerFilter[]
|
||||
// TODO: This needs to be rewritten using a custom Processor
|
||||
/*
|
||||
class FilterHandler extends HandlerWrapper
|
||||
class FilterHandler extends Handler.Wrapper
|
||||
{
|
||||
@Override
|
||||
public void handle(String target, Request jettyRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
||||
public boolean process(Request request, Response response, Callback callback) throws Exception
|
||||
{
|
||||
String path = request.getRequestURI();
|
||||
String path = Request.getPathInContext(request);
|
||||
if (path.startsWith("/old_path/"))
|
||||
{
|
||||
// Rewrite old paths to new paths.
|
||||
HttpURI uri = jettyRequest.getHttpURI();
|
||||
HttpURI uri = request.getHttpURI();
|
||||
String newPath = "/new_path/" + path.substring("/old_path/".length());
|
||||
HttpURI newURI = HttpURI.build(uri).path(newPath);
|
||||
// Modify the request object.
|
||||
jettyRequest.setHttpURI(newURI);
|
||||
HttpURI newURI = HttpURI.build(uri).path(newPath).asImmutable();
|
||||
|
||||
// Modify the request object by wrapping the HttpURI
|
||||
request = new Request.Wrapper(request)
|
||||
{
|
||||
@Override
|
||||
public HttpURI getHttpURI()
|
||||
{
|
||||
return newURI;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// This Handler is not handling the request, so
|
||||
// it does not call jettyRequest.setHandled(true).
|
||||
|
||||
// Forward to the next Handler.
|
||||
super.handle(target, jettyRequest, request, response);
|
||||
return super.process(request, response, callback);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -618,7 +622,6 @@ public class HTTPServerDocs
|
|||
server.setHandler(filter);
|
||||
|
||||
server.start();
|
||||
*/
|
||||
// end::handlerFilter[]
|
||||
}
|
||||
|
||||
|
@ -999,22 +1002,16 @@ public class HTTPServerDocs
|
|||
{
|
||||
// tag::defaultHandler[]
|
||||
Server server = new Server();
|
||||
server.setDefaultHandler(new DefaultHandler(false, true));
|
||||
|
||||
Connector connector = new ServerConnector(server);
|
||||
server.addConnector(connector);
|
||||
|
||||
// Create a Handler collection.
|
||||
Handler.Collection handlerList = new Handler.Collection();
|
||||
|
||||
// Add as first a ContextHandlerCollection to manage contexts.
|
||||
// Add a ContextHandlerCollection to manage contexts.
|
||||
ContextHandlerCollection contexts = new ContextHandlerCollection();
|
||||
handlerList.addHandler(contexts);
|
||||
|
||||
// Add as last a DefaultHandler.
|
||||
DefaultHandler defaultHandler = new DefaultHandler();
|
||||
handlerList.addHandler(defaultHandler);
|
||||
|
||||
// Link the HandlerList to the Server.
|
||||
server.setHandler(handlerList);
|
||||
// Link the contexts to the Server.
|
||||
server.setHandler(contexts);
|
||||
|
||||
server.start();
|
||||
// end::defaultHandler[]
|
||||
|
|
|
@ -93,29 +93,11 @@
|
|||
-->
|
||||
</New>
|
||||
|
||||
|
||||
<!-- =========================================================== -->
|
||||
<!-- Set the default handler structure for the Server -->
|
||||
<!-- A handler collection is used to pass received requests to -->
|
||||
<!-- both the ContextHandlerCollection, which selects the next -->
|
||||
<!-- handler by context path and virtual host, and the -->
|
||||
<!-- DefaultHandler, which handles any requests not handled by -->
|
||||
<!-- the context handlers. -->
|
||||
<!-- Other handlers may be added to the "Handlers" collection. -->
|
||||
<!-- =========================================================== -->
|
||||
<Set name="handler">
|
||||
<New id="Handlers" class="org.eclipse.jetty.server.Handler$Collection">
|
||||
<Set name="handlers">
|
||||
<Array type="org.eclipse.jetty.server.Handler">
|
||||
<Item>
|
||||
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
|
||||
</Item>
|
||||
</Array>
|
||||
</Set>
|
||||
</New>
|
||||
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
|
||||
</Set>
|
||||
|
||||
<!-- =========================================================== -->
|
||||
|
|
|
@ -228,13 +228,13 @@ public class JettyHttpServer extends com.sun.net.httpserver.HttpServer
|
|||
JettyHttpContext context = new JettyHttpContext(this, path, httpHandler);
|
||||
HttpSpiContextHandler jettyContextHandler = context.getJettyContextHandler();
|
||||
|
||||
ContextHandlerCollection chc = _server.getDescendant(ContextHandlerCollection.class);
|
||||
ContextHandlerCollection contexts = _server.getDescendant(ContextHandlerCollection.class);
|
||||
|
||||
if (chc == null)
|
||||
if (contexts == null)
|
||||
throw new RuntimeException("could not find ContextHandlerCollection, you must configure one");
|
||||
|
||||
chc.addHandler(jettyContextHandler);
|
||||
if (chc.isStarted())
|
||||
contexts.addHandler(jettyContextHandler);
|
||||
if (contexts.isStarted())
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
@ -21,8 +21,6 @@ import com.sun.net.httpserver.HttpsServer;
|
|||
import com.sun.net.httpserver.spi.HttpServerProvider;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
import org.eclipse.jetty.util.thread.ThreadPool;
|
||||
|
||||
|
@ -31,7 +29,6 @@ import org.eclipse.jetty.util.thread.ThreadPool;
|
|||
*/
|
||||
public class JettyHttpServerProvider extends HttpServerProvider
|
||||
{
|
||||
|
||||
private static Server _server;
|
||||
|
||||
public static void setServer(Server server)
|
||||
|
@ -51,8 +48,7 @@ public class JettyHttpServerProvider extends HttpServerProvider
|
|||
ThreadPool threadPool = new DelegatingThreadPool(new QueuedThreadPool());
|
||||
server = new Server(threadPool);
|
||||
|
||||
HandlerList handlerCollection = new HandlerList(new ContextHandlerCollection(), new DefaultHandler());
|
||||
server.setHandler(handlerCollection);
|
||||
server.setHandler(new ContextHandlerCollection(true));
|
||||
|
||||
shared = false;
|
||||
}
|
||||
|
|
|
@ -156,18 +156,7 @@
|
|||
</Set>
|
||||
|
||||
<Set name="handler">
|
||||
<New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerList">
|
||||
<Set name="handlers">
|
||||
<Array type="org.eclipse.jetty.server.Handler">
|
||||
<Item>
|
||||
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection" />
|
||||
</Item>
|
||||
<Item>
|
||||
<New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler" />
|
||||
</Item>
|
||||
</Array>
|
||||
</Set>
|
||||
</New>
|
||||
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection" />
|
||||
</Set>
|
||||
</New>
|
||||
</Set>
|
||||
|
|
|
@ -81,24 +81,17 @@
|
|||
</New>
|
||||
|
||||
<!-- =========================================================== -->
|
||||
<!-- Set the default handler structure for the Server -->
|
||||
<!-- A handler list is used to pass received requests to -->
|
||||
<!-- both the ContextHandlerCollection, which selects the next -->
|
||||
<!-- handler by context path and virtual host, and then only if -->
|
||||
<!-- the request is not handled is the DefaultHandler invoked -->
|
||||
<!-- Set the handler structure for the Server -->
|
||||
<!-- =========================================================== -->
|
||||
<Set name="defaultHandler">
|
||||
<New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler">
|
||||
<Arg name="serveFavIcon" type="boolean"><Property name="jetty.server.default.serveFavIcon" default="true"/></Arg>
|
||||
<Arg name="showContexts" type="boolean"><Property name="jetty.server.default.showContexts" default="true"/></Arg>
|
||||
</New>
|
||||
</Set>
|
||||
<Set name="handler">
|
||||
<New id="Handlers" class="org.eclipse.jetty.server.Handler$Collection">
|
||||
<Set name="handlers">
|
||||
<Array type="org.eclipse.jetty.server.Handler">
|
||||
<Item>
|
||||
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
|
||||
</Item>
|
||||
</Array>
|
||||
</Set>
|
||||
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection">
|
||||
<Set name="dynamic" property="jetty.server.contexts.dynamic"/>
|
||||
</New>
|
||||
</Set>
|
||||
|
||||
|
|
|
@ -111,3 +111,13 @@ etc/jetty.xml
|
|||
## The number of server scheduler threads.
|
||||
# jetty.scheduler.threads=1
|
||||
# end::documentation-scheduler-config[]
|
||||
|
||||
## Whether the handlers of the ContextHandlerCollection can be updated once the server is started
|
||||
## If set to false, then eeN-deploy module jetty.deploy.scanInterval should also be set to 0.
|
||||
# jetty.server.contexts.dynamic=true
|
||||
|
||||
## Should the DefaultHandler serve the jetty favicon.ico from the root.
|
||||
# jetty.server.default.serveFavIcon=true
|
||||
|
||||
## Should the DefaultHandler show a list of known contexts in a root 404 response.
|
||||
# jetty.server.default.showContexts=true
|
||||
|
|
|
@ -297,9 +297,17 @@ public interface Handler extends LifeCycle, Destroyable, Invocable, Request.Proc
|
|||
{
|
||||
// check state
|
||||
Server server = nested.getServer();
|
||||
if (server != null && server.isStarted() && handler != null &&
|
||||
server.getInvocationType() != Invocable.combine(server.getInvocationType(), handler.getInvocationType()))
|
||||
throw new IllegalArgumentException("Cannot change invocation type of started server");
|
||||
|
||||
// If the collection is changed whilst started, then the risk is that if we switch from NON_BLOCKING to BLOCKING
|
||||
// whilst the execution strategy may have already dispatched the very last available thread, thinking it would
|
||||
// never block, only for it to lose the race and find a newly added BLOCKING handler.
|
||||
if (server != null && server.isStarted() && handler != null)
|
||||
{
|
||||
InvocationType serverInvocationType = server.getInvocationType();
|
||||
if (serverInvocationType != Invocable.combine(serverInvocationType, handler.getInvocationType()) &&
|
||||
serverInvocationType != InvocationType.BLOCKING)
|
||||
throw new IllegalArgumentException("Cannot change invocation type of started server");
|
||||
}
|
||||
|
||||
// Check for loops.
|
||||
if (handler == nested || (handler instanceof Handler.Container container &&
|
||||
|
@ -401,13 +409,33 @@ public interface Handler extends LifeCycle, Destroyable, Invocable, Request.Proc
|
|||
*/
|
||||
abstract class AbstractContainer extends Abstract implements Container
|
||||
{
|
||||
private boolean _dynamic;
|
||||
|
||||
protected AbstractContainer()
|
||||
{
|
||||
this(true);
|
||||
}
|
||||
|
||||
protected AbstractContainer(InvocationType invocationType)
|
||||
/**
|
||||
* @param dynamic If true, then handlers may be added to the container dynamically when started,
|
||||
* thus the InvocationType is assumed to be BLOCKING,
|
||||
* otherwise handlers cannot be modified once the container is started.
|
||||
*/
|
||||
protected AbstractContainer(boolean dynamic)
|
||||
{
|
||||
super(invocationType);
|
||||
_dynamic = dynamic;
|
||||
}
|
||||
|
||||
public boolean isDynamic()
|
||||
{
|
||||
return _dynamic;
|
||||
}
|
||||
|
||||
public void setDynamic(boolean dynamic)
|
||||
{
|
||||
if (isStarted())
|
||||
throw new IllegalStateException(getState());
|
||||
_dynamic = dynamic;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -468,6 +496,9 @@ public interface Handler extends LifeCycle, Destroyable, Invocable, Request.Proc
|
|||
@Override
|
||||
public InvocationType getInvocationType()
|
||||
{
|
||||
// Dynamic is always BLOCKING, as a blocking handler can be added at any time.
|
||||
if (_dynamic)
|
||||
return InvocationType.BLOCKING;
|
||||
InvocationType invocationType = InvocationType.NON_BLOCKING;
|
||||
for (Handler child : getHandlers())
|
||||
invocationType = Invocable.combine(invocationType, child.getInvocationType());
|
||||
|
@ -512,8 +543,19 @@ public interface Handler extends LifeCycle, Destroyable, Invocable, Request.Proc
|
|||
this(null);
|
||||
}
|
||||
|
||||
public Wrapper(boolean dynamic)
|
||||
{
|
||||
this(dynamic, null);
|
||||
}
|
||||
|
||||
public Wrapper(Handler handler)
|
||||
{
|
||||
this(false, handler);
|
||||
}
|
||||
|
||||
public Wrapper(boolean dynamic, Handler handler)
|
||||
{
|
||||
super(dynamic);
|
||||
_handler = handler == null ? null : Nested.updateHandler(this, handler);
|
||||
}
|
||||
|
||||
|
@ -524,6 +566,8 @@ public interface Handler extends LifeCycle, Destroyable, Invocable, Request.Proc
|
|||
|
||||
public void setHandler(Handler handler)
|
||||
{
|
||||
if (!isDynamic() && isStarted())
|
||||
throw new IllegalStateException(getState());
|
||||
_handler = Nested.updateHandler(this, handler);
|
||||
}
|
||||
|
||||
|
@ -544,6 +588,8 @@ public interface Handler extends LifeCycle, Destroyable, Invocable, Request.Proc
|
|||
@Override
|
||||
public InvocationType getInvocationType()
|
||||
{
|
||||
if (isDynamic())
|
||||
return InvocationType.BLOCKING;
|
||||
Handler next = getHandler();
|
||||
return next == null ? InvocationType.NON_BLOCKING : next.getInvocationType();
|
||||
}
|
||||
|
@ -557,15 +603,32 @@ public interface Handler extends LifeCycle, Destroyable, Invocable, Request.Proc
|
|||
class Collection extends AbstractContainer
|
||||
{
|
||||
private volatile List<Handler> _handlers = new ArrayList<>();
|
||||
private volatile InvocationType _invocationType = InvocationType.BLOCKING;
|
||||
|
||||
public Collection(Handler... handlers)
|
||||
{
|
||||
this(List.of(handlers));
|
||||
this(handlers.length == 0, List.of(handlers));
|
||||
}
|
||||
|
||||
public Collection(boolean dynamic)
|
||||
{
|
||||
this(dynamic, Collections.emptyList());
|
||||
}
|
||||
|
||||
public Collection(List<Handler> handlers)
|
||||
{
|
||||
this(handlers == null || handlers.size() == 0, handlers);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dynamic If true, then handlers may be added dynamically once started,
|
||||
* so the InvocationType is assumed to be BLOCKING, otherwise
|
||||
* handlers cannot be modified once started.
|
||||
*
|
||||
* @param handlers The handlers to add.
|
||||
*/
|
||||
public Collection(boolean dynamic, List<Handler> handlers)
|
||||
{
|
||||
super(dynamic);
|
||||
setHandlers(handlers);
|
||||
}
|
||||
|
||||
|
@ -593,11 +656,14 @@ public interface Handler extends LifeCycle, Destroyable, Invocable, Request.Proc
|
|||
|
||||
public void setHandlers(List<Handler> handlers)
|
||||
{
|
||||
if (!isDynamic() && isStarted())
|
||||
throw new IllegalStateException(getState());
|
||||
|
||||
List<Handler> newHandlers = newHandlers(handlers);
|
||||
|
||||
Server server = getServer();
|
||||
InvocationType invocationType = server == null ? null : server.getInvocationType();
|
||||
_invocationType = InvocationType.BLOCKING; // switch to blocking invocation type whilst updating handlers;
|
||||
InvocationType serverInvocationType = server == null ? null : server.getInvocationType();
|
||||
InvocationType invocationType = InvocationType.NON_BLOCKING;
|
||||
|
||||
// Check for loops && InvocationType changes.
|
||||
for (Handler handler : newHandlers)
|
||||
|
@ -609,24 +675,31 @@ public interface Handler extends LifeCycle, Destroyable, Invocable, Request.Proc
|
|||
container.getDescendants().contains(this)))
|
||||
throw new IllegalStateException("setHandler loop");
|
||||
invocationType = Invocable.combine(invocationType, handler.getInvocationType());
|
||||
if (server != null && server.isStarted() &&
|
||||
server.getInvocationType() != Invocable.combine(server.getInvocationType(), handler.getInvocationType()))
|
||||
throw new IllegalArgumentException("Cannot change invocation type of started server");
|
||||
|
||||
if (server != null)
|
||||
handler.setServer(server);
|
||||
}
|
||||
|
||||
// If the collection can be changed dynamically, then the risk is that if we switch from NON_BLOCKING to BLOCKING
|
||||
// whilst the execution strategy may have already dispatched the very last available thread, thinking it would
|
||||
// never block, only for it to lose the race and find a newly added BLOCKING handler.
|
||||
if (isDynamic() && server != null && server.isStarted() && serverInvocationType != invocationType && serverInvocationType != InvocationType.BLOCKING)
|
||||
throw new IllegalArgumentException("Cannot change invocation type of started server");
|
||||
|
||||
updateBeans(_handlers, handlers);
|
||||
|
||||
_handlers = newHandlers;
|
||||
_invocationType = invocationType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InvocationType getInvocationType()
|
||||
{
|
||||
return _invocationType == null ? super.getInvocationType() : _invocationType;
|
||||
if (isDynamic())
|
||||
return InvocationType.BLOCKING;
|
||||
|
||||
InvocationType invocationType = InvocationType.NON_BLOCKING;
|
||||
for (Handler handler : _handlers)
|
||||
invocationType = Invocable.combine(invocationType, handler.getInvocationType());
|
||||
return invocationType;
|
||||
}
|
||||
|
||||
protected List<Handler> newHandlers(List<Handler> handlers)
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.eclipse.jetty.io.Connection;
|
|||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.server.handler.ErrorProcessor;
|
||||
import org.eclipse.jetty.util.Attributes;
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
import org.eclipse.jetty.util.DecoratedObjectFactory;
|
||||
import org.eclipse.jetty.util.ExceptionUtil;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
|
@ -56,6 +57,7 @@ import org.eclipse.jetty.util.resource.FileSystemPool;
|
|||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.util.resource.ResourceFactory;
|
||||
import org.eclipse.jetty.util.thread.AutoLock;
|
||||
import org.eclipse.jetty.util.thread.Invocable;
|
||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
import org.eclipse.jetty.util.thread.ShutdownThread;
|
||||
import org.eclipse.jetty.util.thread.ThreadPool;
|
||||
|
@ -77,6 +79,7 @@ public class Server extends Handler.Wrapper implements Attributes
|
|||
private boolean _stopAtShutdown;
|
||||
private boolean _dumpAfterStart;
|
||||
private boolean _dumpBeforeStop;
|
||||
private Handler _defaultHandler;
|
||||
private Request.Processor _errorProcessor;
|
||||
private RequestLog _requestLog;
|
||||
private boolean _dryRun;
|
||||
|
@ -130,6 +133,31 @@ public class Server extends Handler.Wrapper implements Attributes
|
|||
addBean(FileSystemPool.INSTANCE, false);
|
||||
}
|
||||
|
||||
public Handler getDefaultHandler()
|
||||
{
|
||||
return _defaultHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param defaultHandler The handler to use if no other handler is set or has processed the request. This handler should
|
||||
* always accept the request, even if only to send a 404.
|
||||
*/
|
||||
public void setDefaultHandler(Handler defaultHandler)
|
||||
{
|
||||
if (!isDynamic() && isStarted())
|
||||
throw new IllegalStateException(getState());
|
||||
Handler old = _defaultHandler;
|
||||
_defaultHandler = defaultHandler;
|
||||
updateBean(old, defaultHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean process(Request request, Response response, Callback callback) throws Exception
|
||||
{
|
||||
// Handle either with normal handler or default handler
|
||||
return super.process(request, response, callback) || _defaultHandler != null && _defaultHandler.process(request, response, callback);
|
||||
}
|
||||
|
||||
public String getServerInfo()
|
||||
{
|
||||
return _serverInfo;
|
||||
|
@ -195,11 +223,22 @@ public class Server extends Handler.Wrapper implements Attributes
|
|||
@Override
|
||||
public InvocationType getInvocationType()
|
||||
{
|
||||
Handler handler = getHandler();
|
||||
if (handler == null)
|
||||
return InvocationType.NON_BLOCKING;
|
||||
if (isDynamic())
|
||||
return InvocationType.BLOCKING;
|
||||
|
||||
// Return cached type to avoid a full handler tree walk.
|
||||
return isRunning() ? _invocationType : handler.getInvocationType();
|
||||
if (isStarted())
|
||||
return _invocationType;
|
||||
|
||||
InvocationType type = InvocationType.NON_BLOCKING;
|
||||
Handler handler = getHandler();
|
||||
if (handler != null)
|
||||
type = Invocable.combine(type, handler.getInvocationType());
|
||||
handler = getDefaultHandler();
|
||||
if (handler != null)
|
||||
type = Invocable.combine(type, handler.getInvocationType());
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
public boolean isDryRun()
|
||||
|
@ -475,8 +514,7 @@ public class Server extends Handler.Wrapper implements Attributes
|
|||
|
||||
// Cache the invocation type to avoid runtime walk of handler tree
|
||||
// Handlers must check they don't change the InvocationType of a started server
|
||||
Handler handler = getHandler();
|
||||
_invocationType = handler == null ? InvocationType.NON_BLOCKING : handler.getInvocationType();
|
||||
_invocationType = getInvocationType();
|
||||
|
||||
if (_dryRun)
|
||||
{
|
||||
|
|
|
@ -50,6 +50,19 @@ public class ContextHandlerCollection extends Handler.Collection
|
|||
|
||||
public ContextHandlerCollection(ContextHandler... contexts)
|
||||
{
|
||||
this(true, contexts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dynamic If true, then contexts may be added dynamically once started,
|
||||
* so the InvocationType is assumed to be BLOCKING, otherwise
|
||||
* the InvocationType is fixed once started and handlers cannot be
|
||||
* subsequently added.
|
||||
* @param contexts The contexts to add.
|
||||
*/
|
||||
public ContextHandlerCollection(boolean dynamic, ContextHandler... contexts)
|
||||
{
|
||||
super(dynamic);
|
||||
if (contexts.length > 0)
|
||||
setHandlers(contexts);
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.eclipse.jetty.util.IO;
|
|||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.URIUtil;
|
||||
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||
import org.eclipse.jetty.util.annotation.Name;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -59,11 +60,19 @@ public class DefaultHandler extends Handler.Abstract
|
|||
private final long _faviconModifiedMs = (System.currentTimeMillis() / 1000) * 1000L;
|
||||
private final HttpField _faviconModified = new PreEncodedHttpField(HttpHeader.LAST_MODIFIED, DateGenerator.formatDate(_faviconModifiedMs));
|
||||
private ByteBuffer _favicon;
|
||||
private boolean _serveIcon = true;
|
||||
private boolean _serveFavIcon = true;
|
||||
private boolean _showContexts = true;
|
||||
|
||||
public DefaultHandler()
|
||||
{
|
||||
this(true, true);
|
||||
}
|
||||
|
||||
public DefaultHandler(@Name("serveFavIcon") boolean serveFavIcon, @Name("showContexts")boolean showContexts)
|
||||
{
|
||||
super(InvocationType.NON_BLOCKING);
|
||||
_serveFavIcon = serveFavIcon;
|
||||
_showContexts = showContexts;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -109,7 +118,7 @@ public class DefaultHandler extends Handler.Abstract
|
|||
String method = request.getMethod();
|
||||
|
||||
// little cheat for common request
|
||||
if (isServeIcon() && _favicon != null && HttpMethod.GET.is(method) && Request.getPathInContext(request).equals("/favicon.ico"))
|
||||
if (isServeFavIcon() && _favicon != null && HttpMethod.GET.is(method) && Request.getPathInContext(request).equals("/favicon.ico"))
|
||||
{
|
||||
ByteBuffer content = BufferUtil.EMPTY_BUFFER;
|
||||
if (_faviconModifiedMs > 0 && request.getHeaders().getDateField(HttpHeader.IF_MODIFIED_SINCE) == _faviconModifiedMs)
|
||||
|
@ -218,18 +227,18 @@ public class DefaultHandler extends Handler.Abstract
|
|||
/**
|
||||
* @return Returns true if the handle can server the jetty favicon.ico
|
||||
*/
|
||||
@ManagedAttribute("True if the favicon.ico should be served")
|
||||
public boolean isServeIcon()
|
||||
@ManagedAttribute("True if the favicon.ico is served")
|
||||
public boolean isServeFavIcon()
|
||||
{
|
||||
return _serveIcon;
|
||||
return _serveFavIcon;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param serveIcon true if the handle can server the jetty favicon.ico
|
||||
* @param serveFavIcon true if the handle can server the jetty favicon.ico
|
||||
*/
|
||||
public void setServeIcon(boolean serveIcon)
|
||||
public void setServeFavIcon(boolean serveFavIcon)
|
||||
{
|
||||
_serveIcon = serveIcon;
|
||||
_serveFavIcon = serveFavIcon;
|
||||
}
|
||||
|
||||
@ManagedAttribute("True if the contexts should be shown in the default 404 page")
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2022 Mort Bay Consulting Pty Ltd and others.
|
||||
//
|
||||
// This program and the accompanying materials are made available under the
|
||||
// terms of the Eclipse Public License v. 2.0 which is available at
|
||||
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
|
||||
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
|
||||
//
|
||||
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.server.handler;
|
||||
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
|
||||
/**
|
||||
* HandlerList.
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public class HandlerList extends Handler.Collection
|
||||
{
|
||||
public HandlerList()
|
||||
{
|
||||
}
|
||||
|
||||
public HandlerList(Handler... handlers)
|
||||
{
|
||||
super(handlers);
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2022 Mort Bay Consulting Pty Ltd and others.
|
||||
//
|
||||
// This program and the accompanying materials are made available under the
|
||||
// terms of the Eclipse Public License v. 2.0 which is available at
|
||||
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
|
||||
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
|
||||
//
|
||||
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.server.handler;
|
||||
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link Handler.Wrapper}
|
||||
*/
|
||||
@ManagedObject("Handler wrapping another Handler")
|
||||
@Deprecated
|
||||
public class HandlerWrapper extends Handler.Wrapper
|
||||
{
|
||||
}
|
|
@ -37,6 +37,7 @@ public class HotSwapHandler extends Handler.AbstractContainer implements Handler
|
|||
*/
|
||||
public HotSwapHandler()
|
||||
{
|
||||
super(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -39,6 +39,16 @@ public class PathMappingsHandler extends Handler.AbstractContainer
|
|||
|
||||
private final PathMappings<Handler> mappings = new PathMappings<>();
|
||||
|
||||
public PathMappingsHandler()
|
||||
{
|
||||
this(true);
|
||||
}
|
||||
|
||||
public PathMappingsHandler(boolean dynamic)
|
||||
{
|
||||
super(dynamic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addHandler(Handler handler)
|
||||
{
|
||||
|
|
|
@ -41,10 +41,9 @@ import org.slf4j.LoggerFactory;
|
|||
*
|
||||
* <pre>
|
||||
* Server server = new Server(8080);
|
||||
* HandlerList handlers = new HandlerList();
|
||||
* handlers.setHandlers(new Handler[]
|
||||
* { someOtherHandler, new ShutdownHandler("secret password", false, true) });
|
||||
* server.setHandler(handlers);
|
||||
* ShutdownHandler shutdown = new ShutdownHandler("secret password", false, true) });
|
||||
* server.setHandler(shutdown);
|
||||
* shutdown.setHandler(someOtherHandler);
|
||||
* server.start();
|
||||
* </pre>
|
||||
*
|
||||
|
@ -151,7 +150,7 @@ public class ShutdownHandler extends Handler.Wrapper
|
|||
@Override
|
||||
public boolean process(Request request, Response response, Callback callback) throws Exception
|
||||
{
|
||||
return false;
|
||||
return super.process(request, response, callback);
|
||||
/* TODO
|
||||
if (!target.equals("/shutdown"))
|
||||
{
|
||||
|
|
|
@ -24,7 +24,6 @@ import org.eclipse.jetty.logging.StacklessLogging;
|
|||
import org.eclipse.jetty.server.LocalConnector.LocalEndPoint;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.server.handler.DumpHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
|
@ -39,7 +38,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
@Disabled // TODO
|
||||
public class PartialRFC2616Test
|
||||
{
|
||||
private Server server;
|
||||
|
@ -62,7 +60,7 @@ public class PartialRFC2616Test
|
|||
context.setContextPath("/");
|
||||
context.setHandler(new DumpHandler());
|
||||
|
||||
server.setHandler(new HandlerList(vcontext, context));
|
||||
server.setHandler(new Handler.Collection(vcontext, context));
|
||||
|
||||
server.start();
|
||||
}
|
||||
|
@ -406,6 +404,7 @@ public class PartialRFC2616Test
|
|||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO
|
||||
public void test521() throws Exception
|
||||
{
|
||||
// Default Host
|
||||
|
@ -413,7 +412,7 @@ public class PartialRFC2616Test
|
|||
String response = connector.getResponse("GET http://VirtualHost:8888/path/R1 HTTP/1.1\n" + "Host: wronghost\n" + "Connection: close\n" + "\n");
|
||||
offset = checkContains(response, offset, "HTTP/1.1 200", "Virtual host") + 1;
|
||||
offset = checkContains(response, offset, "Virtual Dump", "Virtual host") + 1;
|
||||
offset = checkContains(response, offset, "pathInfo=/path/R1", "Virtual host") + 1;
|
||||
offset = checkContains(response, offset, "pathInContext=/path/R1", "Virtual host") + 1;
|
||||
offset = checkContains(response, offset, "servername=VirtualHost", "Virtual host") + 1;
|
||||
}
|
||||
|
||||
|
@ -424,15 +423,15 @@ public class PartialRFC2616Test
|
|||
int offset = 0;
|
||||
String response = connector.getResponse("GET /path/R1 HTTP/1.1\n" + "Host: localhost\n" + "Connection: close\n" + "\n");
|
||||
offset = checkContains(response, offset, "HTTP/1.1 200", "Default host") + 1;
|
||||
offset = checkContains(response, offset, "Dump HttpHandler", "Default host") + 1;
|
||||
offset = checkContains(response, offset, "pathInfo=/path/R1", "Default host") + 1;
|
||||
offset = checkContains(response, offset, "Dump Handler", "Default host") + 1;
|
||||
offset = checkContains(response, offset, "pathInContext=/path/R1", "Default host") + 1;
|
||||
|
||||
// Virtual Host
|
||||
offset = 0;
|
||||
response = connector.getResponse("GET /path/R2 HTTP/1.1\n" + "Host: VirtualHost\n" + "Connection: close\n" + "\n");
|
||||
offset = checkContains(response, offset, "HTTP/1.1 200", "Default host") + 1;
|
||||
offset = checkContains(response, offset, "Virtual Dump", "virtual host") + 1;
|
||||
offset = checkContains(response, offset, "pathInfo=/path/R2", "Default host") + 1;
|
||||
offset = checkContains(response, offset, "pathInContext=/path/R2", "Default host") + 1;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -443,14 +442,14 @@ public class PartialRFC2616Test
|
|||
String response = connector.getResponse("GET /path/R1 HTTP/1.1\n" + "Host: VirtualHost\n" + "Connection: close\n" + "\n");
|
||||
offset = checkContains(response, offset, "HTTP/1.1 200", "2. virtual host field") + 1;
|
||||
offset = checkContains(response, offset, "Virtual Dump", "2. virtual host field") + 1;
|
||||
offset = checkContains(response, offset, "pathInfo=/path/R1", "2. virtual host field") + 1;
|
||||
offset = checkContains(response, offset, "pathInContext=/path/R1", "2. virtual host field") + 1;
|
||||
|
||||
// Virtual Host case insensitive
|
||||
offset = 0;
|
||||
response = connector.getResponse("GET /path/R1 HTTP/1.1\n" + "Host: ViRtUalhOst\n" + "Connection: close\n" + "\n");
|
||||
offset = checkContains(response, offset, "HTTP/1.1 200", "2. virtual host field") + 1;
|
||||
offset = checkContains(response, offset, "Virtual Dump", "2. virtual host field") + 1;
|
||||
offset = checkContains(response, offset, "pathInfo=/path/R1", "2. virtual host field") + 1;
|
||||
offset = checkContains(response, offset, "pathInContext=/path/R1", "2. virtual host field") + 1;
|
||||
|
||||
// Virtual Host
|
||||
offset = 0;
|
||||
|
@ -486,6 +485,7 @@ public class PartialRFC2616Test
|
|||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO
|
||||
public void test10418() throws Exception
|
||||
{
|
||||
// Expect Failure
|
||||
|
@ -541,6 +541,7 @@ public class PartialRFC2616Test
|
|||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO
|
||||
public void test824() throws Exception
|
||||
{
|
||||
// Expect 100 not sent
|
||||
|
@ -599,6 +600,7 @@ public class PartialRFC2616Test
|
|||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO
|
||||
public void test1423() throws Exception
|
||||
{
|
||||
try (StacklessLogging stackless = new StacklessLogging(HttpParser.class))
|
||||
|
|
|
@ -285,7 +285,7 @@ public class ContextHandlerCollectionTest
|
|||
String rawResponse = connector.getResponse(rawRequest);
|
||||
HttpTester.Response response = HttpTester.parseResponse(rawResponse);
|
||||
assertThat("Response status for [GET " + requestHost + "]", response.getStatus(), is(HttpStatus.NOT_FOUND_404));
|
||||
assertThat("Response body for [GET " + requestHost + "]", response.getContent(), containsString("<h2>HTTP ERROR 404 Not Found</h2>"));
|
||||
assertThat("Response body for [GET " + requestHost + "]", response.getContent(), containsString("Not Found"));
|
||||
assertThat("Response Header for [GET " + requestHost + "]", response.get("X-IsHandled-Name"), nullValue());
|
||||
|
||||
connector.getResponse(rawRequest);
|
||||
|
|
|
@ -48,11 +48,7 @@ public class DefaultHandlerTest
|
|||
server.addConnector(connector);
|
||||
|
||||
ContextHandlerCollection contexts = new ContextHandlerCollection();
|
||||
handler = new DefaultHandler();
|
||||
server.setHandler(new Handler.Collection(contexts, handler));
|
||||
|
||||
handler.setServeIcon(true);
|
||||
handler.setShowContexts(true);
|
||||
server.setHandler(new Handler.Collection(contexts, new DefaultHandler(true, true)));
|
||||
|
||||
contexts.addHandler(new ContextHandler("/foo"));
|
||||
contexts.addHandler(new ContextHandler("/bar"));
|
||||
|
|
|
@ -400,7 +400,7 @@ public class NcsaRequestLogTest
|
|||
setup(logType);
|
||||
RequestLogHandler handler = new RequestLogHandler();
|
||||
handler.setRequestLog(_log);
|
||||
HandlerList handlers = new HandlerList(handler, testHandler);
|
||||
Handler.Collection handlers = new Handler.Collection(handler, testHandler);
|
||||
_server.setHandler(handlers);
|
||||
startServer();
|
||||
makeRequest(requestPath);
|
||||
|
|
|
@ -355,7 +355,7 @@ public class ResourceHandlerTest
|
|||
(response) ->
|
||||
{
|
||||
String body = response.getContent();
|
||||
assertThat(body, containsString("/../../"));
|
||||
assertThat(body, containsString("Not Found"));
|
||||
assertThat(body, not(containsString("Directory: ")));
|
||||
}
|
||||
);
|
||||
|
|
|
@ -149,7 +149,7 @@ public class SecuredRedirectHandlerCodeTest
|
|||
contextHandlers.setHandlers(redirectHandler);
|
||||
|
||||
// Create server level handler tree
|
||||
server.setHandler(new HandlerList(contextHandlers, new DefaultHandler()));
|
||||
server.setHandler(contextHandlers);
|
||||
|
||||
server.start();
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ public class SecuredRedirectHandlerTest
|
|||
contextHandlers.setHandlers(redirectHandler, rootContext, test1Context, test2Context);
|
||||
|
||||
// Create server level handler tree
|
||||
server.setHandler(new HandlerList(contextHandlers, new DefaultHandler()));
|
||||
server.setHandler(contextHandlers);
|
||||
|
||||
server.start();
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ public class ShutdownHandlerTest
|
|||
private ServerConnector connector;
|
||||
private String shutdownToken = "asdlnsldgnklns";
|
||||
|
||||
public void start(HandlerWrapper wrapper) throws Exception
|
||||
public void start(Handler.Wrapper wrapper) throws Exception
|
||||
{
|
||||
server = new Server();
|
||||
connector = new ServerConnector(server);
|
||||
|
@ -94,7 +94,7 @@ public class ShutdownHandlerTest
|
|||
public void testShutdownRequestNotFromLocalhost() throws Exception
|
||||
{
|
||||
/* TODO
|
||||
start(new HandlerWrapper()
|
||||
start(new Handler.Wrapper()
|
||||
{
|
||||
@Override
|
||||
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
||||
|
|
|
@ -16,26 +16,20 @@
|
|||
</Array>
|
||||
</Set>
|
||||
|
||||
<New id="context" class="org.eclipse.jetty.ee10.servlet.ServletContextHandler">
|
||||
<Set name="contextPath">/hello</Set>
|
||||
<Call name="addServlet">
|
||||
<Arg>org.eclipse.jetty.ee10.demos.HelloServlet</Arg>
|
||||
<Arg>/</Arg>
|
||||
</Call>
|
||||
</New>
|
||||
|
||||
<Set name="handler">
|
||||
<New class="org.eclipse.jetty.server.Handler$Collection">
|
||||
<Set name="handlers">
|
||||
<Array type="org.eclipse.jetty.server.Handler">
|
||||
<Item>
|
||||
<Ref refid="context" />
|
||||
</Item>
|
||||
<Item>
|
||||
<New class="org.eclipse.jetty.server.handler.DefaultHandler" />
|
||||
</Item>
|
||||
</Array>
|
||||
</Set>
|
||||
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection">
|
||||
<Set name="dynamic" property="jetty.server.contexts.dynamic"/>
|
||||
<Call name="addHandler">
|
||||
<Arg>
|
||||
<New id="context" class="org.eclipse.jetty.ee10.servlet.ServletContextHandler">
|
||||
<Set name="contextPath">/hello</Set>
|
||||
<Call name="addServlet">
|
||||
<Arg>org.eclipse.jetty.ee10.demos.HelloServlet</Arg>
|
||||
<Arg>/</Arg>
|
||||
</Call>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
</New>
|
||||
</Set>
|
||||
</Configure>
|
||||
|
|
|
@ -13,25 +13,13 @@
|
|||
</Arg>
|
||||
</Call>
|
||||
|
||||
<Set name="handler">
|
||||
<New class="org.eclipse.jetty.server.Handler$Collection">
|
||||
<Set name="handlers">
|
||||
<Array type="org.eclipse.jetty.server.Handler">
|
||||
<Item>
|
||||
<New class="org.eclipse.jetty.server.handler.ResourceHandler">
|
||||
<Set name="baseResourceAsString"><Property name="fileserver.baseResource" default="."/></Set>
|
||||
<Set name="dirAllowed">true</Set>
|
||||
<Set name="welcomeFiles">
|
||||
<Array type="String"><Item>index.html</Item></Array>
|
||||
</Set>
|
||||
</New>
|
||||
</Item>
|
||||
<Item>
|
||||
<New class="org.eclipse.jetty.server.handler.DefaultHandler">
|
||||
</New>
|
||||
</Item>
|
||||
</Array>
|
||||
</Set>
|
||||
</New>
|
||||
</Set>
|
||||
<Set name="handler">
|
||||
<New class="org.eclipse.jetty.server.handler.ResourceHandler">
|
||||
<Set name="baseResourceAsString"><Property name="fileserver.baseResource" default="."/></Set>
|
||||
<Set name="dirAllowed">true</Set>
|
||||
<Set name="welcomeFiles">
|
||||
<Array type="String"><Item>index.html</Item></Array>
|
||||
</Set>
|
||||
</New>
|
||||
</Set>
|
||||
</Configure>
|
||||
|
|
|
@ -2,24 +2,15 @@
|
|||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_10_0.dtd">
|
||||
<Configure id="Server" class="org.eclipse.jetty.server.Server">
|
||||
|
||||
<Set name="handler">
|
||||
<New id="Handlers" class="org.eclipse.jetty.server.Handler$Collection">
|
||||
<Set name="handlers">
|
||||
<Array type="org.eclipse.jetty.server.Handler">
|
||||
<Item>
|
||||
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
|
||||
</Item>
|
||||
</Array>
|
||||
</Set>
|
||||
</New>
|
||||
</Set>
|
||||
<Set name="handler">
|
||||
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection">
|
||||
<Set name="dynamic" property="jetty.server.contexts.dynamic"/>
|
||||
</New>
|
||||
</Set>
|
||||
|
||||
<Set name="stopAtShutdown" property="jetty.server.stopAtShutdown"/>
|
||||
<Set name="stopTimeout"><Property name="jetty.server.stopTimeout" default="5000"/></Set>
|
||||
<Set name="dumpAfterStart" property="jetty.server.dumpAfterStart"/>
|
||||
<Set name="dumpBeforeStop" property="jetty.server.dumpBeforeStop"/>
|
||||
<Set name="stopAtShutdown" property="jetty.server.stopAtShutdown"/>
|
||||
<Set name="stopTimeout"><Property name="jetty.server.stopTimeout" default="5000"/></Set>
|
||||
<Set name="dumpAfterStart" property="jetty.server.dumpAfterStart"/>
|
||||
<Set name="dumpBeforeStop" property="jetty.server.dumpBeforeStop"/>
|
||||
|
||||
</Configure>
|
||||
|
|
|
@ -26,18 +26,7 @@
|
|||
<!-- Set handler Collection Structure -->
|
||||
<!-- =========================================================== -->
|
||||
<Set name="handler">
|
||||
<New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerList">
|
||||
<Set name="handlers">
|
||||
<Array type="org.eclipse.jetty.server.Handler">
|
||||
<Item>
|
||||
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
|
||||
</Item>
|
||||
</Array>
|
||||
</Set>
|
||||
</New>
|
||||
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
|
||||
</Set>
|
||||
|
||||
<New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
|
||||
|
|
|
@ -24,18 +24,7 @@
|
|||
<!-- Set handler Collection Structure -->
|
||||
<!-- =========================================================== -->
|
||||
<Set name="handler">
|
||||
<New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerList">
|
||||
<Set name="handlers">
|
||||
<Array type="org.eclipse.jetty.server.Handler">
|
||||
<Item>
|
||||
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
|
||||
</Item>
|
||||
</Array>
|
||||
</Set>
|
||||
</New>
|
||||
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
|
||||
</Set>
|
||||
|
||||
<New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
|
||||
|
|
|
@ -768,7 +768,7 @@ public class DefaultServletTest
|
|||
(response) ->
|
||||
{
|
||||
String body = response.getContent();
|
||||
assertThat(body, containsString("/../../"));
|
||||
assertThat(body, containsString("Not Found"));
|
||||
assertThat(body, not(containsString("Directory: ")));
|
||||
}
|
||||
);
|
||||
|
|
|
@ -25,8 +25,6 @@ import org.eclipse.jetty.http.HttpStatus;
|
|||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.eclipse.jetty.server.handler.ResourceHandler;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.util.security.Constraint;
|
||||
|
@ -75,7 +73,7 @@ public class AliasedConstraintTest
|
|||
context.setContextPath("/ctx");
|
||||
context.setBaseResourceAsPath(MavenTestingUtils.getTestResourcePathDir("docroot"));
|
||||
|
||||
server.setHandler(new HandlerList(context, new DefaultHandler()));
|
||||
server.setHandler(context);
|
||||
|
||||
server.addBean(loginService);
|
||||
|
||||
|
|
|
@ -20,24 +20,19 @@
|
|||
<!-- Set handler Collection Structure -->
|
||||
<!-- =========================================================== -->
|
||||
<Set name="handler">
|
||||
<New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerList">
|
||||
<Set name="handlers">
|
||||
<Array type="org.eclipse.jetty.server.Handler">
|
||||
<Item>
|
||||
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection" />
|
||||
</Item>
|
||||
<Item>
|
||||
<New id="defcontext" class="org.eclipse.jetty.server.handler.ContextHandler">
|
||||
<Set name="contextPath">/tests</Set>
|
||||
<Set name="baseResourceAsString"><Property name="test.docroot.base"/>/default</Set>
|
||||
<Set name="Handler">
|
||||
<New id="reshandler" class="org.eclipse.jetty.server.handler.ResourceHandler"/>
|
||||
</Set>
|
||||
<Set name="DisplayName">default</Set>
|
||||
</New>
|
||||
</Item>
|
||||
</Array>
|
||||
</Set>
|
||||
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection">
|
||||
<Call name="addHandler">
|
||||
<Arg>
|
||||
<New id="defcontext" class="org.eclipse.jetty.server.handler.ContextHandler">
|
||||
<Set name="contextPath">/tests</Set>
|
||||
<Set name="baseResourceAsString"><Property name="test.docroot.base"/>/default</Set>
|
||||
<Set name="Handler">
|
||||
<New id="reshandler" class="org.eclipse.jetty.server.handler.ResourceHandler"/>
|
||||
</Set>
|
||||
<Set name="DisplayName">default</Set>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
</New>
|
||||
</Set>
|
||||
|
||||
|
|
|
@ -33,42 +33,39 @@
|
|||
<!-- Set handler Collection Structure -->
|
||||
<!-- =========================================================== -->
|
||||
<Set name="handler">
|
||||
<New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerList">
|
||||
<Set name="handlers">
|
||||
<Array type="org.eclipse.jetty.server.Handler">
|
||||
<Item>
|
||||
<New id="WebappContexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<New id="vcontexts" class="org.eclipse.jetty.server.handler.ContextHandler">
|
||||
<Set name="contextPath">/tests</Set>
|
||||
<Set name="VirtualHosts">
|
||||
<Array type="java.lang.String">
|
||||
<Item>VirtualHost</Item>
|
||||
</Array>
|
||||
</Set>
|
||||
<Set name="BaseResource"><Property name="test.docroot.base"/>/virtualhost</Set>
|
||||
<Set name="Handler"><New id="reshandler1" class="org.eclipse.jetty.server.handler.ResourceHandler"/></Set>
|
||||
<Set name="DisplayName">virtual</Set>
|
||||
</New>
|
||||
</Item>
|
||||
<Item>
|
||||
<New id="defcontext" class="org.eclipse.jetty.server.handler.ContextHandler">
|
||||
<Set name="contextPath">/tests</Set>
|
||||
<Set name="BaseResource"><Property name="test.docroot.base"/>/default</Set>
|
||||
<Set name="Handler"><New id="reshandler2" class="org.eclipse.jetty.server.handler.ResourceHandler"/></Set>
|
||||
<Set name="DisplayName">default</Set>
|
||||
</New>
|
||||
</Item>
|
||||
<Item>
|
||||
<New id="echocontext" class="org.eclipse.jetty.server.handler.ContextHandler">
|
||||
<Set name="contextPath">/echo</Set>
|
||||
<Set name="Handler"><New id="echohandler" class="org.eclipse.jetty.test.support.EchoHandler"/></Set>
|
||||
<Set name="DisplayName">echo</Set>
|
||||
</New>
|
||||
</Item>
|
||||
</Array>
|
||||
</Set>
|
||||
<New id="WebappContexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection">
|
||||
<Arg>
|
||||
<Array type="org.eclipse.jetty.server.Handler">
|
||||
<Item>
|
||||
<New id="vcontexts" class="org.eclipse.jetty.server.handler.ContextHandler">
|
||||
<Set name="contextPath">/tests</Set>
|
||||
<Set name="VirtualHosts">
|
||||
<Array type="java.lang.String">
|
||||
<Item>VirtualHost</Item>
|
||||
</Array>
|
||||
</Set>
|
||||
<Set name="BaseResource"><Property name="test.docroot.base"/>/virtualhost</Set>
|
||||
<Set name="Handler"><New id="reshandler1" class="org.eclipse.jetty.server.handler.ResourceHandler"/></Set>
|
||||
<Set name="DisplayName">virtual</Set>
|
||||
</New>
|
||||
</Item>
|
||||
<Item>
|
||||
<New id="defcontext" class="org.eclipse.jetty.server.handler.ContextHandler">
|
||||
<Set name="contextPath">/tests</Set>
|
||||
<Set name="BaseResource"><Property name="test.docroot.base"/>/default</Set>
|
||||
<Set name="Handler"><New id="reshandler2" class="org.eclipse.jetty.server.handler.ResourceHandler"/></Set>
|
||||
<Set name="DisplayName">default</Set>
|
||||
</New>
|
||||
</Item>
|
||||
<Item>
|
||||
<New id="echocontext" class="org.eclipse.jetty.server.handler.ContextHandler">
|
||||
<Set name="contextPath">/echo</Set>
|
||||
<Set name="Handler"><New id="echohandler" class="org.eclipse.jetty.test.support.EchoHandler"/></Set>
|
||||
<Set name="DisplayName">echo</Set>
|
||||
</New>
|
||||
</Item>
|
||||
</Array>
|
||||
</Arg>
|
||||
</New>
|
||||
</Set>
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_9_3.dtd">
|
||||
|
||||
<Configure id="Contexts" class="org.eclipse.jetty.server.Handler.Collection">
|
||||
<Configure id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection">
|
||||
<Call name="addHandler">
|
||||
<New class="org.eclipse.jetty.ee10.webapp.WebAppContext">
|
||||
<Set name="contextPath">/test-jetty-webapp</Set>
|
||||
|
|
|
@ -19,18 +19,7 @@
|
|||
<!-- Set handler Collection Structure -->
|
||||
<!-- =========================================================== -->
|
||||
<Set name="handler">
|
||||
<New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerList">
|
||||
<Set name="handlers">
|
||||
<Array type="org.eclipse.jetty.server.Handler">
|
||||
<Item>
|
||||
<New id="WebappContexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection" />
|
||||
</Item>
|
||||
<Item>
|
||||
<New id="defcontext" class="org.eclipse.jetty.server.handler.DefaultHandler" />
|
||||
</Item>
|
||||
</Array>
|
||||
</Set>
|
||||
</New>
|
||||
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection" />
|
||||
</Set>
|
||||
|
||||
<!-- =========================================================== -->
|
||||
|
|
|
@ -20,8 +20,6 @@ import org.eclipse.jetty.ee10.websocket.jakarta.tests.framehandlers.FrameEcho;
|
|||
import org.eclipse.jetty.ee10.websocket.jakarta.tests.framehandlers.WholeMessageEcho;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
import org.eclipse.jetty.util.component.ContainerLifeCycle;
|
||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
|
@ -61,7 +59,7 @@ public class CoreServer extends ContainerLifeCycle
|
|||
// Add Handler
|
||||
WebSocketUpgradeHandler upgradeHandler = new WebSocketUpgradeHandler();
|
||||
upgradeHandler.addMapping("/*", negotiator);
|
||||
server.setHandler(new HandlerList(upgradeHandler, new DefaultHandler()));
|
||||
server.setHandler(upgradeHandler);
|
||||
|
||||
// Start Server
|
||||
addBean(server);
|
||||
|
|
|
@ -32,8 +32,6 @@ import org.eclipse.jetty.ee10.websocket.jakarta.server.config.JakartaWebSocketSe
|
|||
import org.eclipse.jetty.ee10.websocket.jakarta.server.internal.JakartaWebSocketServerContainer;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
@ -67,7 +65,7 @@ public class RestartContextTest
|
|||
context.addEventListener(new AddEndpointListener());
|
||||
|
||||
// Setup handler tree
|
||||
server.setHandler(new HandlerList(context, new DefaultHandler()));
|
||||
server.setHandler(context);
|
||||
|
||||
// Start server
|
||||
server.start();
|
||||
|
@ -103,11 +101,8 @@ public class RestartContextTest
|
|||
serverContainer.addEndpoint(EchoEndpoint.class);
|
||||
});
|
||||
|
||||
// Setup handler tree
|
||||
HandlerList handlers = new HandlerList(context, new DefaultHandler());
|
||||
|
||||
// Add handler tree to server
|
||||
server.setHandler(handlers);
|
||||
server.setHandler(context);
|
||||
|
||||
// Start server
|
||||
server.start();
|
||||
|
|
|
@ -34,8 +34,6 @@ import org.eclipse.jetty.ee10.websocket.server.JettyWebSocketServletFactory;
|
|||
import org.eclipse.jetty.ee10.websocket.server.config.JettyWebSocketServletContainerInitializer;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.util.resource.ResourceFactory;
|
||||
|
@ -109,7 +107,7 @@ public class BrowserDebugTool
|
|||
ServletHolder defHolder = new ServletHolder("default", DefaultServlet.class);
|
||||
context.addServlet(defHolder, "/");
|
||||
|
||||
server.setHandler(new HandlerList(context, new DefaultHandler()));
|
||||
server.setHandler(context);
|
||||
|
||||
LOG.info("{} setup on port {}", this.getClass().getName(), port);
|
||||
}
|
||||
|
|
|
@ -32,8 +32,6 @@ import org.eclipse.jetty.ee10.websocket.server.config.JettyWebSocketServletConta
|
|||
import org.eclipse.jetty.ee10.websocket.tests.CloseTrackingEndpoint;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -81,7 +79,7 @@ public class BadNetworkTest
|
|||
});
|
||||
context.addServlet(holder, "/ws");
|
||||
|
||||
server.setHandler(new HandlerList(context, new DefaultHandler()));
|
||||
server.setHandler(context);
|
||||
JettyWebSocketServletContainerInitializer.configure(context, null);
|
||||
|
||||
server.start();
|
||||
|
|
|
@ -41,8 +41,6 @@ import org.eclipse.jetty.io.EndPoint;
|
|||
import org.eclipse.jetty.io.EofException;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.eclipse.jetty.util.BlockingArrayQueue;
|
||||
import org.eclipse.jetty.websocket.core.CloseStatus;
|
||||
import org.eclipse.jetty.websocket.core.OpCode;
|
||||
|
@ -131,7 +129,7 @@ public class ClientCloseTest
|
|||
});
|
||||
context.addServlet(holder, "/ws");
|
||||
|
||||
server.setHandler(new HandlerList(context, new DefaultHandler()));
|
||||
server.setHandler(context);
|
||||
JettyWebSocketServletContainerInitializer.configure(context, null);
|
||||
|
||||
server.start();
|
||||
|
|
|
@ -36,8 +36,6 @@ import org.eclipse.jetty.ee10.websocket.tests.CloseTrackingEndpoint;
|
|||
import org.eclipse.jetty.ee10.websocket.tests.EchoCreator;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -74,7 +72,7 @@ public class ClientSessionsTest
|
|||
});
|
||||
context.addServlet(holder, "/ws");
|
||||
|
||||
server.setHandler(new HandlerList(context, new DefaultHandler()));
|
||||
server.setHandler(context);
|
||||
JettyWebSocketServletContainerInitializer.configure(context, null);
|
||||
|
||||
server.start();
|
||||
|
|
|
@ -30,8 +30,6 @@ import org.eclipse.jetty.ee10.websocket.tests.CloseTrackingEndpoint;
|
|||
import org.eclipse.jetty.ee10.websocket.tests.EchoSocket;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -76,7 +74,7 @@ public class SlowClientTest
|
|||
});
|
||||
context.addServlet(websocket, "/ws");
|
||||
|
||||
server.setHandler(new HandlerList(context, new DefaultHandler()));
|
||||
server.setHandler(context);
|
||||
JettyWebSocketServletContainerInitializer.configure(context, null);
|
||||
|
||||
server.start();
|
||||
|
|
|
@ -43,8 +43,6 @@ import org.eclipse.jetty.ee10.websocket.tests.CloseTrackingEndpoint;
|
|||
import org.eclipse.jetty.logging.StacklessLogging;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.websocket.core.OpCode;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
|
@ -85,7 +83,7 @@ public class FrameAnnotationTest
|
|||
context.addServlet(closeEndpoint, "/ws");
|
||||
JettyWebSocketServletContainerInitializer.configure(context, null);
|
||||
|
||||
server.setHandler(new HandlerList(context, new DefaultHandler()));
|
||||
server.setHandler(context);
|
||||
|
||||
server.start();
|
||||
}
|
||||
|
|
|
@ -36,8 +36,6 @@ import org.eclipse.jetty.ee10.websocket.tests.CloseTrackingEndpoint;
|
|||
import org.eclipse.jetty.logging.StacklessLogging;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.websocket.core.OpCode;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
|
@ -78,7 +76,7 @@ public class FrameListenerTest
|
|||
context.addServlet(closeEndpoint, "/ws");
|
||||
JettyWebSocketServletContainerInitializer.configure(context, null);
|
||||
|
||||
server.setHandler(new HandlerList(context, new DefaultHandler()));
|
||||
server.setHandler(context);
|
||||
|
||||
server.start();
|
||||
}
|
||||
|
|
|
@ -39,8 +39,6 @@ import org.eclipse.jetty.ee10.websocket.tests.CloseTrackingEndpoint;
|
|||
import org.eclipse.jetty.logging.StacklessLogging;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.websocket.core.internal.util.TextUtils;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
|
@ -81,7 +79,7 @@ public class PartialListenerTest
|
|||
context.addServlet(closeEndpoint, "/ws");
|
||||
JettyWebSocketServletContainerInitializer.configure(context, null);
|
||||
|
||||
server.setHandler(new HandlerList(context, new DefaultHandler()));
|
||||
server.setHandler(context);
|
||||
|
||||
server.start();
|
||||
}
|
||||
|
|
|
@ -33,8 +33,6 @@ import org.eclipse.jetty.ee10.websocket.tests.CloseTrackingEndpoint;
|
|||
import org.eclipse.jetty.logging.StacklessLogging;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.eclipse.jetty.websocket.core.internal.WebSocketCoreSession;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
@ -80,7 +78,7 @@ public class ServerCloseTest
|
|||
});
|
||||
context.addServlet(closeEndpoint, "/ws");
|
||||
|
||||
server.setHandler(new HandlerList(context, new DefaultHandler()));
|
||||
server.setHandler(context);
|
||||
JettyWebSocketServletContainerInitializer.configure(context, null);
|
||||
|
||||
server.start();
|
||||
|
|
|
@ -29,8 +29,6 @@ import org.eclipse.jetty.ee10.websocket.server.config.JettyWebSocketServletConta
|
|||
import org.eclipse.jetty.ee10.websocket.tests.CloseTrackingEndpoint;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -76,7 +74,7 @@ public class SlowServerTest
|
|||
});
|
||||
context.addServlet(websocket, "/ws");
|
||||
|
||||
server.setHandler(new HandlerList(context, new DefaultHandler()));
|
||||
server.setHandler(context);
|
||||
JettyWebSocketServletContainerInitializer.configure(context, null);
|
||||
|
||||
server.start();
|
||||
|
|
|
@ -34,7 +34,6 @@ import org.eclipse.jetty.server.handler.ContextHandler;
|
|||
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerCollection;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.eclipse.jetty.util.Scanner;
|
||||
import org.eclipse.jetty.util.resource.PathResource;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
|
@ -408,7 +407,7 @@ public class ServerProxyImpl implements ServerProxy
|
|||
contexts = new ContextHandlerCollection();
|
||||
HandlerCollection handlers = server.getChildHandlerByClass(HandlerCollection.class);
|
||||
if (handlers == null)
|
||||
server.setHandler(new HandlerList(contexts, new DefaultHandler()));
|
||||
server.setHandler(contexts);
|
||||
else
|
||||
handlers.addHandler(contexts);
|
||||
}
|
||||
|
|
|
@ -20,8 +20,6 @@ import org.eclipse.jetty.server.Handler;
|
|||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.Response;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.eclipse.jetty.server.handler.ResourceHandler;
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
|
||||
|
@ -59,9 +57,7 @@ public class FastFileServer
|
|||
{
|
||||
Server server = new Server(port);
|
||||
|
||||
server.setHandler(new HandlerList(
|
||||
new FastFileHandler(resourceBase),
|
||||
new DefaultHandler()));
|
||||
server.setHandler(new FastFileHandler(resourceBase));
|
||||
return server;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,9 +25,7 @@ import org.eclipse.jetty.ee9.servlet.ServletContextHandler;
|
|||
import org.eclipse.jetty.ee9.servlet.ServletHolder;
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.eclipse.jetty.util.FileID;
|
||||
import org.eclipse.jetty.util.URIUtil;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
|
|
|
@ -51,7 +51,7 @@ public class LikeJettyXml
|
|||
//
|
||||
// // Handler Structure
|
||||
// ContextHandlerCollection contexts = new ContextHandlerCollection();
|
||||
// server.setHandler(new HandlerList(contexts, new DefaultHandler()));
|
||||
// server.setHandler(contexts);
|
||||
//
|
||||
// // === jetty-jmx.xml ===
|
||||
// MBeanContainer mbContainer = new MBeanContainer(
|
||||
|
|
|
@ -16,27 +16,13 @@
|
|||
</Array>
|
||||
</Set>
|
||||
|
||||
<New id="context" class="org.eclipse.jetty.ee9.servlet.ServletContextHandler">
|
||||
<Set name="contextPath">/hello</Set>
|
||||
<Call name="addServlet">
|
||||
<Arg>org.eclipse.jetty.ee9.demos.HelloServlet</Arg>
|
||||
<Arg>/</Arg>
|
||||
</Call>
|
||||
<Get id="coreContextHandler" name="coreContextHandler"/>
|
||||
</New>
|
||||
|
||||
<Set name="handler">
|
||||
<New class="org.eclipse.jetty.server.Handler$Collection">
|
||||
<Set name="handlers">
|
||||
<Array type="org.eclipse.jetty.server.Handler">
|
||||
<Item>
|
||||
<Ref refid="coreContextHandler"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<New class="org.eclipse.jetty.server.handler.DefaultHandler" />
|
||||
</Item>
|
||||
</Array>
|
||||
</Set>
|
||||
<New id="context" class="org.eclipse.jetty.ee9.servlet.ServletContextHandler">
|
||||
<Set name="contextPath">/hello</Set>
|
||||
<Call name="addServlet">
|
||||
<Arg>org.eclipse.jetty.ee9.demos.HelloServlet</Arg>
|
||||
<Arg>/</Arg>
|
||||
</Call>
|
||||
</New>
|
||||
</Set>
|
||||
|
||||
|
|
|
@ -13,27 +13,15 @@
|
|||
</Arg>
|
||||
</Call>
|
||||
|
||||
<Set name="handler">
|
||||
<New class="org.eclipse.jetty.server.handler.HandlerList">
|
||||
<Set name="handlers">
|
||||
<Array type="org.eclipse.jetty.server.Handler">
|
||||
<Item>
|
||||
<New class="org.eclipse.jetty.server.handler.ResourceHandler">
|
||||
<Set name="baseResourceAsString"><Property name="fileserver.baseResource" default="."/></Set>
|
||||
<Set name="dirAllowed">true</Set>
|
||||
<Set name="welcomeFiles">
|
||||
<Array type="String">
|
||||
<Item>index.html</Item>
|
||||
</Array>
|
||||
</Set>
|
||||
</New>
|
||||
</Item>
|
||||
<Item>
|
||||
<New class="org.eclipse.jetty.server.handler.DefaultHandler">
|
||||
</New>
|
||||
</Item>
|
||||
</Array>
|
||||
</Set>
|
||||
</New>
|
||||
</Set>
|
||||
<Set name="handler">
|
||||
<New class="org.eclipse.jetty.server.handler.ResourceHandler">
|
||||
<Set name="baseResourceAsString"><Property name="fileserver.baseResource" default="."/></Set>
|
||||
<Set name="dirAllowed">true</Set>
|
||||
<Set name="welcomeFiles">
|
||||
<Array type="String">
|
||||
<Item>index.html</Item>
|
||||
</Array>
|
||||
</Set>
|
||||
</New>
|
||||
</Set>
|
||||
</Configure>
|
||||
|
|
|
@ -3,23 +3,11 @@
|
|||
<Configure id="Server" class="org.eclipse.jetty.server.Server">
|
||||
|
||||
<Set name="handler">
|
||||
<New id="Handlers" class="org.eclipse.jetty.server.Handler.Collection">
|
||||
<Set name="handlers">
|
||||
<Array type="org.eclipse.jetty.server.Handler">
|
||||
<Item>
|
||||
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
|
||||
</Item>
|
||||
</Array>
|
||||
</Set>
|
||||
</New>
|
||||
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
|
||||
</Set>
|
||||
|
||||
<Set name="stopAtShutdown" property="jetty.server.stopAtShutdown"/>
|
||||
<Set name="stopTimeout"><Property name="jetty.server.stopTimeout" default="5000"/></Set>
|
||||
<Set name="dumpAfterStart" property="jetty.server.dumpAfterStart"/>
|
||||
<Set name="dumpBeforeStop" property="jetty.server.dumpBeforeStop"/>
|
||||
|
||||
</Configure>
|
||||
|
|
|
@ -1,265 +0,0 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2022 Mort Bay Consulting Pty Ltd and others.
|
||||
//
|
||||
// This program and the accompanying materials are made available under the
|
||||
// terms of the Eclipse Public License v. 2.0 which is available at
|
||||
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
|
||||
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
|
||||
//
|
||||
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.ee9.nested;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketException;
|
||||
import java.net.URL;
|
||||
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.NetworkConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* A handler that shuts the server down on a valid request. Used to do "soft" restarts from Java.
|
||||
* If _exitJvm is set to true a hard System.exit() call is being made.
|
||||
* If _sendShutdownAtStart is set to true, starting the server will try to shut down an existing server at the same port.
|
||||
* If _sendShutdownAtStart is set to true, make an http call to
|
||||
* "http://localhost:" + port + "/shutdown?token=" + shutdownCookie
|
||||
* in order to shut down the server.
|
||||
*
|
||||
* This handler is a contribution from Johannes Brodwall: https://bugs.eclipse.org/bugs/show_bug.cgi?id=357687
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* <pre>
|
||||
* Server server = new Server(8080);
|
||||
* HandlerList handlers = new HandlerList();
|
||||
* handlers.setHandlers(new Handler[]
|
||||
* { someOtherHandler, new ShutdownHandler("secret password", false, true) });
|
||||
* server.setHandler(handlers);
|
||||
* server.start();
|
||||
* </pre>
|
||||
*
|
||||
* <pre>
|
||||
* public static void attemptShutdown(int port, String shutdownCookie) {
|
||||
* try {
|
||||
* URL url = new URL("http://localhost:" + port + "/shutdown?token=" + shutdownCookie);
|
||||
* HttpURLConnection connection = (HttpURLConnection)url.openConnection();
|
||||
* connection.setRequestMethod("POST");
|
||||
* connection.getResponseCode();
|
||||
* logger.info("Shutting down " + url + ": " + connection.getResponseMessage());
|
||||
* } catch (SocketException e) {
|
||||
* logger.debug("Not running");
|
||||
* // Okay - the server is not running
|
||||
* } catch (IOException e) {
|
||||
* throw new RuntimeException(e);
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*/
|
||||
public class ShutdownHandler extends HandlerWrapper
|
||||
{
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ShutdownHandler.class);
|
||||
|
||||
private final String _shutdownToken;
|
||||
private boolean _sendShutdownAtStart;
|
||||
private boolean _exitJvm = false;
|
||||
|
||||
/**
|
||||
* Creates a listener that lets the server be shut down remotely (but only from localhost).
|
||||
*
|
||||
* @param shutdownToken a secret password to avoid unauthorized shutdown attempts
|
||||
*/
|
||||
public ShutdownHandler(String shutdownToken)
|
||||
{
|
||||
this(shutdownToken, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param shutdownToken a secret password to avoid unauthorized shutdown attempts
|
||||
* @param exitJVM If true, when the shutdown is executed, the handler class System.exit()
|
||||
* @param sendShutdownAtStart If true, a shutdown is sent as an HTTP post
|
||||
* during startup, which will shutdown any previously running instances of
|
||||
* this server with an identically configured ShutdownHandler
|
||||
*/
|
||||
public ShutdownHandler(String shutdownToken, boolean exitJVM, boolean sendShutdownAtStart)
|
||||
{
|
||||
this._shutdownToken = shutdownToken;
|
||||
setExitJvm(exitJVM);
|
||||
setSendShutdownAtStart(sendShutdownAtStart);
|
||||
}
|
||||
|
||||
public void sendShutdown() throws IOException
|
||||
{
|
||||
URL url = new URL(getServerUrl() + "/shutdown?token=" + _shutdownToken);
|
||||
try
|
||||
{
|
||||
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
|
||||
connection.setRequestMethod("POST");
|
||||
connection.getResponseCode();
|
||||
LOG.info("Shutting down {}: {} {}", url, connection.getResponseCode(), connection.getResponseMessage());
|
||||
}
|
||||
catch (SocketException e)
|
||||
{
|
||||
LOG.debug("Not running");
|
||||
// Okay - the server is not running
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
private String getServerUrl()
|
||||
{
|
||||
NetworkConnector connector = null;
|
||||
for (Connector c : getServer().getConnectors())
|
||||
{
|
||||
if (c instanceof NetworkConnector)
|
||||
{
|
||||
connector = (NetworkConnector)c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (connector == null)
|
||||
return "http://localhost";
|
||||
|
||||
return "http://localhost:" + connector.getPort();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStart() throws Exception
|
||||
{
|
||||
super.doStart();
|
||||
if (_sendShutdownAtStart)
|
||||
sendShutdown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
||||
{
|
||||
if (!target.equals("/shutdown"))
|
||||
{
|
||||
super.handle(target, baseRequest, request, response);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!request.getMethod().equals("POST"))
|
||||
{
|
||||
response.sendError(HttpServletResponse.SC_BAD_REQUEST);
|
||||
return;
|
||||
}
|
||||
if (!hasCorrectSecurityToken(request))
|
||||
{
|
||||
LOG.warn("Unauthorized tokenless shutdown attempt from {}", request.getRemoteAddr());
|
||||
response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
|
||||
return;
|
||||
}
|
||||
if (!requestFromLocalhost(baseRequest))
|
||||
{
|
||||
LOG.warn("Unauthorized non-loopback shutdown attempt from {}", request.getRemoteAddr());
|
||||
response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
|
||||
return;
|
||||
}
|
||||
|
||||
LOG.info("Shutting down by request from {}", request.getRemoteAddr());
|
||||
doShutdown(baseRequest, response);
|
||||
}
|
||||
|
||||
protected void doShutdown(Request baseRequest, HttpServletResponse response) throws IOException
|
||||
{
|
||||
for (Connector connector : getServer().getConnectors())
|
||||
{
|
||||
connector.shutdown();
|
||||
}
|
||||
|
||||
baseRequest.setHandled(true);
|
||||
response.setStatus(200);
|
||||
response.flushBuffer();
|
||||
|
||||
final Server server = getServer();
|
||||
new Thread()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
shutdownServer(server);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
LOG.trace("IGNORED", e);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new RuntimeException("Shutting down server", e);
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
|
||||
private boolean requestFromLocalhost(Request request)
|
||||
{
|
||||
InetSocketAddress addr = request.getRemoteInetSocketAddress();
|
||||
if (addr == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return addr.getAddress().isLoopbackAddress();
|
||||
}
|
||||
|
||||
private boolean hasCorrectSecurityToken(HttpServletRequest request)
|
||||
{
|
||||
String tok = request.getParameter("token");
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Token: {}", tok);
|
||||
return _shutdownToken.equals(tok);
|
||||
}
|
||||
|
||||
private void shutdownServer(Server server) throws Exception
|
||||
{
|
||||
server.stop();
|
||||
|
||||
if (_exitJvm)
|
||||
{
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
public void setExitJvm(boolean exitJvm)
|
||||
{
|
||||
this._exitJvm = exitJvm;
|
||||
}
|
||||
|
||||
public boolean isSendShutdownAtStart()
|
||||
{
|
||||
return _sendShutdownAtStart;
|
||||
}
|
||||
|
||||
public void setSendShutdownAtStart(boolean sendShutdownAtStart)
|
||||
{
|
||||
_sendShutdownAtStart = sendShutdownAtStart;
|
||||
}
|
||||
|
||||
public String getShutdownToken()
|
||||
{
|
||||
return _shutdownToken;
|
||||
}
|
||||
|
||||
public boolean isExitJvm()
|
||||
{
|
||||
return _exitJvm;
|
||||
}
|
||||
}
|
|
@ -23,18 +23,7 @@
|
|||
<!-- Set handler Collection Structure -->
|
||||
<!-- =========================================================== -->
|
||||
<Set name="handler">
|
||||
<New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerList">
|
||||
<Set name="handlers">
|
||||
<Array type="org.eclipse.jetty.server.Handler">
|
||||
<Item>
|
||||
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
|
||||
</Item>
|
||||
</Array>
|
||||
</Set>
|
||||
</New>
|
||||
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
|
||||
</Set>
|
||||
|
||||
<New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
|
||||
|
|
|
@ -26,18 +26,7 @@
|
|||
<!-- Set handler Collection Structure -->
|
||||
<!-- =========================================================== -->
|
||||
<Set name="handler">
|
||||
<New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerList">
|
||||
<Set name="handlers">
|
||||
<Array type="org.eclipse.jetty.server.Handler">
|
||||
<Item>
|
||||
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
|
||||
</Item>
|
||||
</Array>
|
||||
</Set>
|
||||
</New>
|
||||
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
|
||||
</Set>
|
||||
|
||||
<New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
|
||||
|
|
|
@ -24,18 +24,7 @@
|
|||
<!-- Set handler Collection Structure -->
|
||||
<!-- =========================================================== -->
|
||||
<Set name="handler">
|
||||
<New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerList">
|
||||
<Set name="handlers">
|
||||
<Array type="org.eclipse.jetty.server.Handler">
|
||||
<Item>
|
||||
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
|
||||
</Item>
|
||||
</Array>
|
||||
</Set>
|
||||
</New>
|
||||
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
|
||||
</Set>
|
||||
|
||||
<New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
|
||||
|
|
|
@ -49,7 +49,6 @@ import org.eclipse.jetty.server.handler.ContextHandler;
|
|||
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerCollection;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.eclipse.jetty.server.handler.StatisticsHandler;
|
||||
import org.eclipse.jetty.session.SessionHandler;
|
||||
import org.eclipse.jetty.util.RolloverFileOutputStream;
|
||||
|
|
|
@ -36,7 +36,6 @@ import org.eclipse.jetty.ee9.nested.Request;
|
|||
import org.eclipse.jetty.ee9.nested.Response;
|
||||
import org.eclipse.jetty.logging.StacklessLogging;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.server.RequestLog;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
|
@ -277,15 +276,14 @@ public class ServletRequestLogTest
|
|||
}
|
||||
|
||||
/**
|
||||
* Test a RequestLogHandler at the end of a HandlerCollection.
|
||||
* This handler chain is setup to look like Jetty versions up to 9.2.
|
||||
* Test a RequestLog
|
||||
* Default configuration.
|
||||
*
|
||||
* @throws Exception on test failure
|
||||
*/
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
public void testLogHandlerCollection(Servlet testServlet, String requestPath, String expectedLogEntry) throws Exception
|
||||
public void testLogHandler(Servlet testServlet, String requestPath, String expectedLogEntry) throws Exception
|
||||
{
|
||||
Server server = new Server();
|
||||
ServerConnector connector = new ServerConnector(server);
|
||||
|
@ -293,15 +291,9 @@ public class ServletRequestLogTest
|
|||
server.setConnectors(new Connector[]{connector});
|
||||
|
||||
// First the behavior as defined in etc/jetty.xml
|
||||
// id="Handlers"
|
||||
org.eclipse.jetty.server.Handler.Collection handlers = new org.eclipse.jetty.server.Handler.Collection();
|
||||
// id="Contexts"
|
||||
ContextHandlerCollection contexts = new ContextHandlerCollection();
|
||||
// id="DefaultHandler"
|
||||
DefaultHandler defaultHandler = new DefaultHandler();
|
||||
|
||||
handlers.setHandlers(contexts, defaultHandler);
|
||||
server.setHandler(handlers);
|
||||
server.setDefaultHandler(new DefaultHandler());
|
||||
server.setHandler(contexts);
|
||||
|
||||
// Next the behavior as defined by etc/jetty-requestlog.xml
|
||||
// the id="RequestLog"
|
||||
|
@ -359,14 +351,14 @@ public class ServletRequestLogTest
|
|||
}
|
||||
|
||||
/**
|
||||
* Test a RequestLogHandler at the end of a HandlerCollection.
|
||||
* and also with the default ErrorHandler as server bean in place.
|
||||
* Test a RequestLogHandler
|
||||
* also with the default ErrorHandler as server bean in place.
|
||||
*
|
||||
* @throws Exception on test failure
|
||||
*/
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
public void testLogHandlerCollectionErrorHandlerServerBean(Servlet testServlet, String requestPath, String expectedLogEntry) throws Exception
|
||||
public void testLogHandlerErrorHandlerServerBean(Servlet testServlet, String requestPath, String expectedLogEntry) throws Exception
|
||||
{
|
||||
Server server = new Server();
|
||||
ServerConnector connector = new ServerConnector(server);
|
||||
|
@ -376,11 +368,10 @@ public class ServletRequestLogTest
|
|||
ErrorHandler errorHandler = new ErrorHandler();
|
||||
server.addBean(errorHandler);
|
||||
|
||||
// First the behavior as defined in etc/jetty.xml
|
||||
ContextHandlerCollection contexts = new ContextHandlerCollection();
|
||||
DefaultHandler defaultHandler = new DefaultHandler();
|
||||
Handler.Collection handlers = new Handler.Collection();
|
||||
handlers.setHandlers(contexts, defaultHandler);
|
||||
server.setHandler(handlers);
|
||||
server.setDefaultHandler(new DefaultHandler());
|
||||
server.setHandler(contexts);
|
||||
|
||||
// Next the behavior as defined by etc/jetty-requestlog.xml
|
||||
// the id="RequestLog"
|
||||
|
@ -438,24 +429,24 @@ public class ServletRequestLogTest
|
|||
}
|
||||
|
||||
/**
|
||||
* Test a RequestLogHandler at the end of a HandlerCollection
|
||||
* Test a RequestLog
|
||||
* using servlet specific error page mapping.
|
||||
*
|
||||
* @throws Exception on test failure
|
||||
*/
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
public void testLogHandlerCollectionSimpleErrorPageMapping(Servlet testServlet, String requestPath, String expectedLogEntry) throws Exception
|
||||
public void testLogHandlerSimpleErrorPageMapping(Servlet testServlet, String requestPath, String expectedLogEntry) throws Exception
|
||||
{
|
||||
Server server = new Server();
|
||||
ServerConnector connector = new ServerConnector(server);
|
||||
connector.setPort(0);
|
||||
server.setConnectors(new Connector[]{connector});
|
||||
|
||||
// First the behavior as defined in etc/jetty.xml
|
||||
ContextHandlerCollection contexts = new ContextHandlerCollection();
|
||||
Handler.Collection handlers = new Handler.Collection();
|
||||
handlers.setHandlers(contexts, new DefaultHandler());
|
||||
server.setHandler(handlers);
|
||||
server.setDefaultHandler(new DefaultHandler());
|
||||
server.setHandler(contexts);
|
||||
|
||||
// Next the behavior as defined by etc/jetty-requestlog.xml
|
||||
// the id="RequestLog"
|
||||
|
@ -532,14 +523,10 @@ public class ServletRequestLogTest
|
|||
connector.setPort(0);
|
||||
server.setConnectors(new Connector[]{connector});
|
||||
|
||||
// First the behavior as defined in etc/jetty.xml (as is)
|
||||
// id="Contexts"
|
||||
// First the behavior as defined in etc/jetty.xml
|
||||
ContextHandlerCollection contexts = new ContextHandlerCollection();
|
||||
// id="DefaultHandler"
|
||||
DefaultHandler defaultHandler = new DefaultHandler();
|
||||
Handler.Collection handlers = new Handler.Collection();
|
||||
handlers.setHandlers(contexts, defaultHandler);
|
||||
server.setHandler(handlers);
|
||||
server.setDefaultHandler(new DefaultHandler());
|
||||
server.setHandler(contexts);
|
||||
|
||||
// Next the proposed behavioral change to etc/jetty-requestlog.xml
|
||||
// the id="RequestLog"
|
||||
|
|
|
@ -46,7 +46,6 @@ import org.eclipse.jetty.server.ServerConnector;
|
|||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.eclipse.jetty.toolchain.test.FS;
|
||||
import org.eclipse.jetty.toolchain.test.IO;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
|
@ -107,7 +106,7 @@ public class DeploymentErrorTest
|
|||
server.addBean(deploymentManager);
|
||||
|
||||
// Server handlers
|
||||
server.setHandler(new HandlerList(contexts, new DefaultHandler()));
|
||||
server.setHandler(contexts);
|
||||
|
||||
// Setup Configurations
|
||||
Configurations.setServerDefault(server)
|
||||
|
|
|
@ -50,7 +50,6 @@ import org.eclipse.jetty.server.NetworkConnector;
|
|||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.eclipse.jetty.util.NanoTime;
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
|
@ -142,7 +141,7 @@ public class DigestPostTest
|
|||
|
||||
security.setConstraintMappings(Collections.singletonList(mapping));
|
||||
|
||||
_server.setHandler(new HandlerList(context, new DefaultHandler()));
|
||||
_server.setHandler(context);
|
||||
|
||||
_server.start();
|
||||
}
|
||||
|
|
|
@ -49,7 +49,6 @@ import org.eclipse.jetty.logging.StacklessLogging;
|
|||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
import org.eclipse.jetty.util.thread.Scheduler;
|
||||
|
@ -112,7 +111,7 @@ public class FailedSelectorTest
|
|||
ServletHolder closeHolder = new ServletHolder(new CloseSelectorServlet(connector));
|
||||
context.addServlet(closeHolder, "/selector/close");
|
||||
|
||||
server.setHandler(new HandlerList(context, new DefaultHandler()));
|
||||
server.setHandler(context);
|
||||
|
||||
server.start();
|
||||
}
|
||||
|
|
|
@ -20,25 +20,18 @@
|
|||
<!-- Set handler Collection Structure -->
|
||||
<!-- =========================================================== -->
|
||||
<Set name="handler">
|
||||
<New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerList">
|
||||
<Set name="handlers">
|
||||
<Array type="org.eclipse.jetty.server.Handler">
|
||||
<Item>
|
||||
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection" />
|
||||
</Item>
|
||||
<Item>
|
||||
<New id="defcontext" class="org.eclipse.jetty.server.handler.ContextHandler">
|
||||
<Set name="contextPath">/tests</Set>
|
||||
<Set name="baseResourceAsString"><Property name="test.docroot.base"/>/default
|
||||
</Set>
|
||||
<Set name="Handler">
|
||||
<New id="reshandler" class="org.eclipse.jetty.server.handler.ResourceHandler"/>
|
||||
</Set>
|
||||
<Set name="DisplayName">default</Set>
|
||||
</New>
|
||||
</Item>
|
||||
</Array>
|
||||
</Set>
|
||||
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection">
|
||||
<Call name="addHandler">
|
||||
<New id="defcontext" class="org.eclipse.jetty.server.handler.ContextHandler">
|
||||
<Set name="contextPath">/tests</Set>
|
||||
<Set name="baseResourceAsString"><Property name="test.docroot.base"/>/default
|
||||
</Set>
|
||||
<Set name="Handler">
|
||||
<New id="reshandler" class="org.eclipse.jetty.server.handler.ResourceHandler"/>
|
||||
</Set>
|
||||
<Set name="DisplayName">default</Set>
|
||||
</New>
|
||||
</Call>
|
||||
</New>
|
||||
</Set>
|
||||
|
||||
|
|
|
@ -9,70 +9,66 @@
|
|||
<!-- -->
|
||||
<!-- =============================================================== -->
|
||||
|
||||
|
||||
<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="sendServerVersion">true</Set>
|
||||
<Set name="sendDateHeader">false</Set>
|
||||
<Set name="headerCacheSize">1024</Set>
|
||||
<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="sendServerVersion">true</Set>
|
||||
<Set name="sendDateHeader">false</Set>
|
||||
<Set name="headerCacheSize">1024</Set>
|
||||
|
||||
<!-- Uncomment to enable handling of X-Forwarded- style headers
|
||||
<Call name="addCustomizer">
|
||||
<Arg><New class="org.eclipse.jetty.server.ForwardedRequestCustomizer"/></Arg>
|
||||
</Call>
|
||||
-->
|
||||
<!-- Uncomment to enable handling of X-Forwarded- style headers
|
||||
<Call name="addCustomizer">
|
||||
<Arg><New class="org.eclipse.jetty.server.ForwardedRequestCustomizer"/></Arg>
|
||||
</Call>
|
||||
-->
|
||||
</New>
|
||||
|
||||
<!-- =========================================================== -->
|
||||
<!-- Set handler Collection Structure -->
|
||||
<!-- =========================================================== -->
|
||||
<Set name="handler">
|
||||
<New id="WebappContexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection">
|
||||
<Arg>
|
||||
<Array type="org.eclipse.jetty.server.Handler">
|
||||
<Item>
|
||||
<New id="vcontexts" class="org.eclipse.jetty.server.handler.ContextHandler">
|
||||
<Set name="contextPath">/tests</Set>
|
||||
<Set name="VirtualHosts">
|
||||
<Array type="java.lang.String">
|
||||
<Item>VirtualHost</Item>
|
||||
</Array>
|
||||
</Set>
|
||||
<Set name="BaseResource"><Property name="test.docroot.base"/>/virtualhost</Set>
|
||||
<Set name="Handler"><New id="reshandler1" class="org.eclipse.jetty.server.handler.ResourceHandler"/></Set>
|
||||
<Set name="DisplayName">virtual</Set>
|
||||
</New>
|
||||
</Item>
|
||||
<Item>
|
||||
<New id="defcontext" class="org.eclipse.jetty.server.handler.ContextHandler">
|
||||
<Set name="contextPath">/tests</Set>
|
||||
<Set name="baseResourceAsString"><Property name="test.docroot.base"/>/default</Set>
|
||||
<Set name="Handler"><New id="reshandler2" class="org.eclipse.jetty.server.handler.ResourceHandler"/></Set>
|
||||
<Set name="DisplayName">default</Set>
|
||||
</New>
|
||||
</Item>
|
||||
<Item>
|
||||
<New id="echocontext" class="org.eclipse.jetty.server.handler.ContextHandler">
|
||||
<Set name="contextPath">/echo</Set>
|
||||
<Set name="Handler"><New id="echohandler" class="org.eclipse.jetty.test.support.EchoHandler"/></Set>
|
||||
<Set name="DisplayName">echo</Set>
|
||||
</New>
|
||||
</Item>
|
||||
</Array>
|
||||
</Arg>
|
||||
</New>
|
||||
</Set>
|
||||
|
||||
<!-- =========================================================== -->
|
||||
<!-- Set handler Collection Structure -->
|
||||
<!-- =========================================================== -->
|
||||
<Set name="handler">
|
||||
<New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerList">
|
||||
<Set name="handlers">
|
||||
<Array type="org.eclipse.jetty.server.Handler">
|
||||
<Item>
|
||||
<New id="WebappContexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<New id="vcontexts" class="org.eclipse.jetty.server.handler.ContextHandler">
|
||||
<Set name="contextPath">/tests</Set>
|
||||
<Set name="VirtualHosts">
|
||||
<Array type="java.lang.String">
|
||||
<Item>VirtualHost</Item>
|
||||
</Array>
|
||||
</Set>
|
||||
<Set name="BaseResource"><Property name="test.docroot.base"/>/virtualhost</Set>
|
||||
<Set name="Handler"><New id="reshandler1" class="org.eclipse.jetty.server.handler.ResourceHandler"/></Set>
|
||||
<Set name="DisplayName">virtual</Set>
|
||||
</New>
|
||||
</Item>
|
||||
<Item>
|
||||
<New id="defcontext" class="org.eclipse.jetty.server.handler.ContextHandler">
|
||||
<Set name="contextPath">/tests</Set>
|
||||
<Set name="baseResourceAsString"><Property name="test.docroot.base"/>/default</Set>
|
||||
<Set name="Handler"><New id="reshandler2" class="org.eclipse.jetty.server.handler.ResourceHandler"/></Set>
|
||||
<Set name="DisplayName">default</Set>
|
||||
</New>
|
||||
</Item>
|
||||
<Item>
|
||||
<New id="echocontext" class="org.eclipse.jetty.server.handler.ContextHandler">
|
||||
<Set name="contextPath">/echo</Set>
|
||||
<Set name="Handler"><New id="echohandler" class="org.eclipse.jetty.test.support.EchoHandler"/></Set>
|
||||
<Set name="DisplayName">echo</Set>
|
||||
</New>
|
||||
</Item>
|
||||
</Array>
|
||||
</Set>
|
||||
</New>
|
||||
</Set>
|
||||
|
||||
<Call name="addBean">
|
||||
<Call name="addBean">
|
||||
<Arg>
|
||||
<New id="DeploymentManager" class="org.eclipse.jetty.deploy.DeploymentManager">
|
||||
<Set name="contexts">
|
||||
|
|
|
@ -19,18 +19,7 @@
|
|||
<!-- Set handler Collection Structure -->
|
||||
<!-- =========================================================== -->
|
||||
<Set name="handler">
|
||||
<New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerList">
|
||||
<Set name="handlers">
|
||||
<Array type="org.eclipse.jetty.server.Handler">
|
||||
<Item>
|
||||
<New id="WebappContexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection" />
|
||||
</Item>
|
||||
<Item>
|
||||
<New id="defcontext" class="org.eclipse.jetty.server.handler.DefaultHandler" />
|
||||
</Item>
|
||||
</Array>
|
||||
</Set>
|
||||
</New>
|
||||
<New id="WebappContexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection" />
|
||||
</Set>
|
||||
|
||||
<!-- =========================================================== -->
|
||||
|
|
|
@ -37,7 +37,6 @@ import org.eclipse.jetty.ee9.servlet.ServletContextHandler;
|
|||
import org.eclipse.jetty.ee9.servlet.ServletHolder;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.eclipse.jetty.toolchain.test.FS;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.eclipse.jetty.util.security.Constraint;
|
||||
|
|
|
@ -20,8 +20,6 @@ import org.eclipse.jetty.ee9.websocket.jakarta.tests.framehandlers.FrameEcho;
|
|||
import org.eclipse.jetty.ee9.websocket.jakarta.tests.framehandlers.WholeMessageEcho;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
import org.eclipse.jetty.util.component.ContainerLifeCycle;
|
||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
|
@ -61,7 +59,7 @@ public class CoreServer extends ContainerLifeCycle
|
|||
// Add Handler
|
||||
WebSocketUpgradeHandler upgradeHandler = new WebSocketUpgradeHandler();
|
||||
upgradeHandler.addMapping("/*", negotiator);
|
||||
server.setHandler(new HandlerList(upgradeHandler, new DefaultHandler()));
|
||||
server.setHandler(upgradeHandler);
|
||||
|
||||
// Start Server
|
||||
addBean(server);
|
||||
|
|
|
@ -32,8 +32,6 @@ import org.eclipse.jetty.ee9.websocket.jakarta.server.config.JakartaWebSocketSer
|
|||
import org.eclipse.jetty.ee9.websocket.jakarta.server.internal.JakartaWebSocketServerContainer;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
@ -67,7 +65,7 @@ public class RestartContextTest
|
|||
context.addEventListener(new AddEndpointListener());
|
||||
|
||||
// Setup handler tree
|
||||
server.setHandler(new HandlerList(context.getCoreContextHandler(), new DefaultHandler()));
|
||||
server.setHandler(context.getCoreContextHandler());
|
||||
|
||||
// Start server
|
||||
server.start();
|
||||
|
@ -103,11 +101,8 @@ public class RestartContextTest
|
|||
serverContainer.addEndpoint(EchoEndpoint.class);
|
||||
});
|
||||
|
||||
// Setup handler tree
|
||||
HandlerList handlers = new HandlerList(context.getCoreContextHandler(), new DefaultHandler());
|
||||
|
||||
// Add handler tree to server
|
||||
server.setHandler(handlers);
|
||||
// Add context to server
|
||||
server.setHandler(context);
|
||||
|
||||
// Start server
|
||||
server.start();
|
||||
|
|
|
@ -34,8 +34,6 @@ import org.eclipse.jetty.ee9.websocket.server.JettyWebSocketServletFactory;
|
|||
import org.eclipse.jetty.ee9.websocket.server.config.JettyWebSocketServletContainerInitializer;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.util.resource.ResourceFactory;
|
||||
|
@ -109,7 +107,7 @@ public class BrowserDebugTool
|
|||
ServletHolder defHolder = new ServletHolder("default", DefaultServlet.class);
|
||||
context.addServlet(defHolder, "/");
|
||||
|
||||
server.setHandler(new HandlerList(context.getCoreContextHandler(), new DefaultHandler()));
|
||||
server.setHandler(context.getCoreContextHandler());
|
||||
|
||||
LOG.info("{} setup on port {}", this.getClass().getName(), port);
|
||||
}
|
||||
|
|
|
@ -32,8 +32,6 @@ import org.eclipse.jetty.ee9.websocket.server.config.JettyWebSocketServletContai
|
|||
import org.eclipse.jetty.ee9.websocket.tests.CloseTrackingEndpoint;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -81,7 +79,7 @@ public class BadNetworkTest
|
|||
});
|
||||
context.addServlet(holder, "/ws");
|
||||
|
||||
server.setHandler(new HandlerList(context.getCoreContextHandler(), new DefaultHandler()));
|
||||
server.setHandler(context.getCoreContextHandler());
|
||||
JettyWebSocketServletContainerInitializer.configure(context, null);
|
||||
|
||||
server.start();
|
||||
|
|
|
@ -41,8 +41,6 @@ import org.eclipse.jetty.io.EndPoint;
|
|||
import org.eclipse.jetty.io.EofException;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.eclipse.jetty.util.BlockingArrayQueue;
|
||||
import org.eclipse.jetty.websocket.core.CloseStatus;
|
||||
import org.eclipse.jetty.websocket.core.OpCode;
|
||||
|
@ -131,7 +129,7 @@ public class ClientCloseTest
|
|||
});
|
||||
context.addServlet(holder, "/ws");
|
||||
|
||||
server.setHandler(new HandlerList(context.getCoreContextHandler(), new DefaultHandler()));
|
||||
server.setHandler(context.getCoreContextHandler());
|
||||
JettyWebSocketServletContainerInitializer.configure(context, null);
|
||||
|
||||
server.start();
|
||||
|
|
|
@ -36,8 +36,6 @@ import org.eclipse.jetty.ee9.websocket.tests.CloseTrackingEndpoint;
|
|||
import org.eclipse.jetty.ee9.websocket.tests.EchoCreator;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -74,7 +72,7 @@ public class ClientSessionsTest
|
|||
});
|
||||
context.addServlet(holder, "/ws");
|
||||
|
||||
server.setHandler(new HandlerList(context.getCoreContextHandler(), new DefaultHandler()));
|
||||
server.setHandler(context.getCoreContextHandler());
|
||||
JettyWebSocketServletContainerInitializer.configure(context, null);
|
||||
|
||||
server.start();
|
||||
|
|
|
@ -30,8 +30,6 @@ import org.eclipse.jetty.ee9.websocket.tests.CloseTrackingEndpoint;
|
|||
import org.eclipse.jetty.ee9.websocket.tests.EchoSocket;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -76,7 +74,7 @@ public class SlowClientTest
|
|||
});
|
||||
context.addServlet(websocket, "/ws");
|
||||
|
||||
server.setHandler(new HandlerList(context.getCoreContextHandler(), new DefaultHandler()));
|
||||
server.setHandler(context.getCoreContextHandler());
|
||||
JettyWebSocketServletContainerInitializer.configure(context, null);
|
||||
|
||||
server.start();
|
||||
|
|
|
@ -43,8 +43,6 @@ import org.eclipse.jetty.ee9.websocket.tests.CloseTrackingEndpoint;
|
|||
import org.eclipse.jetty.logging.StacklessLogging;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.websocket.core.OpCode;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
|
@ -85,7 +83,7 @@ public class FrameAnnotationTest
|
|||
context.addServlet(closeEndpoint, "/ws");
|
||||
JettyWebSocketServletContainerInitializer.configure(context, null);
|
||||
|
||||
server.setHandler(new HandlerList(context.getCoreContextHandler(), new DefaultHandler()));
|
||||
server.setHandler(context.getCoreContextHandler());
|
||||
|
||||
server.start();
|
||||
}
|
||||
|
|
|
@ -36,8 +36,6 @@ import org.eclipse.jetty.ee9.websocket.tests.CloseTrackingEndpoint;
|
|||
import org.eclipse.jetty.logging.StacklessLogging;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.websocket.core.OpCode;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
|
@ -78,7 +76,7 @@ public class FrameListenerTest
|
|||
context.addServlet(closeEndpoint, "/ws");
|
||||
JettyWebSocketServletContainerInitializer.configure(context, null);
|
||||
|
||||
server.setHandler(new HandlerList(context.getCoreContextHandler(), new DefaultHandler()));
|
||||
server.setHandler(context.getCoreContextHandler());
|
||||
|
||||
server.start();
|
||||
}
|
||||
|
|
|
@ -39,8 +39,6 @@ import org.eclipse.jetty.ee9.websocket.tests.CloseTrackingEndpoint;
|
|||
import org.eclipse.jetty.logging.StacklessLogging;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.websocket.core.internal.util.TextUtils;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
|
@ -81,7 +79,7 @@ public class PartialListenerTest
|
|||
context.addServlet(closeEndpoint, "/ws");
|
||||
JettyWebSocketServletContainerInitializer.configure(context, null);
|
||||
|
||||
server.setHandler(new HandlerList(context.getCoreContextHandler(), new DefaultHandler()));
|
||||
server.setHandler(context.getCoreContextHandler());
|
||||
|
||||
server.start();
|
||||
}
|
||||
|
|
|
@ -33,8 +33,6 @@ import org.eclipse.jetty.ee9.websocket.tests.CloseTrackingEndpoint;
|
|||
import org.eclipse.jetty.logging.StacklessLogging;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.eclipse.jetty.websocket.core.internal.WebSocketCoreSession;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
@ -80,7 +78,7 @@ public class ServerCloseTest
|
|||
});
|
||||
context.addServlet(closeEndpoint, "/ws");
|
||||
|
||||
server.setHandler(new HandlerList(context.getCoreContextHandler(), new DefaultHandler()));
|
||||
server.setHandler(context.getCoreContextHandler());
|
||||
JettyWebSocketServletContainerInitializer.configure(context, null);
|
||||
|
||||
server.start();
|
||||
|
|
|
@ -29,8 +29,6 @@ import org.eclipse.jetty.ee9.websocket.server.config.JettyWebSocketServletContai
|
|||
import org.eclipse.jetty.ee9.websocket.tests.CloseTrackingEndpoint;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -76,7 +74,7 @@ public class SlowServerTest
|
|||
});
|
||||
context.addServlet(websocket, "/ws");
|
||||
|
||||
server.setHandler(new HandlerList(context.getCoreContextHandler(), new DefaultHandler()));
|
||||
server.setHandler(context.getCoreContextHandler());
|
||||
JettyWebSocketServletContainerInitializer.configure(context, null);
|
||||
|
||||
server.start();
|
||||
|
|
Loading…
Reference in New Issue