예제 #1
0
  protected NamedConfigParametersModule readConfiguration(final String configFile) {
    final List<Object> beans = getCommandConfigurationBeans();
    for (Object bean : beans) {
      jadConfig.addConfigurationBean(bean);
    }
    jadConfig.setRepositories(getConfigRepositories(configFile));

    LOG.debug("Loading configuration from config file: {}", configFile);
    try {
      jadConfig.process();
    } catch (RepositoryException e) {
      LOG.error("Couldn't load configuration: {}", e.getMessage());
      System.exit(1);
    } catch (ParameterException | ValidationException e) {
      LOG.error("Invalid configuration", e);
      System.exit(1);
    }

    if (configuration.getRestTransportUri() == null) {
      configuration.setRestTransportUri(configuration.getDefaultRestTransportUri());
      LOG.debug(
          "No rest_transport_uri set. Using default [{}].", configuration.getRestTransportUri());
    }

    return new NamedConfigParametersModule(jadConfig.getConfigurationBeans());
  }
예제 #2
0
  private String getPluginPath(String configFile) {
    PluginLoaderConfig pluginLoaderConfig = new PluginLoaderConfig();
    JadConfig jadConfig = new JadConfig(getConfigRepositories(configFile), pluginLoaderConfig);

    try {
      jadConfig.process();
    } catch (RepositoryException e) {
      LOG.error("Couldn't load configuration: {}", e.getMessage());
      System.exit(1);
    } catch (ParameterException | ValidationException e) {
      LOG.error("Invalid configuration", e);
      System.exit(1);
    }

    return pluginLoaderConfig.getPluginDir();
  }
예제 #3
0
  protected CmdLineTool(String commandName, BaseConfiguration configuration) {
    jadConfig = new JadConfig();
    jadConfig.addConverterFactory(new GuavaConverterFactory());
    jadConfig.addConverterFactory(new JodaTimeConverterFactory());

    if (commandName == null) {
      if (this.getClass().isAnnotationPresent(Command.class)) {
        this.commandName = this.getClass().getAnnotation(Command.class).name();
      } else {
        this.commandName = "tool";
      }
    } else {
      this.commandName = commandName;
    }
    this.configuration = configuration;
  }
예제 #4
0
 private PluginBindings installPluginConfigAndBindings(String pluginPath) {
   final Set<Plugin> plugins = loadPlugins(pluginPath);
   final PluginBindings pluginBindings = new PluginBindings(plugins);
   for (final Plugin plugin : plugins) {
     for (final PluginModule pluginModule : plugin.modules()) {
       for (final PluginConfigBean configBean : pluginModule.getConfigBeans()) {
         jadConfig.addConfigurationBean(configBean);
       }
     }
   }
   return pluginBindings;
 }
예제 #5
0
 private void dumpDefaultConfigAndExit() {
   for (Object bean : getCommandConfigurationBeans()) jadConfig.addConfigurationBean(bean);
   dumpCurrentConfigAndExit();
 }
예제 #6
0
 private void dumpCurrentConfigAndExit() {
   System.out.println(dumpConfiguration(jadConfig.dump()));
   System.exit(0);
 }