Re-enabled the documentation module. (#8326)
Re-enabled the documentation module. Now using ee10 rather than ee9. Updated sources to reference ee10 implementation classes. Now -DskipTests will compile the documentation classes but not build the documentation, saving time when building. Much more work to do to update the documentation for Jetty 12. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
parent
8cb09e4c59
commit
e4de4fd189
|
@ -33,7 +33,7 @@
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.tests</groupId>
|
||||
<artifactId>test-distribution</artifactId>
|
||||
<artifactId>test-distribution-common</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -11,7 +11,9 @@
|
|||
<name>Jetty :: Documentation</name>
|
||||
<packaging>jar</packaging>
|
||||
<properties>
|
||||
<ee.version>ee9</ee.version>
|
||||
<assembly.skipAssembly>${skipTests}</assembly.skipAssembly>
|
||||
<asciidoctor.skip>${skipTests}</asciidoctor.skip>
|
||||
<ee.version>ee10</ee.version>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
|
@ -158,10 +160,6 @@
|
|||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.toolchain</groupId>
|
||||
<artifactId>jetty-jakarta-servlet-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-alpn-server</artifactId>
|
||||
|
@ -236,16 +234,16 @@
|
|||
<artifactId>jetty-nosql</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.ee9.websocket</groupId>
|
||||
<artifactId>jetty-ee9-websocket-jetty-client</artifactId>
|
||||
<groupId>org.eclipse.jetty.${ee.version}.websocket</groupId>
|
||||
<artifactId>jetty-${ee.version}-websocket-jetty-client</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.ee9.websocket</groupId>
|
||||
<artifactId>jetty-ee9-websocket-jakarta-server</artifactId>
|
||||
<groupId>org.eclipse.jetty.${ee.version}.websocket</groupId>
|
||||
<artifactId>jetty-${ee.version}-websocket-jakarta-server</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.ee9.websocket</groupId>
|
||||
<artifactId>jetty-ee9-websocket-jetty-server</artifactId>
|
||||
<groupId>org.eclipse.jetty.${ee.version}.websocket</groupId>
|
||||
<artifactId>jetty-${ee.version}-websocket-jetty-server</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -41,12 +41,11 @@ The corresponding `Handler` tree structure looks like the following:
|
|||
|
||||
[source,screen]
|
||||
----
|
||||
HandlerCollection
|
||||
├── HandlerList
|
||||
│ ├── App1Handler
|
||||
│ └── HandlerWrapper
|
||||
│ └── App2Handler
|
||||
Server
|
||||
└── LoggingHandler
|
||||
└── Handler.Collection
|
||||
├── App1Handler
|
||||
└── App2Handler
|
||||
----
|
||||
|
||||
Server applications should rarely write custom ``Handler``s, preferring instead to use existing ``Handler``s provided by the Jetty Server Libraries for managing web application contexts, security, HTTP sessions and Servlet support.
|
||||
|
|
|
@ -20,18 +20,18 @@ import java.nio.ByteBuffer;
|
|||
import java.nio.file.Path;
|
||||
import java.time.Duration;
|
||||
|
||||
import org.eclipse.jetty.ee9.websocket.api.RemoteEndpoint;
|
||||
import org.eclipse.jetty.ee9.websocket.api.Session;
|
||||
import org.eclipse.jetty.ee9.websocket.api.StatusCode;
|
||||
import org.eclipse.jetty.ee9.websocket.api.WebSocketListener;
|
||||
import org.eclipse.jetty.ee9.websocket.api.WebSocketPartialListener;
|
||||
import org.eclipse.jetty.ee9.websocket.api.WebSocketPingPongListener;
|
||||
import org.eclipse.jetty.ee9.websocket.api.WriteCallback;
|
||||
import org.eclipse.jetty.ee9.websocket.api.annotations.OnWebSocketClose;
|
||||
import org.eclipse.jetty.ee9.websocket.api.annotations.OnWebSocketConnect;
|
||||
import org.eclipse.jetty.ee9.websocket.api.annotations.OnWebSocketError;
|
||||
import org.eclipse.jetty.ee9.websocket.api.annotations.OnWebSocketMessage;
|
||||
import org.eclipse.jetty.ee9.websocket.api.annotations.WebSocket;
|
||||
import org.eclipse.jetty.ee10.websocket.api.RemoteEndpoint;
|
||||
import org.eclipse.jetty.ee10.websocket.api.Session;
|
||||
import org.eclipse.jetty.ee10.websocket.api.StatusCode;
|
||||
import org.eclipse.jetty.ee10.websocket.api.WebSocketListener;
|
||||
import org.eclipse.jetty.ee10.websocket.api.WebSocketPartialListener;
|
||||
import org.eclipse.jetty.ee10.websocket.api.WebSocketPingPongListener;
|
||||
import org.eclipse.jetty.ee10.websocket.api.WriteCallback;
|
||||
import org.eclipse.jetty.ee10.websocket.api.annotations.OnWebSocketClose;
|
||||
import org.eclipse.jetty.ee10.websocket.api.annotations.OnWebSocketConnect;
|
||||
import org.eclipse.jetty.ee10.websocket.api.annotations.OnWebSocketError;
|
||||
import org.eclipse.jetty.ee10.websocket.api.annotations.OnWebSocketMessage;
|
||||
import org.eclipse.jetty.ee10.websocket.api.annotations.WebSocket;
|
||||
import org.eclipse.jetty.util.IteratingCallback;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
|
|
|
@ -341,7 +341,7 @@ public class HTTPClientDocs
|
|||
|
||||
// Offer the content, and release the ByteBuffer
|
||||
// to the pool when the Callback is completed.
|
||||
content.offer(buffer, Callback.from(() -> bufferPool.release(buffer)));
|
||||
content.write(buffer, Callback.from(() -> bufferPool.release(buffer)));
|
||||
|
||||
// Close AsyncRequestContent when all the content is arrived.
|
||||
if (lastContent)
|
||||
|
@ -489,7 +489,7 @@ public class HTTPClientDocs
|
|||
public void onContent(Response response, LongConsumer demand, ByteBuffer content, Callback callback)
|
||||
{
|
||||
// When response content is received from server1, forward it to server2.
|
||||
content2.offer(content, Callback.from(() ->
|
||||
content2.write(content, Callback.from(() ->
|
||||
{
|
||||
// When the request content to server2 is sent,
|
||||
// succeed the callback to recycle the buffer.
|
||||
|
|
|
@ -22,10 +22,10 @@ import org.eclipse.jetty.client.HttpProxy;
|
|||
import org.eclipse.jetty.client.HttpRequest;
|
||||
import org.eclipse.jetty.client.HttpResponse;
|
||||
import org.eclipse.jetty.client.dynamic.HttpClientTransportDynamic;
|
||||
import org.eclipse.jetty.ee9.websocket.api.Session;
|
||||
import org.eclipse.jetty.ee9.websocket.client.ClientUpgradeRequest;
|
||||
import org.eclipse.jetty.ee9.websocket.client.JettyUpgradeListener;
|
||||
import org.eclipse.jetty.ee9.websocket.client.WebSocketClient;
|
||||
import org.eclipse.jetty.ee10.websocket.api.Session;
|
||||
import org.eclipse.jetty.ee10.websocket.client.ClientUpgradeRequest;
|
||||
import org.eclipse.jetty.ee10.websocket.client.JettyUpgradeListener;
|
||||
import org.eclipse.jetty.ee10.websocket.client.WebSocketClient;
|
||||
import org.eclipse.jetty.http2.client.HTTP2Client;
|
||||
import org.eclipse.jetty.http2.client.http.ClientConnectionFactoryOverHTTP2;
|
||||
import org.eclipse.jetty.http2.client.http.HttpClientTransportOverHTTP2;
|
||||
|
|
|
@ -15,10 +15,8 @@ package org.eclipse.jetty.docs.programming.server;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.Flow;
|
||||
|
||||
|
@ -35,6 +33,7 @@ import org.eclipse.jetty.util.Callback;
|
|||
import org.eclipse.jetty.util.URIUtil;
|
||||
import org.eclipse.jetty.util.thread.SerializedInvoker;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class HandlerDocs
|
||||
{
|
||||
// TODO this class has been temporarily moved to jetty-core/jetty-demo
|
||||
|
|
|
@ -16,61 +16,56 @@ package org.eclipse.jetty.docs.programming.server.http;
|
|||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
import jakarta.servlet.DispatcherType;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.ServletInputStream;
|
||||
import jakarta.servlet.http.HttpServlet;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory;
|
||||
import org.eclipse.jetty.ee9.servlet.DefaultServlet;
|
||||
import org.eclipse.jetty.ee9.servlet.FilterHolder;
|
||||
import org.eclipse.jetty.ee9.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.ee9.servlet.ServletHolder;
|
||||
import org.eclipse.jetty.ee9.servlets.CrossOriginFilter;
|
||||
import org.eclipse.jetty.ee9.webapp.WebAppContext;
|
||||
import org.eclipse.jetty.ee10.servlet.DefaultServlet;
|
||||
import org.eclipse.jetty.ee10.servlet.FilterHolder;
|
||||
import org.eclipse.jetty.ee10.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.ee10.servlet.ServletHolder;
|
||||
import org.eclipse.jetty.ee10.servlets.CrossOriginFilter;
|
||||
import org.eclipse.jetty.ee10.webapp.WebAppContext;
|
||||
import org.eclipse.jetty.http.HttpCompliance;
|
||||
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;
|
||||
import org.eclipse.jetty.http3.server.HTTP3ServerConnector;
|
||||
import org.eclipse.jetty.io.Content;
|
||||
import org.eclipse.jetty.rewrite.handler.CompactPathRule;
|
||||
import org.eclipse.jetty.rewrite.handler.RedirectRegexRule;
|
||||
import org.eclipse.jetty.rewrite.handler.RewriteHandler;
|
||||
import org.eclipse.jetty.rewrite.handler.RewriteRegexRule;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.CustomRequestLog;
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.server.HttpConfiguration;
|
||||
import org.eclipse.jetty.server.HttpConnectionFactory;
|
||||
import org.eclipse.jetty.server.ProxyConnectionFactory;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.RequestLogWriter;
|
||||
import org.eclipse.jetty.server.Response;
|
||||
import org.eclipse.jetty.server.SecureRequestCustomizer;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.Slf4jRequestLogWriter;
|
||||
import org.eclipse.jetty.server.SslConnectionFactory;
|
||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
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.HandlerWrapper;
|
||||
import org.eclipse.jetty.server.handler.RequestLogHandler;
|
||||
import org.eclipse.jetty.server.handler.ResourceHandler;
|
||||
import org.eclipse.jetty.server.handler.SecuredRedirectHandler;
|
||||
import org.eclipse.jetty.server.handler.StatisticsHandler;
|
||||
import org.eclipse.jetty.server.handler.gzip.GzipHandler;
|
||||
import org.eclipse.jetty.server.internal.HttpChannelState;
|
||||
import org.eclipse.jetty.unixdomain.server.UnixDomainServerConnector;
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
|
@ -78,8 +73,6 @@ import org.eclipse.jetty.util.resource.ResourceCollection;
|
|||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
|
||||
import static java.lang.System.Logger.Level.INFO;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class HTTPServerDocs
|
||||
{
|
||||
|
@ -100,14 +93,13 @@ public class HTTPServerDocs
|
|||
server.addConnector(connector);
|
||||
|
||||
// Set a simple Handler to handle requests/responses.
|
||||
server.setHandler(new AbstractHandler()
|
||||
server.setHandler(new Handler.Processor()
|
||||
{
|
||||
@Override
|
||||
public void handle(String target, Request jettyRequest, HttpServletRequest request, HttpServletResponse response)
|
||||
public void process(Request request, Response response, Callback callback)
|
||||
{
|
||||
// Mark the request as handled so that it
|
||||
// will not be processed by other handlers.
|
||||
jettyRequest.setHandled(true);
|
||||
// Succeed the callback to write the response.
|
||||
callback.succeeded();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -119,6 +111,8 @@ public class HTTPServerDocs
|
|||
public void httpChannelListener() throws Exception
|
||||
{
|
||||
// tag::httpChannelListener[]
|
||||
// TODO: HttpChannelState.Listener does not exist anymore.
|
||||
/*
|
||||
class TimingHttpChannelListener implements HttpChannelState.Listener
|
||||
{
|
||||
private final ConcurrentMap<Request, Long> times = new ConcurrentHashMap<>();
|
||||
|
@ -157,6 +151,7 @@ public class HTTPServerDocs
|
|||
});
|
||||
|
||||
server.start();
|
||||
*/
|
||||
// end::httpChannelListener[]
|
||||
}
|
||||
|
||||
|
@ -197,6 +192,8 @@ public class HTTPServerDocs
|
|||
mainContext.setContextPath("/main");
|
||||
|
||||
// Create a RequestLogHandler to log requests for your main application.
|
||||
// TODO: RequestLogHandler may need to be re-introduced, to allow per-context logging?
|
||||
/*
|
||||
RequestLogHandler requestLogHandler = new RequestLogHandler();
|
||||
requestLogHandler.setRequestLog(new CustomRequestLog());
|
||||
// Wrap the main application with the request log handler.
|
||||
|
@ -208,6 +205,7 @@ public class HTTPServerDocs
|
|||
mainContext.setContextPath("/other");
|
||||
|
||||
server.setHandler(new HandlerList(requestLogHandler, otherContext));
|
||||
*/
|
||||
// end::contextRequestLog[]
|
||||
}
|
||||
|
||||
|
@ -475,27 +473,30 @@ public class HTTPServerDocs
|
|||
|
||||
public void handlerTree()
|
||||
{
|
||||
class LoggingHandler extends AbstractHandler
|
||||
class LoggingHandler extends Handler.Processor
|
||||
{
|
||||
@Override
|
||||
public void handle(String target, Request jettyRequest, HttpServletRequest request, HttpServletResponse response)
|
||||
public void process(Request request, Response response, Callback callback) throws Exception
|
||||
{
|
||||
callback.succeeded();
|
||||
}
|
||||
}
|
||||
|
||||
class App1Handler extends AbstractHandler
|
||||
class App1Handler extends Handler.Processor
|
||||
{
|
||||
@Override
|
||||
public void handle(String target, Request jettyRequest, HttpServletRequest request, HttpServletResponse response)
|
||||
public void process(Request request, Response response, Callback callback) throws Exception
|
||||
{
|
||||
callback.succeeded();
|
||||
}
|
||||
}
|
||||
|
||||
class App2Handler extends HandlerWrapper
|
||||
class App2Handler extends Handler.Processor
|
||||
{
|
||||
@Override
|
||||
public void handle(String target, Request jettyRequest, HttpServletRequest request, HttpServletResponse response)
|
||||
public void process(Request request, Response response, Callback callback) throws Exception
|
||||
{
|
||||
callback.succeeded();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -503,29 +504,23 @@ public class HTTPServerDocs
|
|||
// Create a Server instance.
|
||||
Server server = new Server();
|
||||
|
||||
HandlerCollection collection = new HandlerCollection();
|
||||
LoggingHandler loggingHandler = new LoggingHandler();
|
||||
// Link the root Handler with the Server.
|
||||
server.setHandler(collection);
|
||||
server.setHandler(loggingHandler);
|
||||
|
||||
HandlerList list = new HandlerList();
|
||||
collection.addHandler(list);
|
||||
collection.addHandler(new LoggingHandler());
|
||||
|
||||
list.addHandler(new App1Handler());
|
||||
HandlerWrapper wrapper = new HandlerWrapper();
|
||||
list.addHandler(wrapper);
|
||||
|
||||
wrapper.setHandler(new App2Handler());
|
||||
Handler.Collection collection = new Handler.Collection();
|
||||
collection.addHandler(new App1Handler());
|
||||
collection.addHandler(new App2Handler());
|
||||
// end::handlerTree[]
|
||||
}
|
||||
|
||||
public void handlerAPI()
|
||||
{
|
||||
class MyHandler extends AbstractHandler
|
||||
class MyHandler extends Handler.Processor
|
||||
{
|
||||
@Override
|
||||
// tag::handlerAPI[]
|
||||
public void handle(String target, Request jettyRequest, HttpServletRequest request, HttpServletResponse response)
|
||||
public void process(Request request, Response response, Callback callback) throws Exception
|
||||
{
|
||||
}
|
||||
// end::handlerAPI[]
|
||||
|
@ -535,29 +530,26 @@ public class HTTPServerDocs
|
|||
public void handlerHello() throws Exception
|
||||
{
|
||||
// tag::handlerHello[]
|
||||
class HelloWorldHandler extends AbstractHandler
|
||||
class HelloWorldHandler extends Handler.Processor
|
||||
{
|
||||
@Override
|
||||
public void handle(String target, Request jettyRequest, HttpServletRequest request, HttpServletResponse response) throws IOException
|
||||
public void process(Request request, Response response, Callback callback)
|
||||
{
|
||||
// Mark the request as handled by this Handler.
|
||||
jettyRequest.setHandled(true);
|
||||
|
||||
response.setStatus(200);
|
||||
response.setContentType("text/html; charset=UTF-8");
|
||||
response.getHeaders().put(HttpHeader.CONTENT_TYPE, "text/html; charset=UTF-8");
|
||||
|
||||
// Write a Hello World response.
|
||||
response.getWriter().print("" +
|
||||
"<!DOCTYPE html>" +
|
||||
"<html>" +
|
||||
"<head>" +
|
||||
" <title>Jetty Hello World Handler</title>" +
|
||||
"</head>" +
|
||||
"<body>" +
|
||||
" <p>Hello World</p>" +
|
||||
"</body>" +
|
||||
"</html>" +
|
||||
"");
|
||||
Content.Sink.write(response, true, """
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Jetty Hello World Handler</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Hello World</p>
|
||||
</body>
|
||||
</html>
|
||||
""", callback);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -574,15 +566,17 @@ public class HTTPServerDocs
|
|||
|
||||
public void handlerFilter() throws Exception
|
||||
{
|
||||
class HelloWorldHandler extends AbstractHandler
|
||||
class HelloWorldHandler extends Handler.Processor
|
||||
{
|
||||
@Override
|
||||
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
|
||||
public void process(Request request, Response response, Callback callback)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// tag::handlerFilter[]
|
||||
// TODO: This needs to be rewritten using a custom Processor
|
||||
/*
|
||||
class FilterHandler extends HandlerWrapper
|
||||
{
|
||||
@Override
|
||||
|
@ -617,19 +611,19 @@ public class HTTPServerDocs
|
|||
server.setHandler(filter);
|
||||
|
||||
server.start();
|
||||
*/
|
||||
// end::handlerFilter[]
|
||||
}
|
||||
|
||||
public void contextHandler() throws Exception
|
||||
{
|
||||
// tag::contextHandler[]
|
||||
class ShopHandler extends AbstractHandler
|
||||
class ShopHandler extends Handler.Processor
|
||||
{
|
||||
@Override
|
||||
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
|
||||
public void process(Request request, Response response, Callback callback) throws Exception
|
||||
{
|
||||
baseRequest.setHandled(true);
|
||||
// Implement the shop.
|
||||
// Implement the shop, remembering to complete the callback.
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -652,23 +646,21 @@ public class HTTPServerDocs
|
|||
public void contextHandlerCollection() throws Exception
|
||||
{
|
||||
// tag::contextHandlerCollection[]
|
||||
class ShopHandler extends AbstractHandler
|
||||
class ShopHandler extends Handler.Processor
|
||||
{
|
||||
@Override
|
||||
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
|
||||
public void process(Request request, Response response, Callback callback) throws Exception
|
||||
{
|
||||
baseRequest.setHandled(true);
|
||||
// Implement the shop.
|
||||
// Implement the shop, remembering to complete the callback.
|
||||
}
|
||||
}
|
||||
|
||||
class RESTHandler extends AbstractHandler
|
||||
class RESTHandler extends Handler.Processor
|
||||
{
|
||||
@Override
|
||||
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
|
||||
public void process(Request request, Response response, Callback callback) throws Exception
|
||||
{
|
||||
baseRequest.setHandled(true);
|
||||
// Implement the REST APIs.
|
||||
// Implement the REST APIs, remembering to complete the callback.
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -767,9 +759,10 @@ public class HTTPServerDocs
|
|||
// Configure the directory where static resources are located.
|
||||
handler.setBaseResource(Resource.newResource("/path/to/static/resources/"));
|
||||
// Configure directory listing.
|
||||
handler.setDirectoriesListed(false);
|
||||
// TODO: is the directoriesListed feature still present?
|
||||
// handler.setDirectoriesListed(false);
|
||||
// Configure welcome files.
|
||||
handler.setWelcomeFiles(new String[]{"index.html"});
|
||||
handler.setWelcomeFiles(List.of("index.html"));
|
||||
// Configure whether to accept range requests.
|
||||
handler.setAcceptRanges(true);
|
||||
|
||||
|
@ -787,8 +780,9 @@ public class HTTPServerDocs
|
|||
|
||||
// For multiple directories, use ResourceCollection.
|
||||
ResourceCollection directories = new ResourceCollection();
|
||||
directories.addPath("/path/to/static/resources/");
|
||||
directories.addPath("/another/path/to/static/resources/");
|
||||
// TODO: how to add paths to ResourceCollection?
|
||||
// directories.addPath("/path/to/static/resources/");
|
||||
// directories.addPath("/another/path/to/static/resources/");
|
||||
|
||||
handler.setBaseResource(directories);
|
||||
// end::multipleResourcesHandler[]
|
||||
|
@ -840,23 +834,21 @@ public class HTTPServerDocs
|
|||
|
||||
public void contextGzipHandler() throws Exception
|
||||
{
|
||||
class ShopHandler extends AbstractHandler
|
||||
class ShopHandler extends Handler.Processor
|
||||
{
|
||||
@Override
|
||||
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException
|
||||
public void process(Request request, Response response, Callback callback) throws Exception
|
||||
{
|
||||
baseRequest.setHandled(true);
|
||||
// Implement the shop.
|
||||
// Implement the shop, remembering to complete the callback.
|
||||
}
|
||||
}
|
||||
|
||||
class RESTHandler extends AbstractHandler
|
||||
class RESTHandler extends Handler.Processor
|
||||
{
|
||||
@Override
|
||||
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
|
||||
public void process(Request request, Response response, Callback callback) throws Exception
|
||||
{
|
||||
baseRequest.setHandled(true);
|
||||
// Implement the REST APIs.
|
||||
// Implement the REST APIs, remembering to complete the callback.
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -999,8 +991,8 @@ public class HTTPServerDocs
|
|||
Connector connector = new ServerConnector(server);
|
||||
server.addConnector(connector);
|
||||
|
||||
// Create a HandlerList.
|
||||
HandlerList handlerList = new HandlerList();
|
||||
// Create a Handler collection.
|
||||
Handler.Collection handlerList = new Handler.Collection();
|
||||
|
||||
// Add as first a ContextHandlerCollection to manage contexts.
|
||||
ContextHandlerCollection contexts = new ContextHandlerCollection();
|
||||
|
|
|
@ -16,8 +16,9 @@ package org.eclipse.jetty.docs.programming.server.session;
|
|||
import java.io.File;
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
import org.eclipse.jetty.ee9.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.ee9.webapp.WebAppContext;
|
||||
import org.eclipse.jetty.ee10.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.ee10.servlet.SessionHandler;
|
||||
import org.eclipse.jetty.ee10.webapp.WebAppContext;
|
||||
import org.eclipse.jetty.memcached.session.MemcachedSessionDataMapFactory;
|
||||
import org.eclipse.jetty.nosql.mongodb.MongoSessionDataStoreFactory;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
|
@ -34,7 +35,6 @@ import org.eclipse.jetty.session.NullSessionCache;
|
|||
import org.eclipse.jetty.session.NullSessionCacheFactory;
|
||||
import org.eclipse.jetty.session.NullSessionDataStore;
|
||||
import org.eclipse.jetty.session.SessionCache;
|
||||
import org.eclipse.jetty.session.SessionHandler;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class SessionDocs
|
||||
|
@ -46,7 +46,7 @@ public class SessionDocs
|
|||
DefaultSessionIdManager idMgr = new DefaultSessionIdManager(server);
|
||||
//you must set the workerName unless you set the env viable JETTY_WORKER_NAME
|
||||
idMgr.setWorkerName("server3");
|
||||
server.setSessionIdManager(idMgr);
|
||||
server.addBean(idMgr, true);
|
||||
//end::default[]
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ public class SessionDocs
|
|||
Server server = new Server();
|
||||
DefaultSessionIdManager idMgr = new DefaultSessionIdManager(server);
|
||||
idMgr.setWorkerName("server7");
|
||||
server.setSessionIdManager(idMgr);
|
||||
server.addBean(idMgr, true);
|
||||
|
||||
HouseKeeper houseKeeper = new HouseKeeper();
|
||||
houseKeeper.setSessionIdManager(idMgr);
|
||||
|
@ -169,7 +169,9 @@ public class SessionDocs
|
|||
//Add a webapp that uses an explicit NullSessionCache instead
|
||||
WebAppContext app2 = new WebAppContext();
|
||||
app2.setContextPath("/app2");
|
||||
NullSessionCache nullSessionCache = new NullSessionCache(app2.getSessionHandler());
|
||||
// TODO
|
||||
// NullSessionCache nullSessionCache = new NullSessionCache(app2.getSessionHandler());
|
||||
NullSessionCache nullSessionCache = null;
|
||||
nullSessionCache.setFlushOnResponseCommit(true);
|
||||
nullSessionCache.setRemoveUnloadableSessions(true);
|
||||
nullSessionCache.setSaveOnCreate(true);
|
||||
|
@ -220,7 +222,9 @@ public class SessionDocs
|
|||
app1.setContextPath("/app1");
|
||||
|
||||
//First, we create a DefaultSessionCache
|
||||
DefaultSessionCache cache = new DefaultSessionCache(app1.getSessionHandler());
|
||||
// TODO
|
||||
// DefaultSessionCache cache = new DefaultSessionCache(app1.getSessionHandler());
|
||||
DefaultSessionCache cache = null;
|
||||
cache.setEvictionPolicy(SessionCache.NEVER_EVICT);
|
||||
cache.setFlushOnResponseCommit(true);
|
||||
cache.setInvalidateOnShutdown(false);
|
||||
|
|
|
@ -24,15 +24,15 @@ import jakarta.websocket.DeploymentException;
|
|||
import jakarta.websocket.server.ServerContainer;
|
||||
import jakarta.websocket.server.ServerEndpoint;
|
||||
import jakarta.websocket.server.ServerEndpointConfig;
|
||||
import org.eclipse.jetty.ee9.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.ee9.webapp.WebAppContext;
|
||||
import org.eclipse.jetty.ee9.websocket.api.annotations.WebSocket;
|
||||
import org.eclipse.jetty.ee9.websocket.jakarta.server.config.JakartaWebSocketServletContainerInitializer;
|
||||
import org.eclipse.jetty.ee9.websocket.server.JettyWebSocketCreator;
|
||||
import org.eclipse.jetty.ee9.websocket.server.JettyWebSocketServerContainer;
|
||||
import org.eclipse.jetty.ee9.websocket.server.JettyWebSocketServlet;
|
||||
import org.eclipse.jetty.ee9.websocket.server.JettyWebSocketServletFactory;
|
||||
import org.eclipse.jetty.ee9.websocket.server.config.JettyWebSocketServletContainerInitializer;
|
||||
import org.eclipse.jetty.ee10.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.ee10.webapp.WebAppContext;
|
||||
import org.eclipse.jetty.ee10.websocket.api.annotations.WebSocket;
|
||||
import org.eclipse.jetty.ee10.websocket.jakarta.server.config.JakartaWebSocketServletContainerInitializer;
|
||||
import org.eclipse.jetty.ee10.websocket.server.JettyWebSocketCreator;
|
||||
import org.eclipse.jetty.ee10.websocket.server.JettyWebSocketServerContainer;
|
||||
import org.eclipse.jetty.ee10.websocket.server.JettyWebSocketServlet;
|
||||
import org.eclipse.jetty.ee10.websocket.server.JettyWebSocketServletFactory;
|
||||
import org.eclipse.jetty.ee10.websocket.server.config.JettyWebSocketServletContainerInitializer;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
|
|
|
@ -169,7 +169,7 @@
|
|||
<dependency>
|
||||
<groupId>jakarta.servlet</groupId>
|
||||
<artifactId>jakarta.servlet-api</artifactId>
|
||||
<version>${jetty.servlet.api.version}</version>
|
||||
<version>${jakarta.servlet.api.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.orbit</groupId>
|
||||
|
|
4
pom.xml
4
pom.xml
|
@ -194,7 +194,7 @@
|
|||
<module>jetty-home</module>
|
||||
<module>tests</module>
|
||||
<!-- <module>jetty-p2</module> -->
|
||||
<!-- <module>documentation</module>-->
|
||||
<module>documentation</module>
|
||||
</modules>
|
||||
|
||||
<build>
|
||||
|
@ -1489,7 +1489,7 @@
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.tests</groupId>
|
||||
<artifactId>test-distribution</artifactId>
|
||||
<artifactId>test-distribution-common</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
Loading…
Reference in New Issue