本文整理匯總了Java中io.undertow.Handlers.path方法的典型用法代碼示例。如果您正苦於以下問題:Java Handlers.path方法的具體用法?Java Handlers.path怎麽用?Java Handlers.path使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.undertow.Handlers
的用法示例。
在下文中一共展示了Handlers.path方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: start
import io.undertow.Handlers; //導入方法依賴的package包/類
public void start() {
PathHandler pathHandler = Handlers.path();
for (String name : handlers.keySet()) {
pathHandler.addPrefixPath(name, handlers.get(name));
}
this.server = Undertow.builder().addHttpListener(port, "0.0.0.0", pathHandler).build();
server.start();
this.graph.storage().listen(this);//stop
}
示例2: start
import io.undertow.Handlers; //導入方法依賴的package包/類
public void start() {
final PathHandler pathHandler = Handlers.path();
for (String name : handlers.keySet()) {
pathHandler.addPrefixPath(name, handlers.get(name));
}
this.server = Undertow.builder().addHttpListener(port, "0.0.0.0", pathHandler).build();
server.start();
if (builder.storage != null) {
builder.storage.listen(this);
} else if (builder.storageFactory != null) {
builder.storageFactory.listen(this);
}
}
示例3: initUndertowServer
import io.undertow.Handlers; //導入方法依賴的package包/類
public void initUndertowServer() {
JbootServerClassloader classloader = new JbootServerClassloader(UnderTowServer.class.getClassLoader());
classloader.setDefaultAssertionStatus(false);
deploymentInfo = buildDeploymentInfo(classloader);
if (webConfig.isWebsocketEnable()) {
Set<Class> endPointClasses = JbootWebsocketManager.me().getWebsocketEndPoints();
WebSocketDeploymentInfo webSocketDeploymentInfo = new WebSocketDeploymentInfo();
webSocketDeploymentInfo.setBuffers(new DefaultByteBufferPool(true, webConfig.getWebsocketBufferPoolSize()));
for (Class endPointClass : endPointClasses) {
webSocketDeploymentInfo.addEndpoint(endPointClass);
}
deploymentInfo.addServletContextAttribute(WebSocketDeploymentInfo.ATTRIBUTE_NAME, webSocketDeploymentInfo);
}
servletContainer = Servlets.newContainer();
deploymentManager = servletContainer.addDeployment(deploymentInfo);
deploymentManager.deploy();
HttpHandler httpHandler = null;
try {
/**
* 啟動並初始化servlet和filter
*/
httpHandler = deploymentManager.start();
} catch (Throwable ex) {
ex.printStackTrace();
}
pathHandler = Handlers.path(
Handlers.resource(new ClassPathResourceManager(classloader, "webRoot")));
pathHandler.addPrefixPath(config.getContextPath(), httpHandler);
undertow = Undertow.builder()
.addHttpListener(config.getPort(), config.getHost())
.setHandler(pathHandler)
.build();
}
示例4: startServer
import io.undertow.Handlers; //導入方法依賴的package包/類
/**
* Start server on the given port.
*
* @param port
*/
public static void startServer(int port) {
LOGGER.info(String.format("Starting server on port %d", port));
PathHandler path = Handlers.path();
server = Undertow.builder()
.addHttpListener(port, "localhost")
.setHandler(path)
.build();
server.start();
LOGGER.info(String.format("Server started on port %d", port));
DeploymentInfo servletBuilder = Servlets.deployment()
.setClassLoader(Application.class.getClassLoader())
.setContextPath("/")
.addListeners(listener(Listener.class))
.setResourceManager(new ClassPathResourceManager(Application.class.getClassLoader()))
.addServlets(
Servlets.servlet("jerseyServlet", ServletContainer.class)
.setLoadOnStartup(1)
.addInitParam("javax.ws.rs.Application", JerseyConfig.class.getName())
.addMapping("/api/*"))
.setDeploymentName("application.war");
LOGGER.info("Starting application deployment");
deploymentManager = Servlets.defaultContainer().addDeployment(servletBuilder);
deploymentManager.deploy();
try {
path.addPrefixPath("/", deploymentManager.start());
} catch (ServletException e) {
throw new RuntimeException(e);
}
LOGGER.info("Application deployed");
}