Package ch.cmbntr.modulizer.bootstrap.util.Resources

Examples of ch.cmbntr.modulizer.bootstrap.util.Resources.Pool


      throws MojoExecutionException {

    final Map<Artifact, File> fromTo = compute(artifacts, resourceTargetFile(moduleDirectory));
    final Map<File, Future<String>> targetHashes = sha1async(fromTo.values());

    final Pool pool = Resources.getPoolHandle();
    final ExecutorService executor = pool.aquireExec();
    try {
      return collect(ImmutableList.copyOf(transform(fromTo.entrySet(),
          new Function<Entry<Artifact, File>, Future<String>>() {
            @Override
            public Future<String> apply(final Entry<Artifact, File> e) {
              final Artifact a = e.getKey();
              final File src = a.getFile();
              final File target = e.getValue();
              final Future<String> targetHash = targetHashes.get(target);
              checkState(src != null, "missing file for %s", a);
              return executor.submit(conditionalCopy(src, target, targetHash));
            }
          })));
    } catch (final ComputationException e) {
      throw new MojoExecutionException("failed to copy artifacts", e.getCause());
    } finally {
      pool.releaseExec(executor);
    }

  }
View Full Code Here


  /**
   * {@inheritDoc}
   */
  @Override
  public void run() {
    final Pool handle = Resources.getPoolHandle();
    try {
      establishContext();
      performSecuritySettings();
      initializeLogging();
      verboseLoading();
View Full Code Here

    super();
  }

  public static List<Module> tryLoadModules(final boolean mandatory, final Iterable<String> moduleIdentifiers,
      final File... repoRoots) {
    final Pool pool = Resources.getPoolHandle();
    final ExecutorService exec = pool.aquireExec();
    final Properties origProps = snapshotProps();
    try {
      final LocalModuleLoader loader = new LocalModuleLoader(repoRoots);
      final List<Future<Module>> asyncModules = new LinkedList<Future<Module>>();
      for (final String moduleIdentifier : moduleIdentifiers) {
        asyncModules.add(exec.submit(new Callable<Module>() {
          @Override
          public Module call() throws Exception {
            return loader.loadModule(ModuleIdentifier.fromString(moduleIdentifier));
          }
        }));
      }

      final List<Module> modules = new ArrayList<Module>(asyncModules.size());
      for (final Future<Module> m : asyncModules) {
        try {
          modules.add(Resources.get(m, "failed to load module"));
        } catch (final RuntimeException e) {
          if (mandatory) {
            throw e;
          }
        }
      }
      return modules;
    } finally {
      restoreProps(origProps);
      pool.releaseExec(exec);
    }
  }
View Full Code Here

  /**
   * {@inheritDoc}
   */
  @Override
  public void run() {
    final Pool handle = Resources.getPoolHandle();
    try {
      establishContext();
      performSecuritySettings();
      initializeLogging();
      exportProperties();
View Full Code Here

TOP

Related Classes of ch.cmbntr.modulizer.bootstrap.util.Resources.Pool

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.