Package io.undertow.server.handlers.resource

Examples of io.undertow.server.handlers.resource.FileResourceManager


        tmpDir = new File(System.getProperty("java.io.tmpdir") + DIR_NAME);
        tmpDir.mkdirs();
        tmpDir.deleteOnExit();

        final FileResourceManager resourceManager = new FileResourceManager(tmpDir, 10485760);
        DefaultServer.setRootHandler(new ResourceHandler().setResourceManager(resourceManager)
                .setContentEncodedResourceManager(
                        new ContentEncodedResourceManager(tmpDir, new CachingResourceManager(100, 10000, null, resourceManager, -1), new ContentEncodingRepository()
                                .addEncodingHandler("deflate", new DeflateEncodingProvider(), 50, null), 0, 100000, null)));
    }
View Full Code Here


    public void simpleFileStressTest() throws IOException, ExecutionException, InterruptedException, URISyntaxException {
        ExecutorService executor = Executors.newFixedThreadPool(NUM_THREADS);
        try {
            File rootPath = new File(getClass().getResource("page.html").toURI()).getParentFile();
            final ResourceHandler handler = new ResourceHandler()
                    .setResourceManager(new FileResourceManager(rootPath, 10485760));

            final CacheHandler cacheHandler = new CacheHandler(new DirectBufferCache(1024, 10, 10480), handler);
            final PathHandler path = new PathHandler();
            path.addPrefixPath("/path", cacheHandler);
            final CanonicalPathHandler root = new CanonicalPathHandler();
View Full Code Here

        File rootPath = new File(getClass().getResource("page.html").toURI()).getParentFile();
        try {
            DefaultServer.setRootHandler(new CanonicalPathHandler()
                    .setNext(new PathHandler()
                            .addPrefixPath("/path", new ResourceHandler()
                                    .setResourceManager(new FileResourceManager(rootPath, 10485760))
                                    .setDirectoryListingEnabled(true)
                                    .addWelcomeFiles("page.html"))));

            HttpGet get = new HttpGet(DefaultServer.getDefaultServerURL() + "/path");
            HttpResponse result = client.execute(get);
View Full Code Here

        DeploymentInfo builder = new DeploymentInfo()
                .setClassIntrospecter(TestClassIntrospector.INSTANCE)
                .setClassLoader(ServletPathMappingTestCase.class.getClassLoader())
                .setContextPath("/servletContext")
                .setDeploymentName("servletContext.war")
                .setResourceManager(new CachingResourceManager(100, 10000, new DirectBufferCache(1000, 10, 1000 * 10 * 1000, BufferAllocator.DIRECT_BYTE_BUFFER_ALLOCATOR, METADATA_MAX_AGE), new FileResourceManager(tmpDir, 10485760), METADATA_MAX_AGE));

        builder.addServlet(new ServletInfo("DefaultTestServlet", PathTestServlet.class)
                .addMapping("/path/default"))
                .addFilter(Servlets.filter("message", MessageFilter.class).addInitParam(MessageFilter.MESSAGE, "FILTER_TEXT "))
                .addFilterUrlMapping("message", "*.txt", DispatcherType.REQUEST);
View Full Code Here

    }

    @Test
    public void testSpecialCharacterInFileURL() throws IOException {
        String tmp = System.getProperty("java.io.tmpdir");
        FileResourceManager fileResourceManager = new FileResourceManager(new File(tmp), 1);
        File file = new File(tmp, "1#2.txt");
        FileOutputStream f = null;
        try {
            f = new FileOutputStream(file);
            f.write("Hi".getBytes());
        } finally {
            IoUtils.safeClose(f);
        }
        Resource res = fileResourceManager.getResource("1#2.txt");
        InputStream in = null;
        try {
            in = res.getUrl().openStream();
            Assert.assertEquals("Hi", FileUtils.readFile(in));
        } finally {
View Full Code Here

public class FileServer {

    public static void main(final String[] args) {
        Undertow server = Undertow.builder()
                .addHttpListener(8080, "localhost")
                .setHandler(resource(new FileResourceManager(new File(System.getProperty("user.home")), 100))
                        .setDirectoryListingEnabled(true))
                .build();
        server.start();
    }
View Full Code Here

            .addInitParameter("resteasy.resources", "org.infinispan.rest.Server")
            .addInitParameter("resteasy.use.builtin.providers", "true")
            .addListener(new ListenerInfo(ResteasyBootstrap.class))
            .addMimeMappings(new MimeMapping("html", "text/html"), new MimeMapping("jpg", "image/jpeg"))
            .addWelcomePage("index.html")
            .setResourceManager(new FileResourceManager(new File(pathManagerInjector.getValue().resolveRelativePathEntry("rest", HOME_DIR)), 1024 * 1024));
         callbackHandle = pathManagerInjector.getValue().registerCallback(HOME_DIR, PathManager.ReloadServerCallback.create(), PathManager.Event.UPDATED, PathManager.Event.REMOVED);

         // Add the default servlet for managing static content
         deployment.addServlet(new ServletInfo("default", DefaultServlet.class).addMapping("/"));

View Full Code Here

TOP

Related Classes of io.undertow.server.handlers.resource.FileResourceManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.