Package freenet.support

Examples of freenet.support.JarClassLoader


      } finally {
        Closer.close(pluginJarFile);
      }

      try {
        JarClassLoader jarClassLoader = new JarClassLoader(pluginFile);
        Class<?> pluginMainClass = jarClassLoader.loadClass(pluginMainClassName);
        Object object = pluginMainClass.newInstance();
        if(!(object instanceof FredPlugin)) {
          Logger.error(this, "plugin main class is not a plugin");
          pluginFile.delete();
          if(!downloaded) continue;
          throw new PluginNotFoundException("plugin main class is not a plugin");
        }

        if(pdl instanceof PluginDownLoaderOfficialHTTPS ||
            pdl instanceof PluginDownLoaderOfficialFreenet) {
          System.err.println("Loading official plugin "+name);
          // Check the version after loading it!
          // FIXME IMPORTANT Build the version into the manifest. This is actually pretty easy and just involves changing build.xml.
          // We already do similar things elsewhere.

          // Ugh, this is just as messy ... ideas???? Maybe we need to have OS
          // detection and use grep/sed on unix and find on windows???

          OfficialPluginDescription desc = officialPlugins.get(name);

          long minVer = desc.minimumVersion;
          long ver = -1;

          if(minVer != -1) {
            if(object instanceof FredPluginRealVersioned) {
              ver = ((FredPluginRealVersioned)object).getRealVersion();
            }
          }

          // FIXME l10n the PluginNotFoundException errors.
          if(ver < minVer) {
            System.err.println("Failed to load plugin "+name+" : TOO OLD: need at least version "+minVer+" but is "+ver);
            Logger.error(this, "Failed to load plugin "+name+" : TOO OLD: need at least version "+minVer+" but is "+ver);

            // At this point, the constructor has run, so it's theoretically possible that the plugin has e.g. created some threads.
            // However, it has not been able to use any of the node's services, because we haven't passed it the PluginRespirator.
            // So there is no need to call runPlugin and terminate().
            // And it doesn't matter all that much if the shutdown fails - we won't be able to delete the file on Windows anyway, we're relying on the ignoreOld logic.
            // Plus, this will not cause a leak of more than one fd per plugin, even when it has started threads.
            try {
              jarClassLoader.close();
            } catch (Throwable t) {
              Logger.error(this, "Failed to close jar classloader for plugin: "+t, t);
            }
            pluginFile.delete();
            if(!downloaded) continue;
View Full Code Here

TOP

Related Classes of freenet.support.JarClassLoader

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.