当前位置: 首页>>代码示例>>Java>>正文


Java ClassPathResourceManager类代码示例

本文整理汇总了Java中io.undertow.server.handlers.resource.ClassPathResourceManager的典型用法代码示例。如果您正苦于以下问题:Java ClassPathResourceManager类的具体用法?Java ClassPathResourceManager怎么用?Java ClassPathResourceManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ClassPathResourceManager类属于io.undertow.server.handlers.resource包,在下文中一共展示了ClassPathResourceManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: customize

import io.undertow.server.handlers.resource.ClassPathResourceManager; //导入依赖的package包/类
@Override
public void customize(final DeploymentInfo di) {
	AccessController.doPrivileged(new PrivilegedAction<Void>() {
		@Override
		public Void run() {
			ClassLoader jsfClassLoader = new URLClassLoader(new URL[0], this.getClass().getClassLoader());
			di.setClassLoader(jsfClassLoader);

			di.setResourceManager(new ClassPathResourceManager(
				jsfClassLoader, JsfUndertowDeploymentInfoCustomizer.this.undertowProperties.getClassPathResource()));

			return null;
		}
	});

	log.info("Setting Undertow classLoader to {} directory", this.undertowProperties.getClassPathResource());
}
 
开发者ID:joinfaces,项目名称:joinfaces,代码行数:18,代码来源:JsfUndertowDeploymentInfoCustomizer.java

示例2: initServlet

import io.undertow.server.handlers.resource.ClassPathResourceManager; //导入依赖的package包/类
private static void initServlet() throws ServletException, NoSuchMethodException {
    ClassLoader classLoader = ClassLoader.getSystemClassLoader();
    DeploymentInfo deploymentInfo = new DeploymentInfo()
            .addListener(Servlets.listener(WeldInitialListener.class))
            .addListener(Servlets.listener(WeldTerminalListener.class))
            .setContextPath("/")
            .setDeploymentName("standalone-javax-mvc-app")
            .addServlet(
                    createServletInfo("/resources/*", "JAX-RS Resources", org.glassfish.jersey.servlet.ServletContainer.class)
            )
            .setResourceManager(new ClassPathResourceManager(classLoader, "META-INF/webapp"))
            .setClassIntrospecter(CdiClassIntrospecter.INSTANCE)
            .setAllowNonStandardWrappers(true)
            .setClassLoader(classLoader);

    ServletContainer servletContainer = Servlets.defaultContainer();
    DeploymentManager deploymentManager = servletContainer.addDeployment(deploymentInfo);
    deploymentManager.deploy();

    Undertow server = Undertow.builder()
            .addHttpListener(8080, "0.0.0.0")
            .setHandler(deploymentManager.start())
            .build();
    server.start();
}
 
开发者ID:shamoh,项目名称:standalone-javax-mvc,代码行数:26,代码来源:Main.java

示例3: setup

import io.undertow.server.handlers.resource.ClassPathResourceManager; //导入依赖的package包/类
public void setup() {

		undertow = Undertow.builder()
				.addHttpListener(8080, "localhost")
	//			.setHandler(path().addPrefixPath("/images", resource(new FileResourceManager(new File("/"), 0))))	
				.setHandler(path()
						.addPrefixPath("/myapp", websocket(new SchemaTreeProvider(SchemaPath)))
						.addPrefixPath("/", resource(new ClassPathResourceManager(JSONServer.class.getClassLoader(), JSONServer.class.getPackage()))
								.addWelcomeFiles(MainPage)
								.addWelcomeFiles(JavascriptFiles)
								)
						)
				.build();

		undertow.start();
	}
 
开发者ID:Comcast,项目名称:pipeclamp,代码行数:17,代码来源:JSONServer.java

示例4: main

import io.undertow.server.handlers.resource.ClassPathResourceManager; //导入依赖的package包/类
public static void main(String[] args) {
    PathHandler path = new PathHandler()
            .addPrefixPath("/", resource(new ClassPathResourceManager(Dashboard.class.getClassLoader(),
                    Dashboard.class.getPackage())).addWelcomeFiles("chart.html"))
            .addExactPath("/api", new Dashboard());

    Undertow server = Undertow.builder()
            .addHttpListener(6001, "127.0.0.1")
            .setHandler(path)
            .build();
    server.start();

    try {
        Thread.sleep(1000000000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    server.stop();
}
 
开发者ID:tbrooks8,项目名称:Precipice,代码行数:20,代码来源:Entry.java

示例5: main

import io.undertow.server.handlers.resource.ClassPathResourceManager; //导入依赖的package包/类
public static void main(String[] args) throws ServletException, IOException {
    final Xnio xnio = Xnio.getInstance("nio", Undertow.class.getClassLoader());
    final XnioWorker xnioWorker = xnio.createWorker(OptionMap.builder().getMap());
    final WebSocketDeploymentInfo webSockets = new WebSocketDeploymentInfo()
            .addEndpoint(SocketProxy.class)
            .setWorker(xnioWorker);
    final DeploymentManager deployment = defaultContainer()
            .addDeployment(deployment()
                    .setClassLoader(WebSocketServer.class.getClassLoader())
                    .setContextPath("/")
                    .setDeploymentName("embedded-websockets")
                    .addServletContextAttribute(ATTRIBUTE_NAME, webSockets));

    deployment.deploy();
    Undertow.builder().
            addListener(8080, "localhost")
            .setHandler(deployment.start())
            .setHandler(Handlers.path().addPrefixPath("/test", Handlers.resource(new ClassPathResourceManager(WebSocketServer.class.getClassLoader(), WebSocketServer.class.getPackage())).addWelcomeFiles("index.html")))
            .build()
            .start();

}
 
开发者ID:actframework,项目名称:act-demo-apps,代码行数:23,代码来源:WebSocketServer.java

示例6: createRoutes

import io.undertow.server.handlers.resource.ClassPathResourceManager; //导入依赖的package包/类
/**
 * Create routes for WebSockets ServerSentEvent and Resource files
 */
private static void createRoutes() {
    if (!error) {
        pathHandler = new PathHandler(getRoutingHandler());
        for (final Route route : Router.getRoutes()) {
            if (RouteType.WEBSOCKET == route.getRouteType()) {
                pathHandler.addExactPath(route.getUrl(),
                        Handlers.websocket(injector.getInstance(WebSocketHandler.class)
                                .withControllerClass(route.getControllerClass())
                                .withAuthentication(route.isAuthenticationRequired())));
            } else if (RouteType.SERVER_SENT_EVENT == route.getRouteType()) {
                pathHandler.addExactPath(route.getUrl(),
                        Handlers.serverSentEvents(injector.getInstance(ServerSentEventHandler.class)
                                .withAuthentication(route.isAuthenticationRequired())));
            } else if (RouteType.RESOURCE_PATH == route.getRouteType()) {
                pathHandler.addPrefixPath(route.getUrl(),
                        new ResourceHandler(new ClassPathResourceManager(Thread.currentThread().getContextClassLoader(), Default.FILES_FOLDER.toString() + route.getUrl())));
            }
        }            
    }
}
 
开发者ID:svenkubiak,项目名称:mangooio,代码行数:24,代码来源:Application.java

示例7: setup

import io.undertow.server.handlers.resource.ClassPathResourceManager; //导入依赖的package包/类
@BeforeClass
public static void setup() throws ScriptException, IOException {

    final ClassPathResourceManager res = new ClassPathResourceManager(FreemarkerTemplateTestCase.class.getClassLoader(), FreemarkerTemplateTestCase.class.getPackage());
    UndertowJS js = UndertowJS.builder()
            .addTemplateProvider(new FreemarkerTemplateProvider())
            .addResources(res, "freemarker.js")
            .setResourceManager(res)
            .build();
    js.start();
    DefaultServer.setRootHandler(js.getHandler(new ResourceHandler(res, new HttpHandler() {
        @Override
        public void handleRequest(HttpServerExchange exchange) throws Exception {
            exchange.getResponseSender().send("Default Response");
        }
    })));
}
 
开发者ID:undertow-io,项目名称:undertow.js,代码行数:18,代码来源:FreemarkerTemplateTestCase.java

示例8: setup

import io.undertow.server.handlers.resource.ClassPathResourceManager; //导入依赖的package包/类
@BeforeClass
public static void setup() throws ScriptException, IOException {

    final ClassPathResourceManager res = new ClassPathResourceManager(TrimouTemplateTestCase.class.getClassLoader(),
            TrimouTemplateTestCase.class.getPackage());
    UndertowJS js = UndertowJS.builder()
            .addResources(res, "trimou.js")
            .addTemplateProvider(new TrimouTemplateProvider())
            .setResourceManager(res)
            .build();
    js.start();
    DefaultServer.setRootHandler(js.getHandler(new ResourceHandler(res, new HttpHandler() {
        @Override
        public void handleRequest(HttpServerExchange exchange) throws Exception {
            exchange.getResponseSender().send("Default Response");
        }
    })));
}
 
开发者ID:undertow-io,项目名称:undertow.js,代码行数:19,代码来源:TrimouTemplateTestCase.java

示例9: setup

import io.undertow.server.handlers.resource.ClassPathResourceManager; //导入依赖的package包/类
@BeforeClass
public static void setup() throws ScriptException, IOException {

    final ClassPathResourceManager res = new ClassPathResourceManager(MustacheTemplateTestCase.class.getClassLoader(), MustacheTemplateTestCase.class.getPackage());
    UndertowJS js = UndertowJS.builder()
            .addTemplateProvider(new MustacheTemplateProvider())
            .addResources(res, "mustache.js")
            .setResourceManager(res)
            .build();
    js.start();
    DefaultServer.setRootHandler(js.getHandler(new ResourceHandler(res, new HttpHandler() {
        @Override
        public void handleRequest(HttpServerExchange exchange) throws Exception {
            exchange.getResponseSender().send("Default Response");
        }
    })));
}
 
开发者ID:undertow-io,项目名称:undertow.js,代码行数:18,代码来源:MustacheTemplateTestCase.java

示例10: setup

import io.undertow.server.handlers.resource.ClassPathResourceManager; //导入依赖的package包/类
@BeforeClass
public static void setup() throws Exception {

    final ClassPathResourceManager res = new ClassPathResourceManager(JavascriptWebsocketTestCase.class.getClassLoader(), JavascriptWebsocketTestCase.class.getPackage());
    js = UndertowJS.builder()
            .addInjectionProvider(new TestInjectionProvider())
            .addResources(res, "websocket.js")
            .setResourceManager(res).build();
    js.start();
    DefaultServer.setRootHandler(js.getHandler(new ResourceHandler(res, new HttpHandler() {
        @Override
        public void handleRequest(HttpServerExchange exchange) throws Exception {
            exchange.getResponseSender().send("Default Response");
        }
    })));

}
 
开发者ID:undertow-io,项目名称:undertow.js,代码行数:18,代码来源:JavascriptWebsocketTestCase.java

示例11: start

import io.undertow.server.handlers.resource.ClassPathResourceManager; //导入依赖的package包/类
@Override
public void start(StartContext context) throws StartException {
    ExtensibleHttpManagement httpManagement = httpManagementInjector.getValue();

    ResourceManager rm = new ClassPathResourceManager(getClass().getClassLoader(), getClass().getPackage());
    httpManagement.addStaticContext("static", rm);
    log.info("Added context 'static'");

    ExtensibleHttpManagement.PathRemapper remapper = new ExtensibleHttpManagement.PathRemapper() {
        @Override
        public String remapPath(String originalPath) {
            if ("/foo".equals(originalPath)) {
                String prefix = forServer ? "" : "/host/master";
                return prefix + "/extension/" + EXTENSION_NAME;
            }
            return null;
        }
    };
    httpManagement.addManagementGetRemapContext("remap", remapper);
    log.info("Added context 'remap'");
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:22,代码来源:CustomContextExtension.java

示例12: createErrorContext

import io.undertow.server.handlers.resource.ClassPathResourceManager; //导入依赖的package包/类
public static HttpHandler createErrorContext(final String slot) throws ModuleLoadException {
    final ClassPathResourceManager cpresource = new ClassPathResourceManager(getClassLoader(Module.getCallerModuleLoader(), ERROR_MODULE, slot), "");
    final io.undertow.server.handlers.resource.ResourceHandler handler = new io.undertow.server.handlers.resource.ResourceHandler(cpresource)
            .setAllowed(not(path("META-INF")))
            .setDirectoryListingEnabled(false)
            .setCachable(Predicates.<HttpServerExchange>falsePredicate());

    //we also need to setup the default resource redirect
    return new PredicateHandler(path("/"), new RedirectHandler(ExchangeAttributes.constant(ERROR_CONTEXT + DEFAULT_RESOURCE)), handler);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:11,代码来源:ErrorContextHandler.java

示例13: Server

import io.undertow.server.handlers.resource.ClassPathResourceManager; //导入依赖的package包/类
public Server() {
    Undertow server = Undertow.builder().addHttpListener(port, "0.0.0.0",
            Handlers.path()
                    .addPrefixPath("rpc", this)
                    .addPrefixPath("/", new ResourceHandler(new ClassPathResourceManager(Server.class.getClassLoader(), "static")).addWelcomeFiles("index.html").setDirectoryListingEnabled(false))
    ).build();
    server.start();
    System.out.println("Server running at : 9077");
}
 
开发者ID:datathings,项目名称:greycat,代码行数:10,代码来源:Server.java

示例14: index

import io.undertow.server.handlers.resource.ClassPathResourceManager; //导入依赖的package包/类
public void index(HttpServerExchange exchange) {
    File index_cache = new File(App.getStorageDir().resolve("index_cache.html").toString());
    if (index_cache.exists()) {
        exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/html");
        exchange.getResponseSender().send(fileToString(index_cache));
        return;
    }
    ClassPathResourceManager cprm = new ClassPathResourceManager(App.class.getClassLoader(), "public/");
    String s = resourceToString("/public/index.html");
    String[] replacements = {"title", "head", "info"};
    for (String p : replacements) {
        String r = App.getConfig().getString("html." + p);
        if (r == null) {
            r = "";
        }
        if (r.startsWith("resource:")) {
            r = resourceToString(r.substring(9));
        } else if (r.startsWith("file:")) {
            r = fileToString(App.getStorageDir().resolve(r.substring(5)).toString());
        }
        s = s.replace("{{" + p + "}}", r);
    }
    try {
        FileWriter fw = new FileWriter(index_cache);
        fw.write(s);
        fw.flush();
        fw.close();
        index(exchange); // we created the file, now output it!
    } catch (IOException e) {
        exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/html");
        exchange.getResponseSender().send("error");
        return;
    }
}
 
开发者ID:xSke,项目名称:Pxls,代码行数:35,代码来源:WebHandler.java

示例15: start

import io.undertow.server.handlers.resource.ClassPathResourceManager; //导入依赖的package包/类
public void start() {
    PathHandler mainHandler = Handlers.path()
            .addExactPath("/ws", Handlers.websocket(this::webSocketHandler))
            .addPrefixPath("/ws", Handlers.websocket(this::webSocketHandler))
            .addPrefixPath("/info", webHandler::info)
            .addPrefixPath("/boarddata", webHandler::data)
            .addPrefixPath("/heatmap", webHandler::heatmap)
            .addPrefixPath("/logout", webHandler::logout)
            .addPrefixPath("/lookup", webHandler::lookup)
            .addPrefixPath("/report", webHandler::report)
            .addPrefixPath("/signin", webHandler::signIn)
            .addPrefixPath("/users", webHandler::users)
            .addPrefixPath("/auth", new RateLimitingHandler(webHandler::auth, (int) App.getConfig().getDuration("server.limits.auth.time", TimeUnit.SECONDS), App.getConfig().getInt("server.limits.auth.count")))
            .addPrefixPath("/signup", new RateLimitingHandler(webHandler::signUp, (int) App.getConfig().getDuration("server.limits.signup.time", TimeUnit.SECONDS), App.getConfig().getInt("server.limits.signup.count")))
            .addPrefixPath("/admin/ban", new RoleGate(Role.MODERATOR, webHandler::ban))
            .addPrefixPath("/admin/unban", new RoleGate(Role.MODERATOR, webHandler::unban))
            .addPrefixPath("/admin/permaban", new RoleGate(Role.MODERATOR, webHandler::permaban))
            .addPrefixPath("/admin/shadowban", new RoleGate(Role.ADMIN, webHandler::shadowban))
            .addPrefixPath("/admin/check", new RoleGate(Role.MODERATOR, webHandler::check))
            .addPrefixPath("/admin", new RoleGate(Role.MODERATOR, Handlers.resource(new ClassPathResourceManager(App.class.getClassLoader(), "public/admin/"))
                    .setCacheTime(10)))
            .addExactPath("/", webHandler::index)
            .addExactPath("/index.html", webHandler::index)
            .addPrefixPath("/", Handlers.resource(new ClassPathResourceManager(App.class.getClassLoader(), "public/"))
                    .setCacheTime(10));
    //EncodingHandler encoder = new EncodingHandler(mainHandler, new ContentEncodingRepository().addEncodingHandler("gzip", new GzipEncodingProvider(), 50, Predicates.parse("max-content-size(1024)")));
    server = Undertow.builder()
            .addHttpListener(port, "0.0.0.0")
            .setIoThreads(32)
            .setWorkerThreads(128)
            .setHandler(new IPReader(new AuthReader(new EagerFormParsingHandler().setNext(mainHandler)))).build();
    server.start();
}
 
开发者ID:xSke,项目名称:Pxls,代码行数:34,代码来源:UndertowServer.java


注:本文中的io.undertow.server.handlers.resource.ClassPathResourceManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。