簡體   English   中英

可以使用嵌入式碼頭以編程方式設置上下文閥和領域嗎?

[英]Possible to set context valve and realm programmatically using embedded jetty?

我正在按照以下步驟設置嵌入式Jetty服務器:

Server server = new Server(8080);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");

ServletHandler handler = new ServletHandler();
context.addServlet(new ServletHolder(new CustomServlet()),"/*");

context.setHandler(handler);
server.setHandler(context);

try {
    server.start();
} catch (Exception e) {
    e.printStackTrace();
}

我想以編程方式添加以下參數。

<Context>
  <Valve className="a.ClassA" />
  <Realm className="b.ClassB" />
</Context>

我怎樣才能做到這一點?

在Java本身上,jetty xml只是一個皮膚,因此您可以在嵌入式xml中執行的所有操作都可以在jetty xml中進行。

這是我們嵌入碼頭的文檔的鏈接。

http://www.eclipse.org/jetty/documentation/current/advanced-embedding.html

對我來說,目前尚不清楚您要在這里做什么,但是以下示例對安全領域等進行了一些說明。

http://www.eclipse.org/jetty/documentation/current/embedded-examples.html#embedded-secured-hello-handler

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM