Exemplo n.º 1
0
  @Override
  protected void doExecute(ApplicationService applicationService)
      throws ApplicationServiceException {

    Set<Application> applications = applicationService.getApplications();
    console.printf("%s%10s%n", "State", "Name");
    for (Application curApp : applications) {
      ApplicationStatus appStatus = applicationService.getApplicationStatus(curApp);
      // only show applications that have features (gets rid of repo
      // aggregator 'apps')
      if (!curApp.getFeatures().isEmpty()) {
        console.print("[");
        switch (appStatus.getState()) {
          case ACTIVE:
            console.print(Ansi.ansi().fg(Ansi.Color.GREEN).toString());
            break;
          case FAILED:
            console.print(Ansi.ansi().fg(Ansi.Color.RED).toString());
            break;
          case INACTIVE:
            // don't set a color
            break;
          case UNKNOWN:
            console.print(Ansi.ansi().fg(Ansi.Color.YELLOW).toString());
            break;
          default:
            break;
        }
        console.print(StringUtils.rightPad(appStatus.getState().toString(), STATUS_COLUMN_LENGTH));
        console.print(Ansi.ansi().reset().toString());
        console.println("] " + curApp.getName());
      }
    }
    return;
  }
Exemplo n.º 2
0
 public void waitForRequiredApps(String... appNames) throws InterruptedException {
   ApplicationService appService = getApplicationService();
   if (appNames.length > 0) {
     for (String appName : appNames) {
       try {
         Application app = appService.getApplication(appName);
         if (app != null) {
           ApplicationStatus status = appService.getApplicationStatus(app);
           if (ACTIVE != status.getState()) {
             appService.startApplication(appName);
           }
         } else {
           throw new ApplicationServiceException(
               "Unable to determine Application for [" + appName + "].");
         }
       } catch (ApplicationServiceException e) {
         fail("Failed to start boot feature: " + e.getMessage());
       }
       waitForAllBundles();
     }
   }
 }