示例#1
0
  /** {@inheritDoc} */
  public final String convertToString(File[] entries) {
    Assure.notNull("entries", entries);

    // convert Files to String
    List<String> entriesAsString = new LinkedList<String>();
    for (File entry : entries) {
      String path = entry.getPath();
      if (!entriesAsString.contains(path)) {
        entriesAsString.add(path);
      }
    }

    // replace path and directory separator
    StringBuilder buffer = new StringBuilder();
    Iterator<String> iterator = entriesAsString.iterator();
    while (iterator.hasNext()) {
      String path = iterator.next().replace('\\', '/');
      path = Utilities.replace(path, '/', this._dirSeparator);
      buffer.append(path);
      if (iterator.hasNext()) {
        buffer.append(this._pathSeparator);
      }
    }

    // return result
    return buffer.toString();
  }
 /** {@inheritDoc} */
 public File[] getClasspath() {
   List<File> files = new ArrayList<File>();
   List<String> set = new ArrayList<String>();
   for (ClassFileLoader loader : this._classFileLoaders) {
     File[] entries = loader.getClasspath();
     for (File entry : entries) {
       entry = Utilities.getCanonicalFile(entry);
       String path = entry.getAbsolutePath();
       if (Utilities.isWindows()) {
         // for windows the case makes no difference
         path = path.toLowerCase();
       }
       if (!set.contains(path)) {
         set.add(path);
         files.add(entry);
       }
     }
   }
   return files.toArray(new File[files.size()]);
 }
  /** {@inheritDoc} */
  public void configure(ConfigurationContext context) {
    Assure.notNull("context", context);

    // get all properties describing a service
    Iterable<Pair<String, String>> serviceProperties =
        this._ant4EclipseConfiguration.getAllProperties(PROPERTY_PREFIX);

    // Iterate over all service descriptions found
    for (Pair<String, String> serviceProperty : serviceProperties) {

      // instantiate new service instance
      Object serviceInstance = Utilities.newInstance(serviceProperty.getSecond());

      // register new service
      context.registerService(serviceInstance, serviceProperty.getFirst());
    }
  }
示例#4
0
  /** Loads the configured RoleIdentifiers */
  protected void init() {

    // get all properties that defines a ProjectRoleIdentifier
    Ant4EclipseConfiguration config =
        ServiceRegistryAccess.instance().getService(Ant4EclipseConfiguration.class);
    Iterable<Pair<String, String>> entries = config.getAllProperties(PREFIX_VALIDATOR);

    List<ProjectValidator> validators = new ArrayList<ProjectValidator>();

    // Instantiate all ProjectRoleIdentifiers
    for (Pair<String, String> types : entries) {
      // we're not interested in the key of a project validator. only the classname (value of the
      // entry) is relevant
      ProjectValidator projectvalidator =
          Utilities.newInstance(types.getSecond(), types.getFirst());
      A4ELogging.trace("Register ProjectValidator '%s'", projectvalidator);
      validators.add(projectvalidator);
    }

    this._validators = validators.toArray(new ProjectValidator[validators.size()]);
  }