Java Code Examples for org.eclipse.jetty.util.resource.FileResource

Following code examples demonstrate how to use org.eclipse.jetty.util.resource.FileResource from jetty. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.eclipse.jetty.util.resource.FileResource and various code implementation of this class.
Example 1
Project : jetty Source File : JettyServer.java View Source Code on GitHub

    public void init(String path, URI webApp, URI classPath) throws MalformedURLException {
        this.server = new Server(0);

        WebAppContext context = new WebAppContext();

        context.setClassLoader(Thread.currentThread().getContextClassLoader());

        Resource resourceBase = newResource(webApp);
        context.setResourceBase(String.valueOf(resourceBase));

        context.setConfigurations(new Configuration[]{
                new WebXmlConfiguration(),
                new AnnotationConfiguration()
        });

        File tempDirectory = new File("/tmp");
        context.setTempDirectory(tempDirectory);

        FileResource containerResources = new FileResource(classPath);
        context.getMetaData().addContainerResource(containerResources);

        String webXmlPath = webApp.getPath() +"/WEB-INF/web.xml";
        context.setDescriptor(webXmlPath);

        context.setContextPath(path);
        context.setParentLoaderPriority(true);

        server.setHandler(context);
    }