Ejemplo n.º 1
1
  /**
   * Given a master list and the new sub list, replace the items in the master list with the
   * matching items from the new sub list. This process works even if the length of the new sublist
   * is different.
   *
   * <p>For example, givn:
   *
   * <pre>
   * replace A by A':
   *   M=[A,B,C], S=[A'] => [A',B,C]
   *   M=[A,B,A,B,C], S=[A',A'] => [A',B,A',B,C]
   *
   * when list length is different:
   *   M=[A,A,B,C], S=[] => [B,C]
   *   M=[A,B,C], S=[A',A'] => [A',A',B,C]
   *   M=[B,C], S=[A',A'] => [B,C,A',A']
   * </pre>
   */
  private static List<Child> stitchList(
      List<Child> list, String name, List<? extends Child> newSubList) {
    List<Child> removed = new LinkedList<Child>();
    // to preserve order, try to put new itesm where old items are found.
    // if the new list is longer than the current list, we put all the extra
    // after the last item in the sequence. That is,
    // given [A,A,B,C] and [A',A',A'], we'll update the list to [A',A',A',B,C]
    // The 'last' variable remembers the insertion position.
    int last = list.size();

    ListIterator<Child> itr = list.listIterator();
    ListIterator<? extends Child> jtr = newSubList.listIterator();
    while (itr.hasNext()) {
      Child child = itr.next();
      if (child.name.equals(name)) {
        if (jtr.hasNext()) {
          itr.set(jtr.next()); // replace
          last = itr.nextIndex();
          removed.add(child);
        } else {
          itr.remove(); // remove
          removed.add(child);
        }
      }
    }

    // new list is longer than the current one
    if (jtr.hasNext()) list.addAll(last, newSubList.subList(jtr.nextIndex(), newSubList.size()));

    return removed;
  }
Ejemplo n.º 2
1
 private CIJobStatus deleteCI(CIJob job, List<String> builds) throws PhrescoException {
   S_LOGGER.debug("Entering Method CIManagerImpl.deleteCI(CIJob job)");
   S_LOGGER.debug("Job name " + job.getName());
   cli = getCLI(job);
   String deleteType = null;
   List<String> argList = new ArrayList<String>();
   S_LOGGER.debug("job name " + job.getName());
   S_LOGGER.debug("Builds " + builds);
   if (CollectionUtils.isEmpty(builds)) { // delete job
     S_LOGGER.debug("Job deletion started");
     S_LOGGER.debug("Command " + FrameworkConstants.CI_JOB_DELETE_COMMAND);
     deleteType = DELETE_TYPE_JOB;
     argList.add(FrameworkConstants.CI_JOB_DELETE_COMMAND);
     argList.add(job.getName());
   } else { // delete Build
     S_LOGGER.debug("Build deletion started");
     deleteType = DELETE_TYPE_BUILD;
     argList.add(FrameworkConstants.CI_BUILD_DELETE_COMMAND);
     argList.add(job.getName());
     StringBuilder result = new StringBuilder();
     for (String string : builds) {
       result.append(string);
       result.append(",");
     }
     String buildNos = result.substring(0, result.length() - 1);
     argList.add(buildNos);
     S_LOGGER.debug("Command " + FrameworkConstants.CI_BUILD_DELETE_COMMAND);
     S_LOGGER.debug("Build numbers " + buildNos);
   }
   try {
     int status = cli.execute(argList);
     String message = deleteType + " deletion started in jenkins";
     if (status == FrameworkConstants.JOB_STATUS_NOTOK) {
       deleteType = deleteType.substring(0, 1).toLowerCase() + deleteType.substring(1);
       message = "Error while deleting " + deleteType + " in jenkins";
     }
     S_LOGGER.debug("Delete CI Status " + status);
     S_LOGGER.debug("Delete CI Message " + message);
     return new CIJobStatus(status, message);
   } finally {
     if (cli != null) {
       try {
         cli.close();
       } catch (IOException e) {
         if (debugEnabled) {
           S_LOGGER.error(
               "Entered into catch block of CIManagerImpl.deleteCI(CIJob job) "
                   + e.getLocalizedMessage());
         }
       } catch (InterruptedException e) {
         if (debugEnabled) {
           S_LOGGER.error(
               "Entered into catch block of CIManagerImpl.deleteCI(CIJob job) "
                   + e.getLocalizedMessage());
         }
       }
     }
   }
 }
Ejemplo n.º 3
0
    public ProxiedMethod(Method method) {
      this.method = method;
      this.name = // method instanceof Constructor ? "<init>" :
          method.getName();
      this.owner = method.getDeclaringClass();

      StringBuffer jni_sig = new StringBuffer("("), c_sig = new StringBuffer();

      retCapitalized = jni_capitalized(method.getReturnType());
      String[] sigArg = c_signature(method.getReturnType(), "?");
      c_sig.append(retType = sigArg[0]).append(" ").append(name).append("(");
      int i = 0;
      for (Class c : method.getParameterTypes()) {
        jni_sig.append(jni_signature(c));
        if (i > 0) c_sig.append(", ");

        String argName = "arg" + (i + 1);
        sigArg = c_signature(c, argName);
        String argType = sigArg[0];

        argTypes.add(argType);
        argNames.add(argName);
        argValues.add(sigArg[1]);

        c_sig.append(argType).append(" ").append(argName);
        i++;
      }
      c_sig.append(")");
      jni_sig.append(")").append(jni_signature(method.getReturnType()));
      this.jni_signature = jni_sig.toString();
      this.c_signature = c_sig.toString();
    }
Ejemplo n.º 4
0
  public void init() {
    setLayout(new BorderLayout());

    single.add("0");
    single.add("1");
    single.add("2");
    single.add("3");
    single.add("4");
    single.add("5");
    single.add("6");
    single.add("7");
    single.add("8");

    multiple.add("0");
    multiple.add("1");
    multiple.add("2");
    multiple.add("3");
    multiple.add("4");
    multiple.add("5");
    multiple.add("6");
    multiple.add("7");
    multiple.add("8");

    single.addKeyListener(this);
    single.addItemListener(this);
    single.addFocusListener(this);
    p1.add(single);
    add("North", p1);

    multiple.addKeyListener(this);
    multiple.addItemListener(this);
    multiple.addFocusListener(this);
    p2.add(multiple);
    add("South", p2);
  } // End  init()
Ejemplo n.º 5
0
  private CIJobStatus buildJob(CIJob job) throws PhrescoException {
    if (debugEnabled) {
      S_LOGGER.debug("Entering Method CIManagerImpl.buildJob(CIJob job)");
    }
    cli = getCLI(job);

    List<String> argList = new ArrayList<String>();
    argList.add(FrameworkConstants.CI_BUILD_JOB_COMMAND);
    argList.add(job.getName());
    try {
      int status = cli.execute(argList);
      String message = FrameworkConstants.CI_BUILD_STARTED;
      if (status == FrameworkConstants.JOB_STATUS_NOTOK) {
        message = FrameworkConstants.CI_BUILD_STARTING_ERROR;
      }
      return new CIJobStatus(status, message);
    } finally {
      if (cli != null) {
        try {
          cli.close();
        } catch (IOException e) {
          if (debugEnabled) {
            S_LOGGER.error(e.getLocalizedMessage());
          }
        } catch (InterruptedException e) {
          if (debugEnabled) {
            S_LOGGER.error(e.getLocalizedMessage());
          }
        }
      }
    }
  }
Ejemplo n.º 6
0
  public List<InferredType> materializeWithoutUnions() {
    List<InferredType> newStructs = new ArrayList<InferredType>();

    for (int i = 0; i < structTypes.size(); i++) {
      List<InferredType> curTrees = structTypes.get(i).materializeWithoutUnions();

      if (i == 0) {
        for (int j = 0; j < curTrees.size(); j++) {
          List<InferredType> curTypeList = new ArrayList<InferredType>();
          curTypeList.add(curTrees.get(j));
          newStructs.add(new StructType(curTypeList));
        }
      } else {
        List<InferredType> evenNewerStructs = new ArrayList<InferredType>();
        evenNewerStructs.addAll(newStructs);
        for (int j = 1; j < curTrees.size(); j++) {
          for (int k = 0; k < newStructs.size(); k++) {
            evenNewerStructs.add(newStructs.get(k).duplicate());
          }
        }
        for (int j = 0; j < curTrees.size(); j++) {
          for (int k = 0; k < evenNewerStructs.size(); k++) {
            ((StructType) evenNewerStructs.get(k)).addElt(curTrees.get(j));
          }
        }
        newStructs = evenNewerStructs;
      }
    }
    return newStructs;
  }
Ejemplo n.º 7
0
 /**
  * Turn the shas into a readable form
  *
  * @param dependencies
  * @return
  * @throws Exception
  */
 public List<?> toString(List<byte[]> dependencies) throws Exception {
   List<String> out = new ArrayList<String>();
   for (byte[] dependency : dependencies) {
     ArtifactData data = get(dependency);
     if (data == null) out.add(Hex.toHexString(dependency));
     else {
       out.add(Strings.display(data.name, Hex.toHexString(dependency)));
     }
   }
   return out;
 }
Ejemplo n.º 8
0
 public InferredType hoistUnions() {
   List<InferredType> newUnionTypes = new ArrayList<InferredType>();
   for (InferredType it : unionTypes) {
     if (it instanceof UnionType) {
       UnionType subUnion = (UnionType) it;
       for (InferredType it2 : subUnion.unionTypes) {
         newUnionTypes.add(it2.hoistUnions());
       }
     } else {
       newUnionTypes.add(it.hoistUnions());
     }
   }
   return new UnionType(newUnionTypes);
 }
  private static void checkGarbageCollectionNotificationInfoContent(
      GarbageCollectionNotificationInfo notif) throws Exception {
    System.out.println("GC notification for " + notif.getGcName());
    System.out.print("Action: " + notif.getGcAction());
    System.out.println(" Cause: " + notif.getGcCause());
    GcInfo info = notif.getGcInfo();
    System.out.print("GC Info #" + info.getId());
    System.out.print(" start:" + info.getStartTime());
    System.out.print(" end:" + info.getEndTime());
    System.out.println(" (" + info.getDuration() + "ms)");
    Map<String, MemoryUsage> usage = info.getMemoryUsageBeforeGc();

    List<String> pnames = new ArrayList<String>();
    for (Map.Entry entry : usage.entrySet()) {
      String poolname = (String) entry.getKey();
      pnames.add(poolname);
      MemoryUsage busage = (MemoryUsage) entry.getValue();
      MemoryUsage ausage = (MemoryUsage) info.getMemoryUsageAfterGc().get(poolname);
      if (ausage == null) {
        throw new RuntimeException("After Gc Memory does not exist" + " for " + poolname);
      }
      System.out.println("Usage for pool " + poolname);
      System.out.println("   Before GC: " + busage);
      System.out.println("   After GC: " + ausage);
    }

    // check if memory usage for all memory pools are returned
    List<MemoryPoolMXBean> pools = ManagementFactory.getMemoryPoolMXBeans();
    for (MemoryPoolMXBean p : pools) {
      if (!pnames.contains(p.getName())) {
        throw new RuntimeException(
            "GcInfo does not contain " + "memory usage for pool " + p.getName());
      }
    }
  }
Ejemplo n.º 10
0
  /**
   * Inserts a new {@link Dom} node right after the given DOM element.
   *
   * @param reference If null, the new element will be inserted at the very beginning.
   * @param name The element name of the newly inserted item. "*" to indicate that the element name
   *     be determined by the model of the new node.
   */
  public synchronized void insertAfter(Dom reference, String name, Dom newNode) {
    // TODO: reparent newNode
    if (name.equals("*")) name = newNode.model.tagName;
    NodeChild newChild = new NodeChild(name, newNode);

    if (children.size() == 0) {
      children = new ArrayList<Child>();
    }
    if (reference == null) {
      children.add(0, newChild);
      newNode.domDescriptor =
          addWithAlias(getHabitat(), newNode, newNode.getProxyType(), newNode.getKey());
      return;
    }

    ListIterator<Child> itr = children.listIterator();
    while (itr.hasNext()) {
      Child child = itr.next();
      if (child instanceof NodeChild) {
        NodeChild nc = (NodeChild) child;
        if (nc.dom == reference) {
          itr.add(newChild);
          newNode.domDescriptor =
              addWithAlias(getHabitat(), newNode, newNode.getProxyType(), newNode.getKey());

          return;
        }
      }
    }
    throw new IllegalArgumentException(
        reference + " is not a valid child of " + this + ". Children=" + children);
  }
Ejemplo n.º 11
0
 public boolean testGetAdd2() {
   description = "after adding an object at index 2 can get it there";
   precondition = new Boolean(li.size() >= 3);
   Object e = new Object();
   li.add(2, e);
   return li.get(2) == e;
 }
Ejemplo n.º 12
0
  public synchronized Collection<GarbageCollectorMXBean> getGarbageCollectorMXBeans()
      throws IOException {

    // TODO: How to deal with changes to the list??
    if (garbageCollectorMBeans == null) {
      ObjectName gcName = null;
      try {
        gcName = new ObjectName(GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE + ",*");
      } catch (MalformedObjectNameException e) {
        // should not reach here
        assert (false);
      }
      Set<ObjectName> mbeans = server.queryNames(gcName, null);
      if (mbeans != null) {
        garbageCollectorMBeans = new ArrayList<GarbageCollectorMXBean>();
        Iterator<ObjectName> iterator = mbeans.iterator();
        while (iterator.hasNext()) {
          ObjectName on = (ObjectName) iterator.next();
          String name = GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE + ",name=" + on.getKeyProperty("name");

          GarbageCollectorMXBean mBean =
              newPlatformMXBeanProxy(server, name, GarbageCollectorMXBean.class);
          garbageCollectorMBeans.add(mBean);
        }
      }
    }
    return garbageCollectorMBeans;
  }
Ejemplo n.º 13
0
 InferredType duplicate() {
   List<InferredType> newBranches = new ArrayList<InferredType>();
   for (InferredType branch : unionTypes) {
     newBranches.add(branch.duplicate());
   }
   return new UnionType(newBranches);
 }
Ejemplo n.º 14
0
 public List<InferredType> materializeWithoutUnions() {
   List<InferredType> newArrays = new ArrayList<InferredType>();
   for (InferredType subtype : bodyType.materializeWithoutUnions()) {
     newArrays.add(new ArrayType(subtype));
   }
   return newArrays;
 }
Ejemplo n.º 15
0
 InferredType duplicate() {
   List<InferredType> newElts = new ArrayList<InferredType>();
   for (InferredType elt : structTypes) {
     newElts.add(elt.duplicate());
   }
   return new StructType(newElts);
 }
Ejemplo n.º 16
0
 public InferredType hoistUnions() {
   List<InferredType> newStructTypes = new ArrayList<InferredType>();
   for (InferredType it : structTypes) {
     newStructTypes.add(it.hoistUnions());
   }
   return new StructType(newStructTypes);
 }
  public ListIterator<ICFLibAnyObj> enumerateDetails(MssCFGenContext genContext) {
    final String S_ProcName = "CFInternetMssCFIterateTSecGroupIncByGroup.enumerateDetails() ";

    if (genContext == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), S_ProcName, 1, "genContext");
    }

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), S_ProcName, 1, "genContext.getGenDef()");
    }

    List<ICFLibAnyObj> list = new LinkedList<ICFLibAnyObj>();

    if (genDef instanceof ICFInternetTSecGroupObj) {
      Iterator<ICFSecurityTSecGroupIncludeObj> elements =
          ((ICFInternetTSecGroupObj) genDef).getRequiredChildrenIncByGroup().iterator();
      while (elements.hasNext()) {
        list.add(elements.next());
      }
    } else {
      throw CFLib.getDefaultExceptionFactory()
          .newUnsupportedClassException(
              getClass(), S_ProcName, "genContext.getGenDef()", genDef, "ICFInternetTSecGroupObj");
    }

    return (list.listIterator());
  }
Ejemplo n.º 18
0
 public List<CIBuild> getBuilds(CIJob job) throws PhrescoException {
   if (debugEnabled) {
     S_LOGGER.debug("Entering Method CIManagerImpl.getCIBuilds(CIJob job)");
   }
   List<CIBuild> ciBuilds = null;
   try {
     if (debugEnabled) {
       S_LOGGER.debug("getCIBuilds()  JobName = " + job.getName());
     }
     JsonArray jsonArray = getBuildsArray(job);
     ciBuilds = new ArrayList<CIBuild>(jsonArray.size());
     Gson gson = new Gson();
     CIBuild ciBuild = null;
     for (int i = 0; i < jsonArray.size(); i++) {
       ciBuild = gson.fromJson(jsonArray.get(i), CIBuild.class);
       setBuildStatus(ciBuild, job);
       String buildUrl = ciBuild.getUrl();
       String jenkinUrl = job.getJenkinsUrl() + ":" + job.getJenkinsPort();
       buildUrl =
           buildUrl.replaceAll(
               "localhost:" + job.getJenkinsPort(),
               jenkinUrl); // when displaying url it should display setup machine ip
       ciBuild.setUrl(buildUrl);
       ciBuilds.add(ciBuild);
     }
   } catch (Exception e) {
     if (debugEnabled) {
       S_LOGGER.debug(
           "Entering Method CIManagerImpl.getCIBuilds(CIJob job) " + e.getLocalizedMessage());
     }
   }
   return ciBuilds;
 }
Ejemplo n.º 19
0
  private Field[] getAccessibleFields() {
    if (includePrivate) {
      try {
        List<Field> fieldsList = new ArrayList<Field>();
        Class<?> currentClass = cl;

        while (currentClass != null) {
          // get all declared fields in this class, make them
          // accessible, and save
          Field[] declared = currentClass.getDeclaredFields();
          for (int i = 0; i < declared.length; i++) {
            declared[i].setAccessible(true);
            fieldsList.add(declared[i]);
          }
          // walk up superclass chain.  no need to deal specially with
          // interfaces, since they can't have fields
          currentClass = currentClass.getSuperclass();
        }

        return fieldsList.toArray(new Field[fieldsList.size()]);
      } catch (SecurityException e) {
        // fall through to !includePrivate case
      }
    }
    return cl.getFields();
  }
Ejemplo n.º 20
0
  /* package */ void ensureConstraints(List<Child> children) {
    Set<String> nullElements = new HashSet<String>(model.getElementNames());
    for (Child child : children) {
      nullElements.remove(child.name);
    }

    for (String s : nullElements) {
      ConfigModel.Property p = model.getElement(s);
      for (String annotation : p.getAnnotations()) {
        if (annotation.equals(NotNull.class.getName())) {
          if (p instanceof ConfigModel.Node) {
            ConfigModel childModel = ((ConfigModel.Node) p).model;
            Dom child = document.make(getHabitat(), null, this, childModel);
            child.register();

            children.add(new Dom.NodeChild(s, child));

            // recursive call to ensure the children constraints are also respected
            List<Child> grandChildren = new ArrayList<Child>();
            child.ensureConstraints(grandChildren);
            if (!grandChildren.isEmpty()) {
              child.setChildren(grandChildren);
            }

            child.initializationCompleted();
          }
        }
      }
    }
  }
Ejemplo n.º 21
0
 public boolean testContainsAddNew() {
   description = "after adding an object to new list,it is contained";
   precondition = new Boolean(li.isEmpty());
   Object e = new Object();
   li.add(0, e);
   return li.contains(e) == true;
 }
Ejemplo n.º 22
0
 @SuppressWarnings("unchecked")
 public static <BEAN, PROP_TYPE> List<PROP_TYPE> extractProperties(
     Collection<BEAN> beans, String propertyName) {
   List<PROP_TYPE> result = new ArrayList<PROP_TYPE>(beans.size());
   for (BEAN bean : beans) result.add((PROP_TYPE) getPropertyValue(bean, propertyName));
   return result;
 }
  public ListIterator<ICFLibAnyObj> enumerateDetails(MssCFGenContext genContext) {
    final String S_ProcName = "CFAsteriskMssCFIterateHostNodeConfFile.enumerateDetails() ";

    if (genContext == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), S_ProcName, 1, "genContext");
    }

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), S_ProcName, 1, "genContext.getGenDef()");
    }

    List<ICFLibAnyObj> list = new LinkedList<ICFLibAnyObj>();

    if (genDef instanceof ICFAsteriskHostNodeObj) {
      Iterator<ICFAsteriskConfigurationFileObj> elements =
          ((ICFAsteriskHostNodeObj) genDef).getOptionalComponentsConfFile().iterator();
      while (elements.hasNext()) {
        list.add(elements.next());
      }
    } else {
      throw CFLib.getDefaultExceptionFactory()
          .newUnsupportedClassException(
              getClass(), S_ProcName, "genContext.getGenDef()", genDef, "ICFAsteriskHostNodeObj");
    }

    return (list.listIterator());
  }
  public ListIterator<ICFLibAnyObj> enumerateDetails(MssCFGenContext genContext) {
    final String S_ProcName = "CFBamMssCFIterateNumberTypeRef.enumerateDetails() ";

    if (genContext == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), S_ProcName, 1, "genContext");
    }

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), S_ProcName, 1, "genContext.getGenDef()");
    }

    List<ICFLibAnyObj> list = new LinkedList<ICFLibAnyObj>();

    if (genDef instanceof ICFBamNumberTypeObj) {
      Iterator<ICFBamTableColObj> elements =
          ((ICFBamNumberTypeObj) genDef).getOptionalChildrenRef().iterator();
      while (elements.hasNext()) {
        list.add(elements.next());
      }
    } else {
      throw CFLib.getDefaultExceptionFactory()
          .newUnsupportedClassException(
              getClass(), S_ProcName, "genContext.getGenDef()", genDef, "ICFBamNumberTypeObj");
    }

    return (list.listIterator());
  }
Ejemplo n.º 25
0
 public <BLOCK extends Block> BLOCK newBlock(
     String name, Class<BLOCK> cls, Class itemClass, String title) {
   try {
     int id = config.getBlock(name, 4095).getInt();
     Constructor<BLOCK> ctor = cls.getConstructor(int.class);
     BLOCK block = ctor.newInstance(id);
     String qualName = assetKey + ":" + name;
     block.setUnlocalizedName(qualName);
     // block.func_111022_d(qualName.toLowerCase()); // Set default icon name
     // block.func_111022_d(qualName); // Set default icon name
     block.setTextureName(qualName); // Set default icon name
     GameRegistry.registerBlock(block, itemClass);
     if (title != null) {
       LanguageRegistry.addName(block, title);
       if (clientSide) {
         // System.out.printf("%s: BaseMod.newBlock: %s: creative tab = %s\n",
         //	this, block.getUnlocalizedName(), block.getCreativeTabToDisplayOn());
         if (block.getCreativeTabToDisplayOn() == null && !title.startsWith("["))
           block.setCreativeTab(CreativeTabs.tabMisc);
       }
     }
     if (block instanceof IBlock) registeredBlocks.add((IBlock) block);
     return block;
   } catch (Exception e) {
     throw new RuntimeException(e);
   }
 }
Ejemplo n.º 26
0
Archivo: Macro.java Proyecto: bramk/bnd
  String ls(String args[], boolean relative) {
    if (args.length < 2)
      throw new IllegalArgumentException(
          "the ${ls} macro must at least have a directory as parameter");

    File dir = domain.getFile(args[1]);
    if (!dir.isAbsolute())
      throw new IllegalArgumentException(
          "the ${ls} macro directory parameter is not absolute: " + dir);

    if (!dir.exists())
      throw new IllegalArgumentException(
          "the ${ls} macro directory parameter does not exist: " + dir);

    if (!dir.isDirectory())
      throw new IllegalArgumentException(
          "the ${ls} macro directory parameter points to a file instead of a directory: " + dir);

    Collection<File> files = new ArrayList<File>(new SortedList<File>(dir.listFiles()));

    for (int i = 2; i < args.length; i++) {
      Instructions filters = new Instructions(args[i]);
      files = filters.select(files, true);
    }

    List<String> result = new ArrayList<String>();
    for (File file : files) result.add(relative ? file.getName() : file.getAbsolutePath());

    return Processor.join(result, ",");
  }
Ejemplo n.º 27
0
  private void checkStartup(
      Map<String, ServiceData> map,
      List<ServiceData> start,
      ServiceData sd,
      Set<ServiceData> cyclic) {
    if (sd.after.isEmpty() || start.contains(sd)) return;

    if (cyclic.contains(sd)) {
      reporter.error("Cyclic dependency for " + sd.name);
      return;
    }

    cyclic.add(sd);

    for (String dependsOn : sd.after) {
      if (dependsOn.equals("boot")) continue;

      ServiceData deps = map.get(dependsOn);
      if (deps == null) {
        reporter.error("No such service " + dependsOn + " but " + sd.name + " depends on it");
      } else {
        checkStartup(map, start, deps, cyclic);
      }
    }
    start.add(sd);
  }
Ejemplo n.º 28
0
 static ServerMessage doTxRx(ClientMessage... cms) {
   List<ClientMessage> cmArray = new ArrayList<ClientMessage>();
   for (ClientMessage cm : cms) {
     cmArray.add(cm);
   }
   ServerMessage result = doTxRx(cmArray);
   return result;
 }
Ejemplo n.º 29
0
 /**
  * Obtains the plural attribute value. Values are separate by ',' and surrounding whitespaces are
  * ignored.
  *
  * @return null if the attribute doesn't exist. This is a distinct state from the empty list,
  *     which indicates that the attribute was there but no values were found.
  */
 public List<String> attributes(String name) {
   String v = attribute(name);
   if (v == null) return null;
   List<String> r = new ArrayList<String>();
   StringTokenizer tokens = new StringTokenizer(v, ",");
   while (tokens.hasMoreTokens()) r.add(tokens.nextToken().trim());
   return r;
 }
Ejemplo n.º 30
0
 private String getNameText(Element e) // whoops;
     {
   List<String> parts = new ArrayList<String>();
   for (Element w : XML.getElementsByTagname(e, "w", false)) {
     parts.add(w.getTextContent().trim());
   }
   return StringUtils.join(parts, " ");
 }