Beispiel #1
0
  public void init() throws GaspException {
    configureLogging();

    loadProperties();
    log.info("Using home directory: " + homeDir);

    final PluginRegistry pluginRegistry = PluginManager.instance().getPluginRegistry();

    final File pluginsDir = new File(homeDir, PLUGINS_DIR);
    if (!pluginsDir.exists() || !pluginsDir.isDirectory()) {
      throw new IllegalStateException(
          "Plugins directory is not available: " + pluginsDir.getAbsolutePath());
    }

    // installing local plugins
    final File[] plugins = pluginsDir.listFiles(new JarFileFilter());
    if (plugins != null) {
      for (int i = 0; i < plugins.length; ++i) {
        final File pluginFile = plugins[i].getAbsoluteFile();

        log.info("Installing plugin: " + pluginFile.getPath());
        try {
          pluginRegistry.install(pluginFile.toURI().toURL());
        } catch (Exception e) {
          throw new GaspException("Error while installing plugin: " + pluginFile.getPath(), e);
        }
      }
    }
    initDone = true;
  }
Beispiel #2
0
  public void start() throws GaspException {
    checkInitDone();

    log.debug("Starting application");
    final Package pkg = getClass().getPackage();
    final String title = pkg.getSpecificationTitle();
    final String version = pkg.getSpecificationVersion();
    if (!StringUtils.isBlank(title) && !StringUtils.isBlank(version)) {
      // print version in the log
      log.info("Using: " + title + " " + version);
    }

    final PluginRegistry pluginRegistry = PluginManager.instance().getPluginRegistry();

    for (final String pluginDesc : pluginsToStart) {
      try {
        final String pluginId = getPluginId(pluginDesc);
        final Version pluginVersion = getPluginVersion(pluginDesc);
        pluginRegistry.activate(pluginId, pluginVersion);
      } catch (Exception e) {
        throw new GaspException("Error while starting plugin: " + pluginDesc, e);
      }
    }

    log.info("Platform is up and running");
  }