Examples of PluginWrapper


Examples of ro.fortsoft.pf4j.PluginWrapper

    protected String id;

    @Override
    public void run() throws Failure {
      IGitblit gitblit = getContext().getGitblit();
      PluginWrapper pw = getPlugin(id);
      if (pw == null) {
        PluginRegistration registration = gitblit.lookupPlugin(id);
        if (registration == null) {
          throw new Failure(1, String.format("Unknown plugin %s", id));
        }
View Full Code Here

Examples of ro.fortsoft.pf4j.PluginWrapper

    private boolean disableChecksum;

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

      PluginRelease pr = gitblit.lookupRelease(pluginWrapper.getPluginId(), version);
      if (pr == null) {
        throw new UnloggedFailure(1,  String.format("Plugin \"%s\" is not in the registry!", pluginWrapper.getPluginId()));
      }

      // enforce minimum system requirement
      if (!StringUtils.isEmpty(pr.requires)) {
        Version requires = Version.createVersion(pr.requires);
        Version system = gitblit.getSystemVersion();
        boolean isValid = system.isZero() || system.atLeast(requires);
        if (!isValid) {
          throw new Failure(1, String.format("Plugin \"%s:%s\" requires Gitblit %s",
              pluginWrapper.getPluginId(), pr.version, pr.requires));
        }
      }

      try {
        if (gitblit.upgradePlugin(pluginWrapper.getPluginId(), pr.url, !disableChecksum)) {
          stdout.println(String.format("Upgraded %s", pluginWrapper.getPluginId()));
        } else {
          throw new UnloggedFailure(1, String.format("Failed to upgrade %s", pluginWrapper.getPluginId()));
        }
      } catch (IOException e) {
        log.error("Failed to upgrade " + pluginWrapper.getPluginId(), e);
        throw new UnloggedFailure(1, String.format("Failed to upgrade %s", pluginWrapper.getPluginId()), e);
      }
    }
View Full Code Here

Examples of ro.fortsoft.pf4j.PluginWrapper

    protected String id;

    @Override
    public void run() throws Failure {
      IGitblit gitblit = getContext().getGitblit();
      PluginWrapper pluginWrapper = getPlugin(id);
      if (pluginWrapper == null) {
        throw new UnloggedFailure(String.format("Plugin %s is not installed!", id));
      }

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

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

Examples of ro.fortsoft.pf4j.PluginWrapper

      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

Examples of ro.fortsoft.pf4j.PluginWrapper

        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

Examples of ro.fortsoft.pf4j.PluginWrapper

  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

Examples of ro.fortsoft.pf4j.PluginWrapper

        String [] h = { "#", "Id", "Version", "State", "Path"};
        headers = h;
      }
      Object[][] data = new Object[list.size()][];
      for (int i = 0; i < list.size(); i++) {
        PluginWrapper p = list.get(i);
        PluginDescriptor d = p.getDescriptor();
        if (verbose) {
          data[i] = new Object[] { "" + (i + 1), d.getPluginId(), d.getPluginDescription(), d.getVersion(), d.getRequires(), p.getPluginState(), p.getPluginPath() };
        } else {
          data[i] = new Object[] { "" + (i + 1), d.getPluginId(), d.getVersion(), p.getPluginState(), p.getPluginPath() };
        }
      }

      stdout.println(FlipTable.of(headers, data, Borders.BODY_HCOLS));
    }
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.