Examples of IPlugInFinder


Examples of org.jamesii.core.plugins.install.IPlugInFinder

    Set<String> ps = new HashSet<>();

    // **************************** get plug-ins
    // *****************************
    IPlugInFinder pluginFinder;

    if (useCache) {
      try { // try to load from cache
        pluginFinder = new CachePlugInFinder();
      } catch (Exception e) {
        // loading the cache failed
        pluginFinder = initBySearch(ps);
        // create a new cache
        CachePlugInFinder cf = new CachePlugInFinder();
        cf.copyFrom(pluginFinder);
        cf.write();
      }
    } else {
      pluginFinder = initBySearch(ps);
    }

    // If you write the cache once with the lines above than this lines
    // reads to
    // start JII without scanning for new plug-ins

    // get the classpath content
    List<String> paths =
        org.jamesii.core.util.misc.Files.getListOfPaths(System
            .getProperty("java.class.path"));

    // the paths of plug-ins found
    ps.addAll(paths);

    // built a list of URLs from the string paths
    Set<URI> pURIs = new HashSet<>();
    for (String p : ps) {
      try {
        pURIs.add(new File(p).getCanonicalFile().toURI());
      } catch (IOException e1) {
        SimSystem.report(e1);
      }
    }

    // *************** load plug-in types and plug-ins
    // ****************

    List<URL> pURLs = new ArrayList<>();
    for (URI uri : pURIs) {
      try {
        pURLs.add(uri.toURL());
      } catch (MalformedURLException e1) {
        SimSystem.report(e1);
      }
    }

    // get the list of jar files searched (to be used for the class
    // path of the
    // class loader)
    List<URL> classPath = pluginFinder.getJARLocations();

    // merge the jar files and the normal directories
    classPath.addAll(0, pURLs);

    // sort classPath by locations to always have a deterministic list of urls
    Collections.sort(classPath, new Comparator<URL>() {
      @Override
      public int compare(URL o1, URL o2) {
        if (o1 == null)
          return -1;
        if (o2 == null)
          return 1;
        return o1.toExternalForm().compareTo(o2.toExternalForm());
      }
    });

    URL[] path = new URL[classPath.size()];
    classPath.toArray(path);

    final URL[] p = path;

    // TODO sr137: add classloader on top of each plugin classloader
    // and add jar urls on the fly

    classLoader =
        AccessController.doPrivileged(new PrivilegedAction<URLClassLoader>() {
          @Override
          public URLClassLoader run() {
            return new URLClassLoader(p, this.getClass().getClassLoader());
          }
        });

    foundPlugins = pluginFinder.getFoundPlugins();
    // sort plugin list to ensure deterministic ordering
    Collections.sort(foundPlugins, new Comparator<IPluginData>() {
      @Override
      public int compare(IPluginData o1, IPluginData o2) {
        if (o1 == null)
          return -1;
        if (o2 == null)
          return 1;
        return o1.getId().compareTo(o2.getId());
      }
    });

    foundPluginTypes = pluginFinder.getFoundPluginTypes();
    // sort plugintypes list first to ensure deterministic ordering
    Collections.sort(foundPluginTypes, new Comparator<IPluginTypeData>() {
      @Override
      public int compare(IPluginTypeData o1, IPluginTypeData o2) {
        if (o1 == null)
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.