本文整理汇总了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");
}