private static AttachingConnector getAttachingConnectorFor(String transport) {
   List acs = Bootstrap.virtualMachineManager().attachingConnectors();
   AttachingConnector ac;
   int i, k = acs.size();
   for (i = 0; i < k; i++)
     if ((ac = (AttachingConnector) acs.get(i)).transport().name().equals(transport)) return ac;
   return null;
 }
Example #2
0
 /*
  * Find Connector by name
  */
 private static Connector findConnector(String name) {
   List connectors = Bootstrap.virtualMachineManager().allConnectors();
   Iterator iter = connectors.iterator();
   while (iter.hasNext()) {
     Connector connector = (Connector) iter.next();
     if (connector.name().equals(name)) {
       return connector;
     }
   }
   return null;
 }
 // returns null if we don't have anything free
 private static synchronized Class getFreeVMImplClass() {
   while (!freeVMClasses.isEmpty()) {
     SoftReference ref = (SoftReference) freeVMClasses.remove(0);
     Object o = ref.get();
     if (o != null) {
       if (DEBUG) {
         System.out.println("re-using loaded VirtualMachineImpl");
       }
       return (Class) o;
     }
   }
   return null;
 }
 /**
  * Performs basic sanity check of argument.
  *
  * @return <code>true</code> if value is one of {@link #choices()}.
  */
 public boolean isValid(String value) {
   return choices.contains(value);
 }
 // add a new free VirtualMachineImpl class
 private static synchronized void addFreeVMImplClass(Class clazz) {
   if (DEBUG) {
     System.out.println("adding free VirtualMachineImpl class");
   }
   freeVMClasses.add(new SoftReference(clazz));
 }
Example #6
0
  private static List<String> splitStringAtNonEnclosedWhiteSpace(String value)
      throws IllegalArgumentException {
    List<String> al = new ArrayList<String>();
    char[] arr;
    int startPosition = 0;
    int endPosition = 0;
    final char SPACE = ' ';
    final char DOUBLEQ = '"';
    final char SINGLEQ = '\'';

    /*
     * An "open" or "active" enclosing state is where
     * the first valid start quote qualifier is found,
     * and there is a search in progress for the
     * relevant end matching quote
     *
     * enclosingTargetChar set to SPACE
     * is used to signal a non open enclosing state
     */
    char enclosingTargetChar = SPACE;

    if (value == null) {
      throw new IllegalArgumentException(MessageOutput.format("value string is null"));
    }

    // split parameter string into individual chars
    arr = value.toCharArray();

    for (int i = 0; i < arr.length; i++) {
      switch (arr[i]) {
        case SPACE:
          {
            // do nothing for spaces
            // unless last in array
            if (isLastChar(arr, i)) {
              endPosition = i;
              // break for substring creation
              break;
            }
            continue;
          }
        case DOUBLEQ:
        case SINGLEQ:
          {
            if (enclosingTargetChar == arr[i]) {
              // potential match to close open enclosing
              if (isNextCharWhitespace(arr, i)) {
                // if peek next is whitespace
                // then enclosing is a valid substring
                endPosition = i;
                // reset enclosing target char
                enclosingTargetChar = SPACE;
                // break for substring creation
                break;
              }
            }
            if (enclosingTargetChar == SPACE) {
              // no open enclosing state
              // handle as normal char
              if (isPreviousCharWhitespace(arr, i)) {
                startPosition = i;
                // peek forward for end candidates
                if (value.indexOf(arr[i], i + 1) >= 0) {
                  // set open enclosing state by
                  // setting up the target char
                  enclosingTargetChar = arr[i];
                } else {
                  // no more target chars left to match
                  // end enclosing, handle as normal char
                  if (isNextCharWhitespace(arr, i)) {
                    endPosition = i;
                    // break for substring creation
                    break;
                  }
                }
              }
            }
            continue;
          }
        default:
          {
            // normal non-space, non-" and non-' chars
            if (enclosingTargetChar == SPACE) {
              // no open enclosing state
              if (isPreviousCharWhitespace(arr, i)) {
                // start of space delim substring
                startPosition = i;
              }
              if (isNextCharWhitespace(arr, i)) {
                // end of space delim substring
                endPosition = i;
                // break for substring creation
                break;
              }
            }
            continue;
          }
      }

      // break's end up here
      if (startPosition > endPosition) {
        throw new IllegalArgumentException(MessageOutput.format("Illegal option values"));
      }

      // extract substring and add to List<String>
      al.add(value.substring(startPosition, ++endPosition));

      // set new start position
      i = startPosition = endPosition;
    } // for loop

    return al;
  }