Java 类org.reflections.vfs.Vfs.Dir 实例源码

项目:kafka-0.11.0.0-src-with-comment    文件:ReflectionsUtil.java   
private static Dir emptyVfsDir(final URL url) {
    return new Dir() {
        @Override
        public String getPath() {
            return url.toExternalForm();
        }

        @Override
        public Iterable<File> getFiles() {
            return Collections.emptyList();
        }

        @Override
        public void close() {

        }
    };
}
项目:reflections    文件:UrlTypeVFS.java   
public Dir createDir(final URL url) {
    try {
        URL adaptedUrl = adaptURL(url);
        return new ZipDir(new JarFile(adaptedUrl.getFile()));
    } catch (Exception e) {
        try {
            return new ZipDir(new JarFile(url.getFile()));
        } catch (IOException e1) {
            if (Reflections.log != null) {
                Reflections.log.warn("Could not get URL", e);
                Reflections.log.warn("Could not get URL", e1);
            }
        }
    }
    return null;
}
项目:FinanceAnalytics    文件:OpenGammaFudgeContext.java   
@Override
public Dir createDir(URL url) throws Exception {
  File file = Vfs.getFile(url);
  if (file == null || file.exists() == false) {
    s_logger.warn("URL could not be resolved to a file: " + url);
    return new EmptyDir(file);
  } else {
    return new SystemDir(file);
  }
}
项目:kafka-0.11.0.0-src-with-comment    文件:ReflectionsUtil.java   
public Dir createDir(final URL url) throws Exception {
    return emptyVfsDir(url);
}
项目:jsmart-web    文件:FilterControl.java   
private void initResources(FilterConfig config) {
    try {
        if (CONFIG.getContent().getAssetsUrl() != null) {
            LOGGER.log(Level.INFO, "Using external assets, please provide the jsmart assets content at ["
                    + CONFIG.getContent().getAssetsUrl() + "]");
        }

        ServletContext context = config.getServletContext();
        Set<String> libs = context.getResourcePaths(LIB_FILE_PATH);

        if (libs == null || libs.isEmpty()) {
            LOGGER.log(Level.SEVERE, "Could not find the JSmart library JAR file. Empty [" + LIB_FILE_PATH + "] resource folder.");
            return;
        }

        String libFilePath = null;
        for (String lib : libs) {
            Matcher matcher = JAR_FILE_PATTERN.matcher(lib);
            if (matcher.find()) {
                libFilePath = matcher.group();
                break;
            }
        }

        if (libFilePath == null) {
            LOGGER.log(Level.SEVERE, "Could not find the JSmart library JAR file inside [" + LIB_FILE_PATH + "]");
            return;
        }

        Resources jsonResources = EXPRESSIONS.GSON.fromJson(convertResourceToString(FILTER_RESOURCES), Resources.class);

        File libFile = new File(context.getRealPath(libFilePath));
        Dir content = Vfs.fromURL(libFile.toURI().toURL());

        Iterator<Vfs.File> files = content.getFiles().iterator();
        while (files.hasNext()) {
            Vfs.File file = files.next();

            // Copy index.jsp and replace content to redirect to welcome-url case configured
            if (file.getRelativePath().startsWith(INDEX_JSP)) {
                if (CONFIG.getContent().getWelcomeUrl() != null) {
                    StringWriter writer = new StringWriter();
                    IOUtils.copy(file.openInputStream(), writer);
                    String index = writer.toString().replace("{0}", CONFIG.getContent().getWelcomeUrl());
                    copyFileResource(new ByteArrayInputStream(index.getBytes(ENCODING)), file.getRelativePath(), context);
                }
            }

            // Do not copy anything if assets-url was provided
            if (CONFIG.getContent().getAssetsUrl() != null) {
                continue;
            }

            // Copy js, css and font resources to specific location
            for (String resource : jsonResources.getResources()) {
                String resourcePath = resource.replace("*", "");

                if (file.getRelativePath().startsWith(resourcePath)) {
                    initDirResources(context.getRealPath(PATH_SEPARATOR), file.getRelativePath());
                    copyFileResource(file.openInputStream(), file.getRelativePath(), context);
                    break;
                }
            }
        }
    } catch (Exception ex) {
        LOGGER.log(Level.SEVERE, ex.getMessage());
    }
}