AbstractHttpTransport implements IHttpTransport, IConfigModifier, IShutdownListener, IDependenciesListener { protected void contributeBootLayerDeps(StringBuffer sb, HttpServletRequest request) { final String methodName = "contributeBootLayerDeps"; boolean isTraceLogging = log.isLoggable(Level.FINER); if (isTraceLogging) { log.entering(sourceClass, methodName, new Object[]{sb}); } if (request != null) { IRequestedModuleNames modules = (IRequestedModuleNames)request.getAttribute(REQUESTEDMODULENAMES_REQATTRNAME); List<Map<String, String>> deps = new ArrayList<Map<String,String>>(); try { putDeps(deps, modules.getDeps()); putDeps(deps, modules.getPreloads()); if (!deps.isEmpty()) { String json = new JSONArray(deps).toString(); sb.append("require.combo.addBootLayerDeps(").append(json).append(");\r\n"); } } catch (Exception ex) { log.logp(Level.WARNING, sourceClass, methodName, ex.getMessage(), ex); } } else if (isTraceLogging) { log.logp(Level.FINER, sourceClass, methodName, "null request object"); } if (isTraceLogging) { log.exiting(sourceClass, methodName, sb); } } AbstractHttpTransport();   AbstractHttpTransport(CountDownLatch depsInitialized, List<String> dependentFeatures, long depsLastMod); @SuppressWarnings("deprecation") @Override void decorateRequest(HttpServletRequest request); @Override Map<String, Integer> getModuleIdMap(); @Override String getModuleIdRegFunctionName(); @Override void modifyConfig(IAggregator aggregator, Object configObj); @Override void initialize(IAggregator aggregator, IAggregatorExtension extension, IExtensionRegistrar reg); @Override void shutdown(IAggregator aggregator); @Override void contributeLoaderExtensionJavaScript(String contribution); @Override String getLayerContribution(HttpServletRequest request,
			LayerContributionType type, Object arg); abstract boolean isServerExpandable(HttpServletRequest request, String mid); @Override abstract List<ICacheKeyGenerator> getCacheKeyGenerators(); @Override void dependenciesLoaded(IDependencies deps, long sequence); static final String PATHS_PROPNAME; static final String REQUESTEDMODULES_REQPARAM; static final String REQUESTEDMODULEIDS_REQPARAM; static final String REQUESTEDMODULESCOUNT_REQPARAM; static final String EXCLUDEENC_REQPARAM; static final String EXCLUDEIDS_REQPARAM; static final String CONSOLE_WARNING_MSG_FMT; static final String SCRIPTS_REQPARAM; static final String DEPS_REQPARAM; static final String REQUIRED_REQPARAM; static final String PRELOADS_REQPARAM; static final String EXCLUDES_REQPARAM; static final String FEATUREMAP_REQPARAM; static final String FEATUREMAPHASH_REQPARAM; static final String FAILONVERSIONERR_REQPARAM; static final String[] INCLUDEREQUIREDEPS_REQPARAM; static final String[] INCLUDEUNDEFINEDFEATUREDEPS_REQPARAM; static final String[] ASSERTNONLS_REQPARAM; static final String[] OPTIMIZATIONLEVEL_REQPARAMS; static final String[] EXPANDREQUIRELISTS_REQPARAMS; static final String[] EXPORTMODULENAMES_REQPARAMS; static final String[] SHOWFILENAMES_REQPARAMS; static final String[] NOCACHE_REQPARAMS; static final String[] REQUESTEDLOCALES_REQPARAMS; static final String[] CACHEBUST_REQPARAMS; static final String[] SERVEREXPANDLAYERS_REQPARAMS; static final String[] DEPENDENCYEXPANSIONLOGGING_REQPARAMS; static final String[] GENERATESOURCEMAPS_REQPARAMS; static final String CONFIGVARNAME_REQPARAM; static final String LAYERCONTRIBUTIONSTATE_REQATTRNAME; static final String ENCODED_FEATURE_MAP_REQPARAM; static final String FEATURE_LIST_PRELUDE; static final String FEATURE_LIST_PROLOGUE; }
@Test public void testContributeBootLayerDeps() throws Exception { final Pattern pat = Pattern.compile("^require\\.combo\\.addBootLayerDeps\\(([^;]*)\\);\\s"); IAggregator mockAggregator = EasyMock.createMock(IAggregator.class); TestHttpTransport transport = new TestHttpTransport(mockAggregator); HttpServletRequest mockRequest = TestUtils.createMockRequest(mockAggregator); EasyMock.replay(mockAggregator, mockRequest); MockRequestedModuleNames reqNames = new MockRequestedModuleNames(); mockRequest.setAttribute(IHttpTransport.REQUESTEDMODULENAMES_REQATTRNAME, reqNames); reqNames.setDeps(Arrays.asList("dep/a", "prefix!dep/b")); StringBuffer sb = new StringBuffer(); transport.contributeBootLayerDeps(sb, mockRequest); System.out.println(sb.toString()); Matcher m = pat.matcher(sb.toString()); Assert.assertTrue(m.find()); JSONArray jsonObj = new JSONArray(m.group(1)); Assert.assertEquals(new JSONArray("[{\"name\":\"dep/a\"},{\"name\":\"dep/b\",\"prefix\":\"prefix\"}]"), jsonObj); reqNames = new MockRequestedModuleNames(); mockRequest.setAttribute(IHttpTransport.REQUESTEDMODULENAMES_REQATTRNAME, reqNames); reqNames.setPreloads(Arrays.asList("prefix!preload/a", "preload/b")); sb = new StringBuffer(); transport.contributeBootLayerDeps(sb, mockRequest); m = pat.matcher(sb.toString()); Assert.assertTrue(m.find()); jsonObj = new JSONArray(m.group(1)); Assert.assertEquals(new JSONArray("[{\"name\":\"preload/a\",\"prefix\":\"prefix\"},{\"name\":\"preload/b\"}]"), jsonObj); reqNames = new MockRequestedModuleNames(); mockRequest.setAttribute(IHttpTransport.REQUESTEDMODULENAMES_REQATTRNAME, reqNames); reqNames.setPreloads(Arrays.asList("dep/a", "preload/a")); sb = new StringBuffer(); transport.contributeBootLayerDeps(sb, mockRequest); m = pat.matcher(sb.toString()); Assert.assertTrue(m.find()); jsonObj = new JSONArray(m.group(1)); Assert.assertEquals(new JSONArray("[{\"name\":\"dep/a\"},{\"name\":\"preload/a\"}]"), jsonObj); }