org.apache.karaf.shell.api.action.Option.<init>()方法的使用及代码示例

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

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

Option.<init>介绍

暂无

代码示例

代码示例来源: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

@Command(scope = "bundle", name = "stop", description = "Stop bundles.")
@Service
public class Stop extends BundlesCommand {
  
  @Option(name = "-t", aliases={"--transient"}, description="Keep the bundle as auto-start", required = false, multiValued = false)
  boolean transientStop;
  
  public Stop() {
    defaultAllBundles = false;
    errorMessage = "Error stopping bundle";
  }

  @Override
  protected void executeOnBundle(Bundle bundle) throws Exception {
    bundle.stop(transientStop ? Bundle.STOP_TRANSIENT : 0);
  }

}

代码示例来源: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: org.apache.karaf.bundle/org.apache.karaf.bundle.core

@Command(scope = "bundle", name = "stop", description = "Stop bundles.")
@Service
public class Stop extends BundlesCommand {
  
  @Option(name = "-t", aliases={"--transient"}, description="Keep the bundle as auto-start", required = false, multiValued = false)
  boolean transientStop;
  
  public Stop() {
    defaultAllBundles = false;
    errorMessage = "Error stopping bundle";
  }

  @Override
  protected void executeOnBundle(Bundle bundle) throws Exception {
    bundle.stop(transientStop ? Bundle.STOP_TRANSIENT : 0);
  }

}

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

@Command(scope = "bundle", name = "start", description = "Starts bundles.")
@Service
public class Start extends BundlesCommand {

  @Option(name = "-t", aliases={"--transient"}, description="Keep the bundle as auto-start", required = false, multiValued = false)
  boolean transientStart;

  public Start() {
    defaultAllBundles = false;
    errorMessage = "Error starting bundle ";
  }

  @Override
  protected void executeOnBundle(Bundle bundle) throws Exception {
    bundle.start(transientStart ? Bundle.START_TRANSIENT : 0);
  }

}

代码示例来源:origin: org.apache.karaf.bundle/org.apache.karaf.bundle.core

@Command(scope = "bundle", name = "start", description = "Starts bundles.")
@Service
public class Start extends BundlesCommand {

  @Option(name = "-t", aliases={"--transient"}, description="Keep the bundle as auto-start", required = false, multiValued = false)
  boolean transientStart;

  public Start() {
    defaultAllBundles = false;
    errorMessage = "Error starting bundle ";
  }

  @Override
  protected void executeOnBundle(Bundle bundle) throws Exception {
    bundle.start(transientStart ? Bundle.START_TRANSIENT : 0);
  }

}

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

@Command(scope = "jdbc", name = "ds-create", description = "Create a JDBC datasource config for pax-jdbc-config from a DataSourceFactory")
@Service
public class CreateCommand extends JdbcCommandSupport {
  @Argument(index = 0, name = "name", description = "The JDBC datasource name", required = true, multiValued = false)
  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 = "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

@Service
@Command(scope = "booking", name = "list", description = "List booking")
public class ListBookingCommand implements Action {

  @Option(name = "--url", description = "Location of the REST service", required = false, multiValued = false)
  String restLocation = "http://localhost:8181/cxf/booking/";

  @Override
  public Object execute() throws Exception {
    List providers = new ArrayList();
    providers.add(new JacksonJsonProvider());
    WebClient webClient = WebClient.create(restLocation, providers);

    List<Booking> bookings = (List<Booking>) webClient.accept(MediaType.APPLICATION_JSON).getCollection(Booking.class);
    for (Booking booking : bookings) {
      System.out.println(booking.getId() + " " + booking.getCustomer() + " " + booking.getFlight());
    }

    return null;
  }

}

代码示例来源: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: apache/karaf-cellar

@Command(scope = "cluster", name = "shutdown", description = "Shutdown the cluster removing the Cellar feature on all node")
@Service
public class ShutdownCommand extends ClusterCommandSupport {

  @Option(name = "-p", aliases = {"--poweroff"}, description = "Completely stop the nodes", required = false, multiValued = false)
  boolean halt;

  @Override
  protected Object doExecute() throws Exception {
    org.apache.karaf.cellar.core.control.ShutdownCommand command = new org.apache.karaf.cellar.core.control.ShutdownCommand(clusterManager.generateId());
    Set<Node> recipientList = clusterManager.listNodes();
    command.setDestination(recipientList);
    command.setHalt(halt);
    System.out.println("!! Cluster shutdown !!");
    executionContext.execute(command);
    return null;
  }

}

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

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

@Command(scope = "docker", name = "pull", description = "Pull an image")
@Service
public class PullCommand extends DockerCommandSupport {

  @Argument(index = 0, name = "image", description = "The Docker image to pull", multiValued = false, required = true)
  String image;

  @Option(name = "-t", aliases = "--tag", description = "Tag to use", multiValued = false, required = false)
  String tag = "latest";

  @Option(name = "-v", aliases = "--verbose", description = "Display pulling progress on console", multiValued = false, required = false)
  boolean verbose;

  @Override
  public Object execute() throws Exception {
    getDockerService().pull(image, tag, verbose, url);
    return null;
  }

}

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

@Command(scope = "obr", name = "url-list", description = "Displays the repository URLs currently associated with the OBR service.")
@Service
public class ListUrlCommand extends ObrCommandSupport {

  @Option(name = "--no-format", description = "Disable table rendered output", required = false, multiValued = false)
  boolean noFormat;

  protected void doExecute(RepositoryAdmin admin) {

    ShellTable table = new ShellTable();
    table.column("Index");
    table.column("OBR URL");
    table.emptyTableText("No OBR repository URL");

    Repository[] repos = admin.listRepositories();
    if (repos != null) {
      for (int i = 0; i < repos.length; i++) {
        table.addRow().addContent(i, repos[i].getURI());
      }
    }

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

}

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

@Command(scope = "obr", name = "url-list", description = "Displays the repository URLs currently associated with the OBR service.")
@Service
public class ListUrlCommand extends ObrCommandSupport {

  @Option(name = "--no-format", description = "Disable table rendered output", required = false, multiValued = false)
  boolean noFormat;

  protected void doExecute(RepositoryAdmin admin) {

    ShellTable table = new ShellTable();
    table.column("Index");
    table.column("OBR URL");
    table.emptyTableText("No OBR repository URL");

    Repository[] repos = admin.listRepositories();
    if (repos != null) {
      for (int i = 0; i < repos.length; i++) {
        table.addRow().addContent(i, repos[i].getURI());
      }
    }

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

}

代码示例来源:origin: de.mhus.lib/mhu-lib-karaf

@Command(scope = "jms", name = "connection-beat", description = "Beat the connection, load connections and channels")
@Service
public class CmdConnectionBeat implements Action {

  @Option(name="-c",aliases="--channels",description="Beat also all channels",required=false)
  boolean channels = false;
  
  @Override
  public Object execute() throws Exception {

    JmsManagerService service = JmsUtil.getService();
    if (service == null) {
      System.out.println("Service not found");
      return null;
    }

    service.doBeat();
    if (channels)
      service.doChannelBeat();
    System.out.println("OK");

    return null;
  }

}

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

/**
 * @author Lijun Liao
 * @since 2.0.0
 */

@Command(scope = "ca", name = "user-rm",
    description = "remove user")
@Service
public class UserRemoveCmd extends CaCommandSupport {

  @Option(name = "--name", aliases = "-n",
      required = true,
      description = "user Name\n"
          + "(required)")
  private String name;

  @Override
  protected Object execute0() throws Exception {
    boolean bo = caManager.removeUser(name);
    output(bo, "removed", "could not remove", "user " + name);
    return null;
  }

}

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

@Command(scope = "ca", name = "rm-cert", description = "remove certificate")
@Service
public static class RmCert extends UnRevRmCertAction {
 @Option(name = "--force", aliases = "-f", description = "without prompt")
 private Boolean force = Boolean.FALSE;
 @Override
 protected Object execute0() throws Exception {
  BigInteger serialNo = getSerialNumber();
  String msg = "certificate (serial number = 0x" + serialNo.toString(16) + ")";
  if (force || confirm("Do you want to remove " + msg, 3)) {
   try {
    caManager.removeCertificate(caName, serialNo);
    println("removed " + msg);
   } catch (CaMgmtException ex) {
    throw new CmdFailure("could not remove " + msg + ", error: " + ex.getMessage(), ex);
   }
  }
  return null;
 }
}

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

@Service
@Command(scope = "booking", name = "list", description = "List bookings")
public class ListCommand implements Action {

  @Option(name = "--url", description = "Location of the SOAP service", required = false, multiValued = false)
  String url = "http://localhost:8181/cxf/example";

  @Override
  public Object execute() throws Exception {
    CxfClient client = new CxfClient(url);
    ShellTable table = new ShellTable();
    table.column("ID");
    table.column("Customer");
    table.column("Flight");
    if (client.list() != null) {
      for (Booking booking : client.list()) {
        table.addRow().addContent(booking.getId(), booking.getCustomer(), booking.getFlight());
      }
    }
    table.print(System.out);
    return null;
  }

}

相关文章