コード例 #1
0
ファイル: StatusGenerator.java プロジェクト: phan-pivotal/OSS
 public void listOfCommands() {
   CommandRunner cr = habitat.getComponent(CommandRunner.class);
   RestActionReporter ar = new RestActionReporter();
   ParameterMap parameters = new ParameterMap();
   cr.getCommandInvocation("list-commands", ar).parameters(parameters).execute();
   List<ActionReport.MessagePart> children = ar.getTopMessagePart().getChildren();
   for (ActionReport.MessagePart part : children) {
     allCommands.add(part.getMessage());
   }
   ar = new RestActionReporter();
   parameters = new ParameterMap();
   parameters.add("DEFAULT", "_");
   cr.getCommandInvocation("list-commands", ar).parameters(parameters).execute();
   children = ar.getTopMessagePart().getChildren();
   for (ActionReport.MessagePart part : children) {
     allCommands.add(part.getMessage());
   }
 }
コード例 #2
0
  /**
   * Executes the command with the command parameters passed as Properties where the keys are the
   * parameter names and the values the parameter values
   *
   * @param context information
   */
  public void execute(AdminCommandContext context) {

    final ActionReport report = context.getActionReport();

    try {
      Collection<ManagedExecutorService> managedExecutorServices =
          domain.getResources().getResources(ManagedExecutorService.class);
      List<Map<String, String>> resourcesList = new ArrayList<Map<String, String>>();
      List<DefaultResourceProxy> drps = habitat.getAllServices(DefaultResourceProxy.class);

      for (ManagedExecutorService managedExecutorService : managedExecutorServices) {
        String jndiName = managedExecutorService.getJndiName();
        if (bindableResourcesHelper.resourceExists(jndiName, target)) {
          ActionReport.MessagePart part = report.getTopMessagePart().addChild();
          part.setMessage(jndiName);
          Map<String, String> resourceNameMap = new HashMap<String, String>();
          String logicalName = DefaultResourceProxy.Util.getLogicalName(drps, jndiName);
          if (logicalName != null) {
            resourceNameMap.put("logical-jndi-name", logicalName);
          }
          resourceNameMap.put("name", jndiName);
          resourcesList.add(resourceNameMap);
        }
      }

      Properties extraProperties = new Properties();
      extraProperties.put("managedExecutorServices", resourcesList);
      report.setExtraProperties(extraProperties);
    } catch (Exception e) {
      report.setMessage(
          localStrings.getLocalString(
              "list.managed.executor.service.failed", "List managed executor services failed"));
      report.setActionExitCode(ActionReport.ExitCode.FAILURE);
      report.setFailureCause(e);
      return;
    }
    report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
  }