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

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

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

Option介绍

暂无

代码示例

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

/**
 * 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)
  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: apache/karaf

out.println(INTENSITY_BOLD + "OPTIONS" + INTENSITY_NORMAL);
for (Option option : optionsSet) {
  String opt = option.name();
  for (String alias : option.aliases()) {
    opt += ", " + alias;
  ActionMetaData.printFormatted("                ", option.description(), termWidth, out, true);
  if (option.valueToShowInHelp() != null && option.valueToShowInHelp().length() != 0) {
    if (Option.DEFAULT_STRING.equals(option.valueToShowInHelp())) {
      Object o = getDefaultValue(action, option);
      String defaultValue = getDefaultValueString(o);
      printDefaultsTo(out, option.valueToShowInHelp());

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

+ COLOR_DEFAULT + ": " : "";
for (Object param : params) {
  if (HelpOption.HELP.name().equals(param)) {
    int termWidth = getWidth(session);
    boolean globalScope = NameScoping.isGlobalScope(session, actionMetaData.getCommand().scope());
      if (name.equals(opt.name()) || Arrays.asList(opt.aliases()).contains(name)) {
        option = opt;
        break;
        );
    if (option.multiValued()) {
      @SuppressWarnings("unchecked")
      List<Object> l = (List<Object>) optionValues.get(option);
  if (option.required() && optionValues.get(option) == null) {
      throw new CommandException(commandErrorSt +
          "option " + INTENSITY_BOLD + option.name() + INTENSITY_NORMAL + " is required",
          "Option " + option.name() + " is required"
      );
  } catch (Exception e) {
      throw new CommandException(commandErrorSt +
          "unable to convert option " + INTENSITY_BOLD + entry.getKey().name() + INTENSITY_NORMAL + " with value '"
          + entry.getValue() + "' to type " + new GenericType(field.getGenericType()).toString(),
          "Unable to convert option " + entry.getKey().name() + " with value '"
              + entry.getValue() + "' to type " + new GenericType(field.getGenericType()).toString(),

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

if (option != null) {
      fields.put(option, field);
      options.put(option.name(), option);
      String[] aliases = option.aliases();
      if (aliases != null) {
        for (String alias : aliases) {
options.put(HelpOption.HELP.name(), HelpOption.HELP);
optionsCompleter = new StringsCompleter(options.keySet());
      completer = NullCompleter.INSTANCE;
    optionalCompleters.put(option.name(), completer);
    if (option.aliases() != null) {
      for (String alias : option.aliases()) {
        optionalCompleters.put(alias, completer);

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

if (option != null) {
      fields.put(option, field);
      options.put(option.name(), option);
      String[] aliases = option.aliases();
      if (aliases != null) {
        for (String alias : aliases) {
options.put(HelpOption.HELP.name(), HelpOption.HELP);
optionsCompleter = new StringsCompleter(options.keySet());
      completer = NullCompleter.INSTANCE;
    optionalCompleters.put(option.name(), completer);
    if (option.aliases() != null) {
      for (String alias : option.aliases()) {
        optionalCompleters.put(alias, completer);

代码示例来源:origin: org.apache.unomi/shell-dev-commands

@Option(name = "--csv", description = "Output table in CSV format", required = false, multiValued = false)
boolean csv;

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

if (option != null) {
  Completer optionValueCompleter = null;
  String name = option.name();
  if (optionalCompleters != null && name != null) {
    optionValueCompleter = optionalCompleters.get(name);
    if (optionValueCompleter == null) {
      String[] aliases = option.aliases();
      if (aliases.length > 0) {
        for (int i = 0; i < aliases.length && optionValueCompleter == null; i++) {
          optionValueCompleter = optionalCompleters.get(option.aliases()[i]);

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

@Option(name = "-p", aliases = "--pid", description = "The configuration pid", required = false, multiValued = false)
protected String pid;

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

if (option != null) {
  Completer optionValueCompleter = null;
  String name = option.name();
  if (optionalCompleters != null && name != null) {
    optionValueCompleter = optionalCompleters.get(name);
    if (optionValueCompleter == null) {
      String[] aliases = option.aliases();
      if (aliases.length > 0) {
        for (int i = 0; i < aliases.length && optionValueCompleter == null; i++) {
          optionValueCompleter = optionalCompleters.get(option.aliases()[i]);

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

@Command(scope = "jms", name = "create", description = "Create a JMS connection factory.")
public class CreateCommand extends JmsCommandSupport {

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

  @Option(name = "-t", aliases = { "--type" }, description = "The JMS connection factory type (ActiveMQ or WebsphereMQ)", required = false, multiValued = false)
  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 = "-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";
  
  public Object doExecute() throws Exception {
    getJmsService().create(name, type, url, username, password);
    return null;
  }

}

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

@Option(name = "-t", aliases = { "--type" }, description = "The JDBC datasource type (generic, MySQL, Oracle, Postgres, H2, HSQL, Derby, MSSQL)", required = false, multiValued = false)
String type;
@Option(name = "-d", aliases = { "--driver" }, description = "The classname of the JDBC driver to use. NB: this option is used only the type generic", required = false, multiValued = false)
String driver;
@Option(name = "-v", aliases = { "--version" }, description = "The version of the driver to use", required = false, multiValued = false)
String version;
@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 = "-sn", aliases = { "--servername" }, description = "The server name of the database machine, applicable for MSSQL only", required = false, multiValued = false)
String servername;
@Option(name = "-dbn", aliases = { "--databasename" }, description = "The database name, applicable for MSSQL only", required = false, multiValued = false)
String databasename;
@Option(name = "-ptn", aliases = { "--portnumber" }, description = "The portnumber for MS SQL SERVER, applicable for MSSQL only", required = false, multiValued = false)
String portnumber = "1433";
@Option(name = "-i", aliases = { "--install-bundles" }, description = "Try to install the bundles providing the JDBC driver", required = false, multiValued = false)
boolean installBundles = false;

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

@Command(scope = "obr", name = "deploy", description = "Deploys a list of bundles using OBR 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.opendaylight.aaa/aaa-cli

@Option(name = "-keystore",
    aliases = { "--KeyStore" },
    description = "The keystore name.\n-keystore / --default is ctl.jks",
private String keyStoreName = "ctl.jks";
@Option(name = "-storepass",
    aliases = { "--KeyStorePass" },
    description = "The keystore password.\n-storepass",
private String keyStorePassword = "";
@Option(name = "-alias",
    aliases = { "--alias" },
    description = "The alias.\n-alias / --default is controller",
private String alias = "controller";
@Option(name = "-validity",
    aliases = { "--validity" },
    description = "The validity.\n-validity of the keystore certificate / --default is 365",
private int validity = 365;
@Option(name = "-dName",
    aliases = { "--dName" },
    description = "The dName.\n-dName / --should be in the following formate CN=, OU=, O=, L= C=",

代码示例来源:origin: org.opendaylight.aaa/aaa-cli

@Option(name = "-keystore",
    aliases = { "--KeyStore" },
    description = "The keystore name.\n-keystore / --default is truststore.jks",
private String keyStoreName = "truststore.jks";
@Option(name = "-storepass",
    aliases = { "--KeyStorePass" },
    description = "The keystore password.\n-storepass",
private String keyStorePassword = "";
@Option(name = "-alias",
    aliases = { "--alias" },
    description = "The alias.\n-alias / --default is node",

代码示例来源:origin: org.opendaylight.aaa/aaa-cli

@Option(name = "-cert",
    aliases = { "--CertFile" },
    description = "The node certificate file.\n-file / --should be accesable by the karaf command line",
private String certFile = "";
@Option(name = "-storepass",
    aliases = { "--KeyStorePass" },
    description = "The Trust keystore password.\n-storepass",
private String keyStorePassword = "";
@Option(name = "-alias",
    aliases = { "--alias" },
    description = "The alias.\n-alias / node alias should be unique",

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

@Command(scope = "package", name = "imports", description = "Lists imported packages and the bundles that import them")
public class Imports extends OsgiCommandSupport {
  @Option(name = "-p", description = "Only show package instead of full filter", required = false, multiValued = false)
  boolean onlyPackage;
  @Option(name = "--no-format", description = "Disable table rendered output", required = false, multiValued = false)
  boolean noFormat;

代码示例来源:origin: org.onosproject/onos-app-vtn-mgr

/**
 * Supports for updating the external gateway virtualPort.
 */
@Command(scope = "onos", name = "externalportname-set",
    description = "Supports for setting the external port name.")
public class VtnCommand extends AbstractShellCommand {

  @Option(name = "-n", aliases = "--name", description = "external port name.", required = true,
      multiValued = false)
  String exPortName = "";

  @Override
  protected void execute() {
    VtnManager.setExPortName(exPortName);
  }
}

代码示例来源:origin: org.opendaylight.aaa/aaa-cli

protected IAaaCertProvider certProvider;
@Option(name = "-storepass",
    aliases = { "--KeyStorePass" },
    description = "The keystore password.\n-storepass",
private String keyStorePassword = "";
@Option(name = "-alias",
    aliases = { "--alias" },
    description = "The alias.\n-alias / --should be the node certificate alias",

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

@Command(scope = "kar", name = "list", description = "List the installed KAR files.")
public class ListKarCommand extends KarCommandSupport {

  @Option(name = "--no-format", description = "Disable table rendered output", required = false, multiValued = false)
  boolean noFormat;
  
  public Object doExecute() throws Exception {

    ShellTable table = new ShellTable();
    table.column("KAR Name");

    for (String karName : this.getKarService().list()) {
      table.addRow().addContent(karName);
    }

    table.print(System.out, !noFormat);

    return null;
  }
  
}

代码示例来源:origin: org.opendaylight.aaa/aaa-cli

@Option(name = "-cert",
    aliases = { "--CertFile" },
    description = "The ODL certificate file.\n-file / --should be accesable by the karaf command line",
private String certFile = "";
@Option(name = "-storepass",
    aliases = { "--KeyStorePass" },
    description = "The ODL keystore password.\n-storepass",
private String keyStorePassword = "";
@Option(name = "-alias",
    aliases = { "--alias" },
    description = "The alias.\n-alias / ODL alias default is controller as the configuration",

相关文章

Option类方法