org.apache.karaf.shell.api.action.Option类的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(18.8k)|赞(0)|评价(0)|浏览(235)

本文整理了Java中org.apache.karaf.shell.api.action.Option类的一些代码示例,展示了Option类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Option类的具体详情如下:
包路径:org.apache.karaf.shell.api.action.Option
类名称:Option

Option介绍

暂无

代码示例

代码示例来源:origin: apache/karaf

public abstract class MavenSecuritySupport extends MavenConfigurationSupport {

  @Option(name = "-x", aliases = { "--show-passwords" }, description = "Do not hide passwords related to Maven encryption", required = false, multiValued = false)
  boolean showPasswords;

  @Override
  protected boolean showPasswords() {
    return showPasswords;
  }

}

代码示例来源:origin: org.xipki.qa.shells/security-speed-shell

@Option(name = "--duration", description = "duration")
private String duration = "30s";
@Option(name = "--thread", description = "number of threads")
private Integer numThreads = 5;

代码示例来源:origin: apache/karaf

String name;
@Option(name = "-dn", aliases = { "--driverName" }, description = "org.osgi.driver.name property of the DataSourceFactory", required = false, multiValued = false)
String driverName;
@Option(name = "-dc", aliases = { "--driverClass" }, description = "org.osgi.driver.class property  of the DataSourceFactory", required = false, multiValued = false)
String driverClass;
@Option(name = "-dbName", description = "Database name to use", required = false, multiValued = false)
String databaseName;
@Option(name = "-url", description = "The JDBC URL to use", required = false, multiValued = false)
String url;
@Option(name = "-u", aliases = { "--username" }, description = "The database username", required = false, multiValued = false)
String username;
@Option(name = "-p", aliases = { "--password" }, description = "The database password", required = false, multiValued = false)
String password;
@Option(name = "-dt", aliases = { "--databaseType" }, description = "The database type (ConnectionPoolDataSource, XADataSource or DataSource)", required = false, multiValued = false)
String databaseType;

代码示例来源:origin: apache/karaf

@Command(scope = "feature", name = "refresh", description = "Reloads features processing instructions and reprovisions existing features.")
@Service
public class RefreshFeaturesCommand extends FeaturesCommandSupport {

  @Option(name = "-v", aliases = "--verbose", description = "Explain what is being done", required = false, multiValued = false)
  boolean verbose;

  @Option(name = "-t", aliases = "--simulate", description = "Perform a simulation only", required = false, multiValued = false)
  boolean simulate;

  @Option(name = "--features-wiring", description = "Print the wiring between features")
  boolean featuresWiring;

  @Option(name = "--all-wiring", description = "Print the full wiring")
  boolean allWiring;

  protected void doExecute(FeaturesService featuresService) throws Exception {
    addOption(FeaturesService.Option.Simulate, simulate);
    addOption(FeaturesService.Option.Verbose, verbose);
    addOption(FeaturesService.Option.DisplayFeaturesWiring, featuresWiring);
    addOption(FeaturesService.Option.DisplayAllWiring, allWiring);
    try {
      featuresService.refreshFeatures(options);
    } catch (Exception e) {
      System.err.println("Error refreshing features: " + e.getMessage());
    }
  }

}

代码示例来源:origin: apache/karaf

/**
 * For commands that need a connection factory and authentication information 
 */
public abstract class JmsConnectionCommandSupport extends JmsCommandSupport {

  @Argument(index = 0, name = "connectionFactory", description = "The JMS connection factory name", required = true, multiValued = false)
  @Completion(ConnectionFactoriesNameCompleter.class)
  String connectionFactory;

  @Option(name = "-u", aliases = { "--username" }, description = "Username to connect to the JMS broker", required = false, multiValued = false)
  String username = "karaf";

  @Option(name = "-p", aliases = { "--password" }, description = "Password to connect to the JMS broker", required = false, multiValued = false)
  String password = "karaf";

}

代码示例来源:origin: org.apache.karaf.features/org.apache.karaf.features.command

@Command(scope = "feature", name = "refresh", description = "Reloads features processing instructions and reprovisions existing features.")
@Service
public class RefreshFeaturesCommand extends FeaturesCommandSupport {

  @Option(name = "-v", aliases = "--verbose", description = "Explain what is being done", required = false, multiValued = false)
  boolean verbose;

  @Option(name = "-t", aliases = "--simulate", description = "Perform a simulation only", required = false, multiValued = false)
  boolean simulate;

  @Option(name = "--features-wiring", description = "Print the wiring between features")
  boolean featuresWiring;

  @Option(name = "--all-wiring", description = "Print the full wiring")
  boolean allWiring;

  protected void doExecute(FeaturesService featuresService) throws Exception {
    addOption(FeaturesService.Option.Simulate, simulate);
    addOption(FeaturesService.Option.Verbose, verbose);
    addOption(FeaturesService.Option.DisplayFeaturesWiring, featuresWiring);
    addOption(FeaturesService.Option.DisplayAllWiring, allWiring);
    try {
      featuresService.refreshFeatures(options);
    } catch (Exception e) {
      System.err.println("Error refreshing features: " + e.getMessage());
    }
  }

}

代码示例来源:origin: apache/karaf

public abstract class DockerCommandSupport implements Action {

  @Option(name = "-u", aliases = "--url", description = "The location of the Docker REST API", required = false, multiValued = false)
  String url;

  @Reference
  private DockerService dockerService;

  public DockerService getDockerService() {
    return dockerService;
  }

  public void setDockerService(DockerService dockerService) {
    this.dockerService = dockerService;
  }

}

代码示例来源:origin: apache/karaf

@Command(scope = "docker", name = "provision", description = "Create a Docker container using the current running Karaf instance")
@Service
public class ProvisionCommand extends DockerCommandSupport {

  @Argument(index = 0, name = "name", description = "Name of the Docker container", required = true, multiValued = false)
  String name;

  @Option(name = "-c", aliases = "--copy", description = "Use directly the current Karaf instance working dir or make a copy", required = false, multiValued = false)
  boolean copy;

  @Option(name = "--sshPort", description = "Port number used by the Karaf SSH server", required = false, multiValued = false)
  String sshPort = "8101";

  @Option(name = "--jmxRmiPort", description = "Port number used by the Karaf JMX RMI MBeanServer", required = false, multiValued = false)
  String jmxRmiPort = "1099";

  @Option(name = "--jmxRmiRegistryPort", description = "Port number used by the Karaf JMX RMI Registry MBeanServer", required = false, multiValued = false)
  String jmxRmiRegistryPort = "44444";

  @Option(name = "--httpPort", description = "Port number used by the Karaf HTTP service", required = false, multiValued = false)
  String httpPort = "8181";

  @Override
  public Object execute() throws Exception {
    getDockerService().provision(name, sshPort, jmxRmiPort, jmxRmiRegistryPort, httpPort, copy, url);
    return null;
  }

}

代码示例来源:origin: apache/karaf-cellar

/**
 * Abstract cluster shell command.
 */
public abstract class ClusterCommandSupport extends CellarCommandSupport {

  @Option(name = "-t", aliases = { "--timeout" }, description = "Consumer command timeout (in seconds)", required = false, multiValued = false)
  protected long timeout = 30;

  @Reference
  protected ExecutionContext executionContext;

  public ExecutionContext getExecutionContext() {
    return executionContext;
  }

  public void setExecutionContext(ExecutionContext executionContext) {
    this.executionContext = executionContext;
  }

}

代码示例来源:origin: org.xipki.shell/ca-mgmt-shell

@Command(scope = "ca", name = "export-ca", description = "export CA database")
@Service
public static class ExportCa extends DbPortAction {
 @Option(name = "--db-conf", required = true, description = "database configuration file")
 @Completion(FileCompleter.class)
 private String dbconfFile;
 @Option(name = "--out-dir", required = true, description = "output directory")
 @Completion(Completers.DirCompleter.class)
 private String outdir;
 @Option(name = "-n", description = "number of certificates in one zip file")
 private Integer numCertsInBundle = 10000;
 @Option(name = "-k", description = "number of certificates per SELECT")
 private Integer numCertsPerCommit = 100;
 @Option(name = "--resume", description = "resume from the last successful point")
 private Boolean resume = Boolean.FALSE;
 @Override
 protected DbPortWorker getDbPortWorker() throws Exception {
  return new DbPortWorker.ExportCaDb(datasourceFactory, passwordResolver, dbconfFile, outdir,
    resume, numCertsInBundle, numCertsPerCommit);
 }
}

代码示例来源:origin: org.xipki.shell/ca-mgmt-shell

@Command(scope = "ca", name = "export-ocsp", description = "export OCSP database")
@Service
public static class ExportOcsp extends DbPortAction {
 @Option(name = "--db-conf", required = true, description = "database configuration file.")
 @Completion(FileCompleter.class)
 private String dbconfFile;
 @Option(name = "--out-dir", required = true, description = "output directory")
 @Completion(Completers.DirCompleter.class)
 private String outdir;
 @Option(name = "-n", description = "number of certificates in one zip file")
 private Integer numCertsInBundle = 10000;
 @Option(name = "-k", description = "number of certificates per SELECT")
 private Integer numCertsPerSelect = 100;
 @Option(name = "--resume", description = "resume from the last successful point")
 private Boolean resume = Boolean.FALSE;
 @Override
 protected DbPortWorker getDbPortWorker() throws Exception {
  return new DbPortWorker.ExportOcspDb(datasourceFactory, passwordResolver, dbconfFile, outdir,
    resume, numCertsInBundle, numCertsPerSelect);
 }
}

代码示例来源:origin: org.xipki.shell/ca-mgmt-shell

@Command(scope = "ca", name = "import-ca", description = "import CA database")
@Service
public static class ImportCa extends DbPortAction {
 @Option(name = "--db-conf", required = true, description = "database configuration file")
 @Completion(FileCompleter.class)
 private String dbconfFile;
 @Option(name = "--in-dir", required = true, description = "input directory")
 @Completion(Completers.DirCompleter.class)
 private String indir;
 @Option(name = "-k", description = "number of certificates per commit")
 private Integer numCertsPerCommit = 100;
 @Option(name = "--resume", description = "resume from the last successful point")
 private Boolean resume = Boolean.FALSE;
 @Override
 protected DbPortWorker getDbPortWorker() throws Exception {
  return new DbPortWorker.ImportCaDb(datasourceFactory, passwordResolver, dbconfFile, resume,
    indir, numCertsPerCommit.intValue());
 }
}

代码示例来源:origin: org.xipki.shell/ca-mgmt-shell

@Command(scope = "ca", name = "import-ocsp", description = "import OCSP database")
@Service
public static class ImportOcsp extends DbPortAction {
 @Option(name = "--db-conf", required = true, description = "database configuration file")
 @Completion(FileCompleter.class)
 private String dbconfFile;
 @Option(name = "--in-dir", required = true, description = "input directory")
 @Completion(Completers.DirCompleter.class)
 private String indir;
 @Option(name = "-k", description = "number of certificates per commit")
 private Integer numCertsPerCommit = 100;
 @Option(name = "--resume", description = "resume from the last successful point")
 private Boolean resume = Boolean.FALSE;
 @Override
 protected DbPortWorker getDbPortWorker() throws Exception {
  return new DbPortWorker.ImportOcspDb(datasourceFactory, passwordResolver, dbconfFile, resume,
    indir, numCertsPerCommit.intValue());
 }
}

代码示例来源:origin: apache/karaf

@Command(scope = "feature", name = "uninstall", description = "Uninstalls a feature with the specified name and version.")
@Service
public class UninstallFeatureCommand extends FeaturesCommandSupport {

  @Argument(index = 0, name = "features", description = "The name and version of the features to uninstall. A feature id looks like name/version. The version is optional.", required = true, multiValued = true)
  @Completion(RequiredFeatureCompleter.class)
  List<String> features;

  @Option(name = "-r", aliases = "--no-auto-refresh", description = "Do not automatically refresh bundles", required = false, multiValued = false)
  boolean noRefresh;

  @Option(name = "-v", aliases = "--verbose", description = "Explain what is being done", required = false, multiValued = false)
  boolean verbose;

  @Option(name = "-t", aliases = "--simulate", description = "Perform a simulation only", required = false, multiValued = false)
  boolean simulate;

  @Option(name = "-g", aliases = "--region", description = "Region to install to")
  String region;

  protected void doExecute(FeaturesService admin) throws Exception {
    addOption(FeaturesService.Option.Simulate, simulate);
    addOption(FeaturesService.Option.Verbose, verbose);
    addOption(FeaturesService.Option.NoAutoRefreshBundles, noRefresh);
    admin.uninstallFeatures(new HashSet<>(features), region, options);
  }
}

代码示例来源:origin: org.apache.karaf.features/org.apache.karaf.features.command

@Command(scope = "feature", name = "uninstall", description = "Uninstalls a feature with the specified name and version.")
@Service
public class UninstallFeatureCommand extends FeaturesCommandSupport {

  @Argument(index = 0, name = "features", description = "The name and version of the features to uninstall. A feature id looks like name/version. The version is optional.", required = true, multiValued = true)
  @Completion(RequiredFeatureCompleter.class)
  List<String> features;

  @Option(name = "-r", aliases = "--no-auto-refresh", description = "Do not automatically refresh bundles", required = false, multiValued = false)
  boolean noRefresh;

  @Option(name = "-v", aliases = "--verbose", description = "Explain what is being done", required = false, multiValued = false)
  boolean verbose;

  @Option(name = "-t", aliases = "--simulate", description = "Perform a simulation only", required = false, multiValued = false)
  boolean simulate;

  @Option(name = "-g", aliases = "--region", description = "Region to install to")
  String region;

  protected void doExecute(FeaturesService admin) throws Exception {
    addOption(FeaturesService.Option.Simulate, simulate);
    addOption(FeaturesService.Option.Verbose, verbose);
    addOption(FeaturesService.Option.NoAutoRefreshBundles, noRefresh);
    admin.uninstallFeatures(new HashSet<>(features), region, options);
  }
}

代码示例来源:origin: apache/karaf

String name;
@Option(name = "-t", aliases = { "--type" }, description = "The JMS connection factory type (ActiveMQ, Artemis or WebsphereMQ)", required = false, multiValued = false)
@Completion(value = StringsCompleter.class, values = { "activemq", "artemis", "webspheremq" })
String type = "activemq";
@Option(name = "--url", description = "URL of the JMS broker. For WebsphereMQ type, the URL is hostname/port/queuemanager/channel", required = false, multiValued = false)
String url = "tcp://localhost:61616";
@Option(name = "--pool", description = "The pool mechanism to use for this connection factory", required = false, multiValued = false)
@Completion(value = StringsCompleter.class, values = { "pooledjms", "narayama", "transx" })
String pool = "pooledjms";
@Option(name = "-u", aliases = { "--username" }, description = "Username to connect to the JMS broker", required = false, multiValued = false)
String username = "karaf";
@Option(name = "-p", aliases = { "--password" }, description = "Password to connect to the JMS broker", required = false, multiValued = false)
String password = "karaf";

代码示例来源:origin: apache/karaf

String container;
@Option(name = "--stdout", description = "Display stdout", required = false, multiValued = false)
boolean stdout = true;
@Option(name = "--stderr", description = "Display stderr", required = false, multiValued = false)
boolean stderr;
@Option(name = "--timestamps", description = "Show timestamps", required = false, multiValued = false)
boolean timestamps;
@Option(name = "--details", description = "Show extra details provided to logs", required = false, multiValued = false)
boolean details;

代码示例来源:origin: apache/karaf

@Command(scope = "obr", name = "deploy", description = "Deploys a list of bundles using OBR service.")
@Service
public class DeployCommand extends ObrCommandSupport {

  @Argument(index = 0, name = "bundles", description = "List of bundle names to deploy (separated by whitespaces). The bundles are identified using the following syntax: symbolic_name,version where version is optional.", required = true, multiValued = true)
  protected List<String> bundles;

  @Option(name = "-s", aliases = { "--start" }, description = "Start the deployed bundles", required = false, multiValued = false)
  protected boolean start = false;

  @Option(name = "-d", aliases = { "--deployOptional" }, description = "Deploy optional bundles", required = false, multiValued = false)
  protected boolean deployOptional = false;

  protected void doExecute(RepositoryAdmin admin) throws Exception {
    doDeploy(admin, bundles, start, deployOptional);
  }

}

代码示例来源:origin: org.xipki.shell/ca-mgmt-shell

@Command(scope = "ca", name = "user-rm", description = "remove user")
@Service
public static class UserRm extends CaAction {
 @Option(name = "--name", aliases = "-n", required = true, description = "user Name")
 private String name;
 @Option(name = "--force", aliases = "-f", description = "without prompt")
 private Boolean force = Boolean.FALSE;
 @Override
 protected Object execute0() throws Exception {
  String msg = "user " + name;
  if (force || confirm("Do you want to remove " + msg, 3)) {
   try {
    caManager.removeUser(name);
    println("removed " + msg);
   } catch (CaMgmtException ex) {
    throw new CmdFailure("could not remove " + msg + ", error: " + ex.getMessage(), ex);
   }
  }
  return null;
 }
}

代码示例来源:origin: org.xipki.shell/ca-mgmt-shell

@Command(scope = "ca", name = "causer-rm", description = "remove user from CA")
@Service
public static class CauserRm extends CaAction {
 @Option(name = "--ca", required = true, description = "CA name")
 @Completion(CaCompleters.CaNameCompleter.class)
 private String caName;
 @Option(name = "--user", required = true, description = "user name")
 private String userName;
 @Option(name = "--force", aliases = "-f", description = "without prompt")
 private Boolean force = Boolean.FALSE;
 @Override
 protected Object execute0() throws Exception {
  String msg = "user " + userName + " from CA " + caName;
  if (force || confirm("Do you want to remove " + msg, 3)) {
   try {
    caManager.removeUserFromCa(userName, caName);
    println("removed " + msg);
   } catch (CaMgmtException ex) {
    throw new CmdFailure("could not remove " + msg + ", error: " + ex.getMessage(), ex);
   }
  }
  return null;
 }
}

相关文章