Exemplo n.º 1
0
  private void logPluginDetails(final PluginWrapper plugin) {
    assert plugin != null;

    log.debug("Loaded plugin: {} ({})", plugin.getShortName(), plugin.getVersion());

    // Some details are not valid until the createPluginWrapper() has returned... like bundled
    // status

    log.debug(
        "  State: active={}, enabled={}, pinned={}, downgradable={}",
        new Object[] {
          plugin.isActive(), plugin.isEnabled(), plugin.isPinned(), plugin.isDowngradable()
        });

    // Spit out some debug/trace details about the classpath
    PluginClassLoader cl = (PluginClassLoader) plugin.classLoader;
    URL[] classpath = cl.getURLs();
    if (classpath.length > 1) {
      log.debug("  Classpath:");
      int i = 0;
      boolean trace = log.isTraceEnabled();
      for (URL url : classpath) {
        // skip the classes/ dir its always there
        if (i++ == 0) {
          continue;
        }
        // for trace still log as debug, but flip on the full URL
        log.debug("    {}", trace ? url.toString() : basename(url.getFile()));
      }
    }

    // Spit out some debug information about the plugin dependencies
    List<Dependency> dependencies = plugin.getDependencies();
    if (dependencies != null && !dependencies.isEmpty()) {
      log.debug("  Dependencies:");
      for (Dependency dependency : dependencies) {
        log.debug("    {}", dependency);
      }
    }

    dependencies = plugin.getOptionalDependencies();
    if (dependencies != null && !dependencies.isEmpty()) {
      log.debug("  Optional dependencies:");
      for (Dependency dependency : plugin.getOptionalDependencies()) {
        log.debug("    {}", dependency);
      }
    }
  }
Exemplo n.º 2
0
  /**
   * Returns the classpath to use for the JSPC Compiler.
   *
   * @param plugin the plugin the jspc will handle.
   * @return the classpath needed to compile a single jsp in a plugin.
   */
  private static String getClasspathForPlugin(Plugin plugin) {
    final StringBuilder classpath = new StringBuilder();

    File pluginDirectory = pluginManager.getPluginDirectory(plugin);

    PluginDevEnvironment pluginEnv = pluginManager.getDevEnvironment(plugin);

    PluginClassLoader pluginClassloader = pluginManager.getPluginClassloader(plugin);

    for (URL url : pluginClassloader.getURLs()) {
      File file = new File(url.getFile());

      classpath.append(file.getAbsolutePath()).append(";");
    }

    // Load all jars from lib
    File libDirectory = new File(pluginDirectory, "lib");
    File[] libs = libDirectory.listFiles();
    final int no = libs != null ? libs.length : 0;
    for (int i = 0; i < no; i++) {
      File libFile = libs[i];
      classpath.append(libFile.getAbsolutePath()).append(';');
    }

    File openfireRoot = pluginDirectory.getParentFile().getParentFile().getParentFile();
    File openfireLib = new File(openfireRoot, "target//lib");

    classpath.append(openfireLib.getAbsolutePath()).append("//servlet.jar;");
    classpath.append(openfireLib.getAbsolutePath()).append("//openfire.jar;");
    classpath.append(openfireLib.getAbsolutePath()).append("//jasper-compiler.jar;");
    classpath.append(openfireLib.getAbsolutePath()).append("//jasper-runtime.jar;");

    if (pluginEnv.getClassesDir() != null) {
      classpath.append(pluginEnv.getClassesDir().getAbsolutePath()).append(";");
    }
    return classpath.toString();
  }