Package org.apache.naming.resources

Examples of org.apache.naming.resources.FileDirContext$FileResourceAttributes


            public WebappClassLoader run() {
                return new WebappClassLoader(parent);
            }
        });
        try {
            FileDirContext r = new FileDirContext();
            File base = new File(context.getSource().getURI());
            r.setDocBase(base.getAbsolutePath());

            cloader.setResources(r);
            cloader.addRepository("WEB-INF/classes/", new File(base, "WEB-INF/classes/"));
            if (context.getScratchDir("ejb") != null) {
                cloader.addRepository(context.getScratchDir("ejb").toURI().toURL().toString().concat("/"));
View Full Code Here


        // Add other overlays, if any
        if (ok) {
            for (String overlay : overlays) {
                if (context.getResources() instanceof ProxyDirContext) {
                    ProxyDirContext resources = (ProxyDirContext) context.getResources();
                    FileDirContext dirContext = new FileDirContext();
                    dirContext.setDocBase(overlay);
                    resources.addOverlay(dirContext);
                }
            }
        }
View Full Code Here

            try {
                if ((getDocBase() != null) && (getDocBase().endsWith(".war")) &&
                        (!(new File(getBasePath())).isDirectory()))
                    setResources(new WARDirContext());
                else
                    setResources(new FileDirContext());
            } catch (IllegalArgumentException e) {
                log.error("Error initializing resources: " + e.getMessage());
                ok = false;
            }
        }
View Full Code Here

                log.debug("Configuring default Resources");
            try {
                if ((docBase != null) && (docBase.endsWith(".war")) && (!(new File(getBasePath())).isDirectory()))
                    setResources(new WARDirContext());
                else
                    setResources(new FileDirContext());
            } catch (IllegalArgumentException e) {
                log.error("Error initializing resources: " + e.getMessage());
                ok = false;
            }
        }
View Full Code Here

            try {
                if ((getDocBase() != null) && (getDocBase().endsWith(".war")) &&
                        (!(new File(getBasePath())).isDirectory()))
                    setResources(new WARDirContext());
                else
                    setResources(new FileDirContext());
            } catch (IllegalArgumentException e) {
                log.error("Error initializing resources: " + e.getMessage());
                ok = false;
            }
        }
View Full Code Here

                        }
                        jar.nextEntry();
                        entryName = jar.getEntryName();
                    }
                } else if ("file".equals(url.getProtocol())) {
                    FileDirContext fileDirContext = new FileDirContext();
                    fileDirContext.setDocBase(new File(url.toURI()).getAbsolutePath());
                    try {
                        fileDirContext.lookup("META-INF/resources/");
                        //lookup succeeded
                        if(context instanceof StandardContext){
                            ((StandardContext)context).addResourcesDirContext(fileDirContext);
                        }
                    } catch (NamingException e) {
View Full Code Here

                log("Configuring default Resources");
            try {
                if ((docBase != null) && (docBase.endsWith(".war")))
                    setResources(new WARDirContext());
                else
                    setResources(new FileDirContext());
            } catch (IllegalArgumentException e) {
                log("Error initializing resources: " + e.getMessage());
                ok = false;
            }
        }
View Full Code Here

            try {
                if ((getDocBase() != null) && (getDocBase().endsWith(".war")) &&
                        (!(new File(getBasePath())).isDirectory()))
                    setResources(new WARDirContext());
                else
                    setResources(new FileDirContext());
            } catch (IllegalArgumentException e) {
                log.error("Error initializing resources: " + e.getMessage());
                ok = false;
            }
        }
View Full Code Here

        }
        return createBundleDirContext(tomcatContext);
    }

    private DirContext createFileDirContext(TomcatContext tomcatContext, File applicationRoot) throws DeploymentException {
        FileDirContext fileDirContext = new FileDirContext();
        fileDirContext.setAllowLinking(allowLinking);
        setDocBase(applicationRoot.getAbsolutePath());
        File libraryDirectory = new File(applicationRoot, "WEB-INF/lib");
        if (libraryDirectory.exists()) {
            for (File libraryFile : libraryDirectory.listFiles()) {
                if (libraryFile.getName().toLowerCase().endsWith(".jar") && libraryFile.isFile()) {
                    try {
                        fileDirContext.addResourcesJar(new URL("jar:" + libraryFile.toURI().toURL().toExternalForm() + "!/ "));
                    } catch (MalformedURLException e) {
                        logger.warn("Unable to add jar file for resource searching", e);
                    }
                }
            }
View Full Code Here

                throw new DeploymentException("Fail to create static resoruce cache for jar files in WEB-INF folder", e);
            }
        }
        for (File resourceDirectory : jarResourceRootDirectory.listFiles()) {
            if (resourceDirectory.isDirectory() && resourceDirectory.getName().endsWith(".jar") && resourceDirectory.listFiles().length > 0) {
                FileDirContext fileDirContext = new FileDirContext();
                fileDirContext.setAllowLinking(allowLinking);
                fileDirContext.setDocBase(resourceDirectory.getAbsolutePath());
                altDirContexts.add(fileDirContext);
            }
        }
        //If it is system artifact, or no getRealPath and development stage support is required, just use BundleDirContext
        if (!(getRealPathSupportRequired || developmentStage)) {
            return new BundleDirContext(tomcatContext.getBundle(), tomcatContext.getModulePath(), altDirContexts, null);
        }
        File realPathTempDirectory = new File(tempRootDirectory, "real_path");
        if (refreshmentRequired || !realPathTempDirectory.exists()) {
            FileUtils.recursiveDelete(realPathTempDirectory);
            realPathTempDirectory.mkdirs();
            String modulePath = tomcatContext.getModulePath() == null ? "" : tomcatContext.getModulePath();
            try {
                File bundleFile = BundleUtils.toFile(bundle);
                if (bundleFile != null) {
                    if (bundleFile.isFile()) {
                        JarUtils.unzipToDirectory(new ZipFile(bundleFile), realPathTempDirectory, modulePath, true);
                    } else {
                        FileUtils.copyFile(new File(bundleFile, modulePath), realPathTempDirectory);
                    }
                } else {
                    ZipInputStream zipIn = null;
                    try {
                        zipIn = new ZipInputStream(new URL(bundle.getLocation()).openStream());
                        JarUtils.unzipToDirectory(zipIn, realPathTempDirectory, modulePath, true);
                    } finally {
                        IOUtils.close(zipIn);
                    }
                }
            } catch (IOException e) {
                checksumFile.delete();
                getLogger().warn("fail to extract the bundle, getRealPath might not work", e);
            }
        }
        if (developmentStage) {
            GeronimoFileDirContext fileDirContext = new GeronimoFileDirContext(altDirContexts);
            fileDirContext.setAllowLinking(allowLinking);
            setDocBase(realPathTempDirectory.getAbsolutePath());
            return fileDirContext;
        } else {
            return new BundleDirContext(tomcatContext.getBundle(), tomcatContext.getModulePath(), altDirContexts, realPathTempDirectory);
        }
View Full Code Here

TOP

Related Classes of org.apache.naming.resources.FileDirContext$FileResourceAttributes

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.