Пример #1
0
  private void printServices(Bundle bundle, ServiceReference<?>[] refs, boolean showProperties) {
    boolean headerPrinted = false;
    boolean needSeparator = false;

    if (refs == null) {
      return;
    }

    for (ServiceReference<?> serviceRef : refs) {
      String[] objectClass = (String[]) serviceRef.getProperty(Constants.OBJECTCLASS);

      boolean print = showAll || !isCommand(objectClass);

      // Print header if we have not already done so.
      if (!headerPrinted) {
        headerPrinted = true;
        System.out.println("");
        String title = ShellUtil.getBundleName(bundle) + ((inUse) ? " uses:" : " provides:");
        System.out.println(title);
        System.out.println(ShellUtil.getUnderlineString(title));
      }

      if (print) {
        // Print service separator if necessary.
        if (needSeparator && showProperties) {
          System.out.println("----");
        }

        if (showProperties) {
          printProperties(serviceRef);
        } else {
          System.out.println(ShellUtil.getValueString(objectClass));
        }

        needSeparator = true;
      }
    }
  }
Пример #2
0
 private void printProperties(ServiceReference<?> serviceRef) {
   for (String key : serviceRef.getPropertyKeys()) {
     System.out.println(key + " = " + ShellUtil.getValueString(serviceRef.getProperty(key)));
   }
 }