Example #1
0
  @Override
  public Set<String> getResourcePaths(String path) {
    // Try to get regular resource paths
    Set<String> paths = super.getResourcePaths(path);

    // If no paths are returned check for virtual paths /WEB-INF/classes and /WEB-INF/lib
    if (paths.isEmpty() && path != null) {
      path = URIUtil.canonicalPath(path);
      if (path.startsWith(WEB_INF_LIB_PREFIX)) {
        paths = new TreeSet<String>();
        for (String fileName : webInfJarMap.keySet()) {
          // Return all jar files from class path
          paths.add(WEB_INF_LIB_PREFIX + "/" + fileName);
        }
      } else if (path.startsWith(WEB_INF_CLASSES_PREFIX)) {
        int i = 0;

        while (paths.isEmpty() && (i < webInfClasses.size())) {
          String newPath = path.replace(WEB_INF_CLASSES_PREFIX, webInfClasses.get(i).getPath());
          paths = super.getResourcePaths(newPath);
          i++;
        }
      }
    }
    return paths;
  }
Example #2
0
 /**
  * return class files and jar files
  *
  * @return
  */
 public List<File> getClassPathFiles() {
   if (this.classpathFiles == null || this.classpathFiles.size() == 0) {
     Set<File> classesFiles = new LinkedHashSet<File>();
     if (getWebInfClasses() != null) {
       classesFiles.addAll(getWebInfClasses());
     }
     if (getWebInfLib() != null) {
       classesFiles.addAll(getWebInfLib());
     }
     this.classpathFiles = new ArrayList<File>(classesFiles.size());
     this.classpathFiles.addAll(classesFiles);
   }
   return this.classpathFiles;
 }
Example #3
0
  public Resource getAutoconfigResource(String uriContext) throws IOException {

    String relativePath = null;
    //        replacer.getAutoconfigTempDirectory()

    if (uriContext.startsWith(URIUtil.SLASH)) {
      relativePath = uriContext.substring(1);
    } else {
      relativePath = uriContext;
    }

    //        path.startsWith(defaultWebAppSourceDirectory.getAbsolutePath())
    if (autoconfigOutput.contains(relativePath)) {
      String resourcePath =
          autoconfigTempDirectory.getAbsolutePath() + File.separator + relativePath;
      if (logger.isDebugEnabled())
        logger.debug(uriContext + " autoconfig replaced resource:" + resourcePath);
      return Resource.newResource(resourcePath);
    }
    return null;
  }