Package org.springframework.boot.loader.archive

Examples of org.springframework.boot.loader.archive.Archive


  private static final AsciiBytes LIB = new AsciiBytes("lib/");

  public static ClassLoader createModuleClassLoader(Resource moduleLocation, ClassLoader parent) {
    try {
      File moduleFile = moduleLocation.getFile();
      Archive moduleArchive = moduleFile.isDirectory() ? new ExplodedArchive(moduleFile) : new JarFileArchive(moduleFile);
      List<Archive> nestedArchives = moduleArchive.getNestedArchives(new Archive.EntryFilter() {
        @Override
        public boolean matches(Archive.Entry entry) {
          return !entry.isDirectory() && entry.getName().startsWith(LIB);
        }
      });
      URL[] urls = new URL[nestedArchives.size() + 1];
      int i = 0;
      for (Archive nested : nestedArchives) {
        urls[i++] = nested.getUrl();
      }
      urls[i] = moduleArchive.getUrl();
      return new ParentLastURLClassLoader(urls, parent);
    }
    catch (IOException e) {
      throw new RuntimeException(e);
    }
View Full Code Here


    if (!isAbsolutePath(root)) {
      file = new File(this.home, root);
    }
    if (file.isDirectory()) {
      this.logger.info("Adding classpath entries from " + file);
      Archive archive = new ExplodedArchive(file, false);
      lib.add(archive);
    }
    Archive archive = getArchive(file);
    if (archive != null) {
      this.logger.info("Adding classpath entries from archive " + archive.getUrl()
          + root);
      lib.add(archive);
    }
    Archive nested = getNestedArchive(root);
    if (nested != null) {
      this.logger.info("Adding classpath entries from nested " + nested.getUrl()
          + root);
      lib.add(nested);
    }
    return lib;
  }
View Full Code Here

    }
    return null;
  }

  private Archive getNestedArchive(final String root) throws Exception {
    Archive parent = createArchive();
    if (root.startsWith("/") || parent.getUrl().equals(this.home.toURI().toURL())) {
      // If home dir is same as parent archive, no need to add it twice.
      return null;
    }
    EntryFilter filter = new PrefixMatchingArchiveFilter(root);
    if (parent.getNestedArchives(filter).isEmpty()) {
      return null;
    }
    // If there are more archives nested in this subdirectory (root) then create a new
    // virtual archive for them, and have it added to the classpath
    return new FilteredArchive(parent, filter);
View Full Code Here

TOP

Related Classes of org.springframework.boot.loader.archive.Archive

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.