JavaScriptModuleBuilder implements IModuleBuilder, IExtensionInitializer, ILayerListener, IShutdownListener, IConfigListener { protected String generateModuleIdReg(List<String[]> expDeps, Map<String, Integer> idMap) { StringBuffer sb = new StringBuffer(); int i = 0; sb.append("[["); for (String[] deps : expDeps) { int j = 0; sb.append(i++==0?"":",").append("["); for (String dep : deps) { sb.append(j++==0?"":",") .append("\"") .append(dep) .append("\""); } sb.append("]"); } sb.append("]"); if (idMap != null) { i = 0; sb.append(",["); for (String[] deps : expDeps) { sb.append(i++==0?"":",").append("["); int j = 0; for (String dep : deps) { Matcher m = hasPluginPattern.matcher(dep); if (m.find()) { HasNode hasNode = new HasNode(m.group(2)); ModuleDeps hasDeps = hasNode.evaluateAll( "has", Features.emptyFeatures, new HashSet<String>(), (ModuleDepInfo)null, null); sb.append(j++==0?"":",").append(hasDeps.size() > 1 ? "[" : ""); int k = 0; for (Map.Entry<String, ModuleDepInfo> entry : hasDeps.entrySet()) { dep = entry.getKey(); int idx = dep.lastIndexOf('!'); if (idx != -1) { dep = dep.substring(idx+1); } Integer val = idMap.get(dep); int id = val != null ? val.intValue() : 0; sb.append(k++==0?"":",").append(id); } sb.append(hasDeps.size() > 1 ? "]" : ""); } else { int idx = dep.lastIndexOf('!'); if (idx != -1) { dep = dep.substring(idx+1); } Integer val = idMap.get(dep); int id = val != null ? val.intValue() : 0; sb.append(j++==0?"":",").append(id); } } sb.append("]"); } sb.append("]"); } sb.append("]"); return sb.toString(); }  static CompilationLevel getCompilationLevel(HttpServletRequest request); @Override void initialize(IAggregator aggregator,
			IAggregatorExtension extension, IExtensionRegistrar registrar); @Override String layerBeginEndNotifier(EventType type, HttpServletRequest request, List<IModule> modules, Set<String> dependentFeatures); @Override void shutdown(IAggregator aggregator); @Override void configLoaded(IConfig config, long sequence); @Override ModuleBuild build(
			String mid,
			IResource resource,
			HttpServletRequest request,
			List<ICacheKeyGenerator> keyGens
			); @Override List<ICacheKeyGenerator> getCacheKeyGenerators(IAggregator aggregator); @Override boolean handles(String mid, IResource resource); @Override boolean isScript(HttpServletRequest request); static final String MODULE_EXPANDED_DEPS; }
@Test public void testGenerateModuleIdReg() throws Exception { Map<String, Integer> moduleIdMap = new HashMap<String, Integer>(); moduleIdMap.put("dep1", 100); moduleIdMap.put("dep2", 102); moduleIdMap.put("foodep", 500); moduleIdMap.put("feature/dep1", 511); moduleIdMap.put("feature/dep2", 512); moduleIdMap.put("feature1/dep", 513); TestJavaScriptModuleBuilder builder = new TestJavaScriptModuleBuilder(); List<String[]> expDeps = new ArrayList<String[]>(); String result = builder.generateModuleIdReg(expDeps, moduleIdMap); Assert.assertEquals("[[],[]]", result); System.out.println(result); expDeps.add(new String[]{"dep1"}); result = builder.generateModuleIdReg(expDeps, moduleIdMap); System.out.println(result); Assert.assertEquals("[[[\"dep1\"]],[[100]]]", result); expDeps.clear(); expDeps.add(new String[]{"dep1", "dep2"}); expDeps.add(new String[]{"foodep"}); result = builder.generateModuleIdReg(expDeps, moduleIdMap); System.out.println(result); Assert.assertEquals("[[[\"dep1\",\"dep2\"],[\"foodep\"]],[[100,102],[500]]]", result); expDeps.clear(); expDeps.add(new String[]{"dep1", "dep2"}); expDeps.add(new String[]{"foodep"}); expDeps.add(new String[]{"nodep"}); result = builder.generateModuleIdReg(expDeps, moduleIdMap); System.out.println(result); Assert.assertEquals("[[[\"dep1\",\"dep2\"],[\"foodep\"],[\"nodep\"]],[[100,102],[500],[0]]]", result); expDeps.add(new String[]{"dojo/has!feature?feature/dep1"}); result = builder.generateModuleIdReg(expDeps, moduleIdMap); System.out.println(result); Assert.assertEquals("[[[\"dep1\",\"dep2\"],[\"foodep\"],[\"nodep\"],[\"dojo/has!feature?feature/dep1\"]],[[100,102],[500],[0],[511]]]", result); expDeps.clear(); expDeps.add(new String[]{"dep1", "dojo/has!feature?feature/dep1"}); result = builder.generateModuleIdReg(expDeps, moduleIdMap); System.out.println(result); Assert.assertEquals("[[[\"dep1\",\"dojo/has!feature?feature/dep1\"]],[[100,511]]]", result); expDeps.clear(); expDeps.add(new String[]{"dep1", "dojo/has!feature?feature/dep1:feature/dep2"}); result = builder.generateModuleIdReg(expDeps, moduleIdMap); System.out.println(result); Assert.assertEquals("[[[\"dep1\",\"dojo/has!feature?feature/dep1:feature/dep2\"]],[[100,[511,512]]]]", result); expDeps.clear(); expDeps.add(new String[]{"dep1", "dojo/has!feature1?feature1/dep:feature?feature/dep1:feature/dep2", "dep2"}); result = builder.generateModuleIdReg(expDeps, moduleIdMap); System.out.println(result); Assert.assertEquals("[[[\"dep1\",\"dojo/has!feature1?feature1/dep:feature?feature/dep1:feature/dep2\",\"dep2\"]],[[100,[513,511,512],102]]]", result); }