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

x33g5p2x  于2022-01-30 转载在 其他  
字(10.9k)|赞(0)|评价(0)|浏览(79)

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

Service.<init>介绍

暂无

代码示例

代码示例来源:origin: OpenNMS/opennms

@Service
public class AliasCompleter implements Completer {

  @Reference
  public SecureCredentialsVault secureCredentialsVault;

  public int complete(Session session, CommandLine commandLine, List<String> candidates) {
    StringsCompleter delegate = new StringsCompleter();
    // Gather the list of known aliases
    delegate.getStrings().addAll(secureCredentialsVault.getAliases());
    return delegate.complete(session, commandLine, candidates);
  }
}

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

@Command(scope = "system", name = "version", description = "Display the instance version")
@Service
public class Version implements Action {

  @Reference
  SystemService systemService;

  @Override
  public Object execute() throws Exception {
    System.out.println(systemService.getVersion());
    return null;
  }

}

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

@Command(scope = "obr", name = "url-add", description = "Adds a list of repository URLs to the OBR service.")
@Service
public class AddUrlCommand extends ObrCommandSupport {

  @Argument(index = 0, name = "urls", description = "Repository URLs to add to the OBR service separated by whitespaces", required = true, multiValued = true)
  List<String> urls;

  protected void doExecute(RepositoryAdmin admin) throws Exception {
    for (String url : urls) {
      admin.addRepository(url);
    }
    persistRepositoryList(admin);
  }
}

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

@Command(scope = "obr", name = "start", description = "Deploys and starts a list of bundles using OBR.")
@Service
public class StartCommand extends ObrCommandSupport {

  @Argument(index = 0, name = "bundles", description = "List of bundles 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 = "-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, true, deployOptional);
  }

}

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

@Command(scope = "obr", name = "start", description = "Deploys and starts a list of bundles using OBR.")
@Service
public class StartCommand extends ObrCommandSupport {

  @Argument(index = 0, name = "bundles", description = "List of bundles 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 = "-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, true, deployOptional);
  }

}

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

@Command(scope = "config", name = "property-delete", description = "Deletes a property from the configuration being edited.")
@Service
public class PropDelCommand extends ConfigPropertyCommandSupport {

  @Argument(index = 0, name = "property", description = "The name of the property to delete", required = true, multiValued = false)
  String prop;

  @Override
  public void propertyAction(TypedProperties props) {
    props.remove(prop);
  }
}

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

@Command(scope = "system", name = "version", description = "Display the instance version")
@Service
public class Version implements Action {

  @Reference
  SystemService systemService;

  @Override
  public Object execute() throws Exception {
    System.out.println(systemService.getVersion());
    return null;
  }

}

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

@Service
public class ProviderTypeNameCompleter implements Completer {

  @Reference
  public RequisitionProviderRegistry registry;

  @Override
  public int complete(Session session, CommandLine commandLine, List<String> candidates) {
    StringsCompleter serviceNames = new StringsCompleter();
    serviceNames.getStrings().addAll(registry.getTypes());
    return serviceNames.complete(session, commandLine, candidates);
  }
}

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

@Command(scope = "jms", name = "consume", description = "Consume messages from a JMS queue.")
@Service
public class ConsumeCommand extends JmsConnectionCommandSupport {

  @Argument(index = 1, name = "queue", description = "The JMS queue where to consume messages", required = true, multiValued = false)
  String queue;

  @Option(name = "-s", aliases = { "--selector" }, description = "The selector to use to select the messages to consume", required = false, multiValued = false)
  String selector;

  @Override
  public Object execute() throws Exception {
    System.out.println(getJmsService().consume(connectionFactory, queue, selector, username, password) + " message(s) consumed");
    return null;
  }

}

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

@Command(scope = "config", name = "property-delete", description = "Deletes a property from the configuration being edited.")
@Service
public class PropDelCommand extends ConfigPropertyCommandSupport {

  @Argument(index = 0, name = "property", description = "The name of the property to delete", required = true, multiValued = false)
  String prop;

  @Override
  public void propertyAction(TypedProperties props) {
    props.remove(prop);
  }
}

代码示例来源:origin: OpenNMS/opennms

@Command(scope = "topo", name = "delete-history", description="Deletes history of all users.")
@Service
public class DeleteHistoryCommand implements Action {

  @Reference
  public HistoryManager historyManager;

  @Override
  public Object execute() throws Exception {
    historyManager.deleteHistory();
    return null;
  }
}

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

@Service
public class CollectorClassNameCompleter implements Completer {

  @Reference
  public ServiceCollectorRegistry registry;

  @Override
  public int complete(Session session, CommandLine commandLine, List<String> candidates) {
    StringsCompleter serviceNames = new StringsCompleter();
    serviceNames.getStrings().addAll(registry.getCollectorClassNames());
    return serviceNames.complete(session, commandLine, candidates);
  }

}

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

@Command(scope = "obr", name = "url-add", description = "Adds a list of repository URLs to the OBR service.")
@Service
public class AddUrlCommand extends ObrCommandSupport {

  @Argument(index = 0, name = "urls", description = "Repository URLs to add to the OBR service separated by whitespaces", required = true, multiValued = true)
  List<String> urls;

  protected void doExecute(RepositoryAdmin admin) throws Exception {
    for (String url : urls) {
      admin.addRepository(url);
    }
    persistRepositoryList(admin);
  }
}

代码示例来源:origin: OpenNMS/opennms

@Command(scope = "collection", name = "list-collectors", description = "Lists all of the available collectors.")
@Service
public class ListCollectors implements Action {

  @Reference
  ServiceCollectorRegistry registry;

  @Override
  public Object execute() throws Exception {
    registry.getCollectorClassNames().stream().sorted().forEachOrdered(e -> {
      System.out.printf("%s\n", e);
    });
    return null;
  }

}

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

@Service
public class MonitorClassNameCompleter implements Completer {

  @Reference
  public ServiceMonitorRegistry registry;

  @Override
  public int complete(Session session, CommandLine commandLine, List<String> candidates) {
    StringsCompleter serviceNames = new StringsCompleter();
    serviceNames.getStrings().addAll(registry.getMonitorClassNames());
    return serviceNames.complete(session, commandLine, candidates);
  }
}

相关文章

微信公众号

最新文章

更多

Service类方法