Package ro.fortsoft.pf4j

Examples of ro.fortsoft.pf4j.PluginWrapper


    register(PluginDispatcher.class);

    List<DispatchCommand> exts = gitblit.getExtensions(DispatchCommand.class);
    for (DispatchCommand ext : exts) {
      Class<? extends DispatchCommand> extClass = ext.getClass();
      PluginWrapper wrapper = gitblit.whichPlugin(extClass);
      String plugin = wrapper.getDescriptor().getPluginId();
      CommandMetaData meta = extClass.getAnnotation(CommandMetaData.class);
      log.debug("Dispatcher {} is loaded from plugin {}", meta.name(), plugin);
      register(ext);
    }
  }
View Full Code Here


      logger.error("Failed to load plugin {}", file);
      return false;
    }

    // allow the plugin to prepare for operation after installation
    PluginWrapper pluginWrapper = pf4j.getPlugin(pluginId);
    if (pluginWrapper.getPlugin() instanceof GitblitPlugin) {
      ((GitblitPlugin) pluginWrapper.getPlugin()).onInstall();
    }

    PluginState state = pf4j.startPlugin(pluginId);
    return PluginState.STARTED.equals(state);
  }
View Full Code Here

        logger.error("Failed to load plugin {}", file);
        return false;
      }

      // the plugin to handle an upgrade
      PluginWrapper pluginWrapper = pf4j.getPlugin(newPluginId);
      if (pluginWrapper.getPlugin() instanceof GitblitPlugin) {
        ((GitblitPlugin) pluginWrapper.getPlugin()).onUpgrade(oldVersion);
      }

      PluginState state = pf4j.startPlugin(newPluginId);
      return PluginState.STARTED.equals(state);
    } else {
View Full Code Here

  public synchronized boolean uninstallPlugin(String pluginId) {
    return removePlugin(pluginId, true);
  }

  protected boolean removePlugin(String pluginId, boolean isUninstall) {
    PluginWrapper pluginWrapper = getPlugin(pluginId);
    final String name = pluginWrapper.getPluginPath().substring(1);

    if (isUninstall) {
      // allow the plugin to prepare for uninstallation
      if (pluginWrapper.getPlugin() instanceof GitblitPlugin) {
        ((GitblitPlugin) pluginWrapper.getPlugin()).onUninstall();
      }
    }

    if (pf4j.deletePlugin(pluginId)) {
View Full Code Here

    IPluginManager pluginManager = dagger.get(IPluginManager.class);

    filters = pluginManager.getExtensions(HttpRequestFilter.class);
    for (HttpRequestFilter f : filters) {
      // wrap the filter config for Gitblit settings retrieval
      PluginWrapper pluginWrapper = pluginManager.whichPlugin(f.getClass());
      FilterConfig runtimeConfig = new FilterRuntimeConfig(runtimeManager,
          pluginWrapper.getPluginId(), filterConfig);

      f.init(runtimeConfig);
    }
  }
View Full Code Here

  static abstract class PluginCommand extends SshCommand {

    protected PluginWrapper getPlugin(String id) throws Failure {
      IGitblit gitblit = getContext().getGitblit();
      PluginWrapper pluginWrapper = null;
      try {
        int index = Integer.parseInt(id);
        List<PluginWrapper> plugins = gitblit.getPlugins();
        if (index > plugins.size()) {
          throw new UnloggedFailure(1, "Invalid plugin index specified!");
View Full Code Here

      IGitblit gitblit = getContext().getGitblit();
      if (id.equalsIgnoreCase("ALL")) {
        gitblit.startPlugins();
        stdout.println("All plugins started");
      } else {
        PluginWrapper pluginWrapper = getPlugin(id);
        if (pluginWrapper == null) {
          throw new UnloggedFailure(String.format("Plugin %s is not installed!", id));
        }

        PluginState state = gitblit.startPlugin(pluginWrapper.getPluginId());
        if (PluginState.STARTED.equals(state)) {
          stdout.println(String.format("Started %s", pluginWrapper.getPluginId()));
        } else {
          throw new UnloggedFailure(1, String.format("Failed to start %s", pluginWrapper.getPluginId()));
        }
      }
    }
View Full Code Here

      IGitblit gitblit = getContext().getGitblit();
      if (id.equalsIgnoreCase("ALL")) {
        gitblit.stopPlugins();
        stdout.println("All plugins stopped");
      } else {
        PluginWrapper pluginWrapper = getPlugin(id);
        if (pluginWrapper == null) {
          throw new UnloggedFailure(String.format("Plugin %s is not installed!", id));
        }

        PluginState state = gitblit.stopPlugin(pluginWrapper.getPluginId());
        if (PluginState.STOPPED.equals(state)) {
          stdout.println(String.format("Stopped %s", pluginWrapper.getPluginId()));
        } else {
          throw new UnloggedFailure(1, String.format("Failed to stop %s", pluginWrapper.getPluginId()));
        }
      }
    }
View Full Code Here

    protected String id;

    @Override
    public void run() throws Failure {
      IGitblit gitblit = getContext().getGitblit();
      PluginWrapper pluginWrapper = getPlugin(id);
      if (pluginWrapper == null) {
        throw new UnloggedFailure("Invalid plugin specified!");
      }

      if (gitblit.enablePlugin(pluginWrapper.getPluginId())) {
        stdout.println(String.format("Enabled %s", pluginWrapper.getPluginId()));
      } else {
        throw new UnloggedFailure(1, String.format("Failed to enable %s", pluginWrapper.getPluginId()));
      }
    }
View Full Code Here

    protected String id;

    @Override
    public void run() throws Failure {
      IGitblit gitblit = getContext().getGitblit();
      PluginWrapper pluginWrapper = getPlugin(id);
      if (pluginWrapper == null) {
        throw new UnloggedFailure("Invalid plugin specified!");
      }

      if (gitblit.disablePlugin(pluginWrapper.getPluginId())) {
        stdout.println(String.format("Disabled %s", pluginWrapper.getPluginId()));
      } else {
        throw new UnloggedFailure(1, String.format("Failed to disable %s", pluginWrapper.getPluginId()));
      }
    }
View Full Code Here

TOP

Related Classes of ro.fortsoft.pf4j.PluginWrapper

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.