@Inject(optional = true) public void setThreadPoolSize( @Named("shindig.closure.compile.threadPoolSize") Integer threadPoolSize) { if (threadPoolSize != null && threadPoolSize != this.threadPoolSize) { ExecutorService compilerPool = this.compilerPool; this.threadPoolSize = threadPoolSize; this.compilerPool = createThreadPool(); compilerPool.shutdown(); } }
public ClosureJsCompiler(DefaultJsCompiler defaultCompiler, CacheProvider cacheProvider, String level, ExecutorService executorService) { this.cache = cacheProvider.createCache(CACHE_NAME); this.defaultCompiler = defaultCompiler; List<SourceFile> externs = null; try { externs = Collections.unmodifiableList(CommandLineRunner.getDefaultExterns()); } catch(IOException e) { if (LOG.isLoggable(Level.WARNING)) { LOG.log(Level.WARNING, "Unable to load default closure externs: " + e.getMessage(), e); } } defaultExterns = externs; compileLevel = level.toLowerCase().trim(); if(executorService != null) { compilerPool = executorService; }else { compilerPool = createThreadPool(); } Map<String, Future<CompileResult>> map = Maps.newHashMap(); compiling = new ConcurrentHashMap<String, Future<CompileResult>>(map); }