本文整理汇总了Java中io.undertow.server.handlers.resource.PathResourceManager类的典型用法代码示例。如果您正苦于以下问题:Java PathResourceManager类的具体用法?Java PathResourceManager怎么用?Java PathResourceManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PathResourceManager类属于io.undertow.server.handlers.resource包,在下文中一共展示了PathResourceManager类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import io.undertow.server.handlers.resource.PathResourceManager; //导入依赖的package包/类
public static void main(String[] args) {
final String urltoConnect = "ws://localhost:5678";
final String serverUrl = "0.0.0.0";
final int serverPort = 8080;
Undertow server = Undertow.builder()
.addHttpListener(serverPort,serverUrl)
.setHandler(
Handlers.path(
Handlers.resource(
new PathResourceManager(Paths.get("plugins/visualizer/src/main/resources").toAbsolutePath(),0)
)
)
)
.build();
server.start();
StringBuilder goToBuilder = new StringBuilder();
goToBuilder.append("http://")
.append(serverUrl)
.append(":")
.append(serverPort)
.append("?q=")
.append(urltoConnect);
System.out.println("Go to: " + goToBuilder);
System.out.println();
}
示例2: main
import io.undertow.server.handlers.resource.PathResourceManager; //导入依赖的package包/类
public static void main(String[]args){
Undertow server = Undertow.builder()
.addHttpListener(7071, "localhost")
.setHandler(io.undertow.Handlers.resource(
new PathResourceManager(Paths.get("/Users/enonowog/books/jbdevg/code/jbdevg"),10))
.setDirectoryListingEnabled(true)
).build();
server.start();
}
示例3: startPreview
import io.undertow.server.handlers.resource.PathResourceManager; //导入依赖的package包/类
/**
* Creates and starts the server to serve the contents of OUTPUT_DIRECTORY on port
9090.
*/
protected void startPreview() {
ResourceHandler resourceHandler = resource(new PathResourceManager(Paths.get(OUTPUT_DIRECTORY), 100, true, true))
.setDirectoryListingEnabled(false);
FileErrorPageHandler errorHandler = new FileErrorPageHandler(Paths.get(OUTPUT_DIRECTORY).resolve("404.html"), StatusCodes.NOT_FOUND);
errorHandler.setNext(resourceHandler);
GracefulShutdownHandler shutdown = Handlers.gracefulShutdown(errorHandler);
Undertow server = Undertow.builder().addHttpListener(port, "localhost")
.setHandler(shutdown)
.build();
server.start();
}
示例4: getResourceManager
import io.undertow.server.handlers.resource.PathResourceManager; //导入依赖的package包/类
public ResourceManager getResourceManager() {
final Path folder = Paths.get(path.getResourceId());
return new PathResourceManager(folder, 10000L);
}
示例5: ExternalAssetProvider
import io.undertow.server.handlers.resource.PathResourceManager; //导入依赖的package包/类
ExternalAssetProvider(final DocumentationProvider provider) {
this.provider = provider;
this.next =
resource(
new PathResourceManager(provider.assetsPath(),100000,false,false));
}
示例6: Webserver
import io.undertow.server.handlers.resource.PathResourceManager; //导入依赖的package包/类
public Webserver() {
try {
DeploymentInfo uploadServlet = Servlets.deployment()
.setClassLoader(Webserver.class.getClassLoader())
.setDeploymentName("HttpRequestHandler")
.setContextPath("/")
.addServlets(
Servlets.servlet(
"HttpRequestHandler",
HttpRequestHandler.class)
.addMapping("/")
.setMultipartConfig(new MultipartConfigElement(System.getProperty("java.io.tmpdir"), config.getMaxFileSize(), config.getMaxFileSize() * 1024, 0))
);
DeploymentInfo panelServlet = Servlets.deployment()
.setClassLoader(Webserver.class.getClassLoader())
.setDeploymentName("Panel")
.setContextPath("/")
.addServlets(
Servlets.servlet("PanelLogin", PanelLogin.class).addMapping("/login"),
Servlets.servlet("Panel", PanelHome.class).addMapping("/")
);
DeploymentManager upload = Servlets.defaultContainer().addDeployment(uploadServlet);
upload.deploy();
DeploymentManager panel = Servlets.defaultContainer().addDeployment(panelServlet);
panel.deploy();
PathHandler path = Handlers.path(
resource(new PathResourceManager(Paths.get(HermexServer.config.getFolder()), 0))
.setDirectoryListingEnabled(false)
);
path.addPrefixPath("/upload", upload.start());
path.addPrefixPath("/panel", panel.start());
path.addPrefixPath("/assets",
resource(new ClassPathResourceManager(this.getClass().getClassLoader(), "assets/"))
.setDirectoryListingEnabled(false)
);
this.server = Undertow.builder()
.addHttpListener(HermexServer.config.getWebPort(), "0.0.0.0")
.setHandler(path)
.build();
} catch (Exception e) {
logger.log(Level.ERROR, "Unknown error", e);
}
}