Beispiel #1
0
 @SuppressWarnings("deprecation")
 public static String getState(Component component) {
   switch (component.getState()) {
     case Component.STATE_DISABLED:
       return "disabled";
     case Component.STATE_ENABLING:
       return "enabling";
     case Component.STATE_ENABLED:
       return "enabled";
     case Component.STATE_UNSATISFIED:
       return "unsatisfied";
     case Component.STATE_ACTIVATING:
       return "activating";
     case Component.STATE_ACTIVE:
       return "active";
     case Component.STATE_REGISTERED:
       return "registered";
     case Component.STATE_FACTORY:
       return "factory";
     case Component.STATE_DEACTIVATING:
       return "deactivating";
     case Component.STATE_DISABLING:
       return "disabling";
     case Component.STATE_DISPOSING:
       return "disposing";
     case Component.STATE_DISPOSED:
       return "disposed";
     default:
       return "" + component.getState();
   }
 }
Beispiel #2
0
  @Override
  protected Object doScrAction(ScrService scrService) throws Exception {
    ShellTable table = new ShellTable();
    table.column("ID");
    table.column("State");
    table.column("Component Name");

    Component[] components = scrService.getComponents();
    Arrays.sort(components, idComparator);
    for (Component component : ScrUtils.emptyIfNull(Component.class, components)) {
      if (showHidden) {
        // we display all because we are overridden
        table
            .addRow()
            .addContent(
                component.getId(), ScrUtils.getState(component.getState()), component.getName());
      } else {
        if (ScrActionSupport.isHiddenComponent(component)) {
          // do nothing
        } else {
          // we aren't hidden so print it
          table
              .addRow()
              .addContent(
                  component.getId(), ScrUtils.getState(component.getState()), component.getName());
        }
      }
    }
    table.print(System.out);

    return null;
  }
  private static final void component(PrintWriter pw, Component component) {

    pw.print(component.getId());
    pw.print("=[");
    pw.print(component.getName());
    pw.println("]");

    pw.println(
        "  Bundle"
            + component.getBundle().getSymbolicName()
            + " ("
            + component.getBundle().getBundleId()
            + ")");
    pw.println("  State=" + toStateString(component.getState()));
    pw.println("  DefaultState=" + (component.isDefaultEnabled() ? "enabled" : "disabled"));
    pw.println("  Activation=" + (component.isImmediate() ? "immediate" : "delayed"));

    listServices(pw, component);
    listReferences(pw, component);
    listProperties(pw, component);

    pw.println();
  }