@Override
	public Future<ModuleBuildReader> getBuild(HttpServletRequest request,
			IModule module) throws IOException {
		IAggregator aggr = (IAggregator)request.getAttribute(IAggregator.AGGREGATOR_REQATTRNAME);
		@SuppressWarnings("unchecked")
		Map<String, String> moduleCacheInfo = (Map<String, String>)request.getAttribute(IModuleCache.MODULECACHEINFO_PROPNAME);
		IResource resource = module.getResource(aggr);
		String cacheKey = module.getModuleId();
		// Try to get the module from the module cache first
		IModule cachedModule = null;
		if (!resource.exists()) {
			// Source file doesn't exist.
			// NotFound modules are not cached.  If the module is in the cache (because a
			// source file has been deleted), then remove the cached module.
			cachedModule = cacheMap.remove(cacheKey);
			if (cachedModule != null) {
				if (moduleCacheInfo != null) {
					moduleCacheInfo.put(cacheKey, "remove"); //$NON-NLS-1$
				}
				cachedModule.clearCached(aggr.getCacheManager());
			}
			throw new NotFoundException(resource.getURI().toString());
		} else {
			// add it to the module cache if not already there
			if (!RequestUtil.isIgnoreCached(request)) {
				cachedModule = cacheMap.putIfAbsent(cacheKey, module);
				if (cachedModule != null && aggr.getOptions().isDevelopmentMode()) {
					// If the uri for the source resource has changed (can happen with resource converters)
					// discard the cached module and use the new one.
					IResource cachedResource = cachedModule.getResource(null);
					if (cachedResource != null && !cachedResource.getURI().equals(resource.getURI())) {
						cacheMap.replace(cacheKey, module);
						cachedModule = null;
					}
				}
			}
			if (moduleCacheInfo != null) {
				moduleCacheInfo.put(cacheKey, (cachedModule != null) ? "hit" : "add"); //$NON-NLS-1$ //$NON-NLS-2$
			}
			module = cachedModule != null ? cachedModule : module;
		}
		return module.getBuild(request);
	}
@ Override public Future < ModuleBuildReader > getBuild ( HttpServletRequest request , IModule module ) throws IOException { IAggregator aggr = ( IAggregator ) request . getAttribute ( IAggregator . AGGREGATOR_REQATTRNAME ) ; @ SuppressWarnings ( "unchecked" ) Map < String , String > moduleCacheInfo = ( Map < String , String > ) request . getAttribute ( IModuleCache . MODULECACHEINFO_PROPNAME ) ; IResource resource = module . getResource ( aggr ) ; String cacheKey = module . getModuleId ( ) ; IModule cachedModule = null ; if ( ! resource . exists ( ) ) { cachedModule = cacheMap . remove ( cacheKey ) ; if ( cachedModule != null ) { if ( moduleCacheInfo != null ) { moduleCacheInfo . put ( cacheKey , "remove" ) ; } cachedModule . clearCached ( aggr . getCacheManager ( ) ) ; } throw new NotFoundException ( resource . getURI ( ) . toString ( ) ) ; } else { if ( ! RequestUtil . isIgnoreCached ( request ) ) { cachedModule = cacheMap . putIfAbsent ( cacheKey , module ) ; if ( cachedModule != null && aggr . getOptions ( ) . isDevelopmentMode ( ) ) { IResource cachedResource = cachedModule . getResource ( null ) ; if ( cachedResource != null && ! cachedResource . getURI ( ) . equals ( resource . getURI ( ) ) ) { cacheMap . replace ( cacheKey , module ) ; cachedModule = null ; } } } if ( moduleCacheInfo != null ) { moduleCacheInfo . put ( cacheKey , ( cachedModule != null ) ? "hit" : "add" ) ; } module = cachedModule != null ? cachedModule : module ; } return module . getBuild ( request ) ; }
/* (non-Javadoc)
@see com.ibm.jaggr.service.module.IModuleCache#getBuild(javax.servlet.http.HttpServletRequest, com.ibm.jaggr.service.module.IModule)