예제 #1
0
 public String getAmpsVersion(String pluginName) {
   for (Plugin plugin : loadedPlugins) {
     if (plugin.getName().equals(pluginName)) {
       return plugin.getAmpsVersion();
     }
   }
   return null;
 }
예제 #2
0
  /** @see ContainerService#shutdown() */
  public void shutdown() {
    // Inform the plugins we are shutting them down.
    // We want to shut them down in the reverse order that we initialized them.
    Collections.reverse(this.loadedPlugins);
    for (Plugin plugin : loadedPlugins) {
      PluginLifecycleListener listener = pluginLifecycleListenerMgr.getListener(plugin.getName());
      if (listener != null) {
        try {
          ClassLoader originalCL = Thread.currentThread().getContextClassLoader();
          Thread.currentThread()
              .setContextClassLoader(
                  this.classLoaderManager.obtainPluginClassLoader(plugin.getName()));
          try {
            listener.shutdown();
          } finally {
            Thread.currentThread().setContextClassLoader(originalCL);
          }
        } catch (Throwable t) {
          log.warn(
              "Failed to get lifecycle listener to shutdown ["
                  + plugin.getName()
                  + "]. Cause: "
                  + ThrowableUtil.getAllMessages(t));
        }
      }
    }

    // Clean up the plugin environment and the temp dirs that were used by the plugin classloaders.
    for (PluginEnvironment pluginEnvironment : this.loadedPluginEnvironments.values()) {
      pluginEnvironment.destroy();
    }
    this.classLoaderManager.destroy();

    this.loadedPluginEnvironments.clear();
    this.loadedPlugins.clear();

    pluginLifecycleListenerMgr.shutdown();
  }