@Test public void testFilterCreateModules_Standard() throws Exception { MockFilterConfig config = new MockFilterConfig(); WebConfiguration configuration = new WebConfiguration(config); Module m1 = binder -> { }; Module m2 = binder -> { }; Collection<Module> modules = configuration.createModules(m1, m2); assertEquals(2, modules.size()); Iterator<Module> it = modules.iterator(); assertSame(m1, it.next()); assertSame(m2, it.next()); }
public Collection<Module> createModules(Module... standardModules) throws ServletException { Set<String> existingModules = new HashSet<>(); Collection<Module> modules = new ArrayList<>(); if (standardModules != null) { for (Module module : standardModules) { modules.add(module); existingModules.add(module.getClass().getName()); } } String extraModules = configuration.getInitParameter(EXTRA_MODULES_PARAMETER); if (extraModules != null) { StringTokenizer toks = new StringTokenizer(extraModules, ", \n\r"); while (toks.hasMoreTokens()) { String moduleName = toks.nextToken(); if (!existingModules.add(moduleName)) { continue; } Module module; try { module = (Module) Util.getJavaClass(moduleName).newInstance(); } catch (Exception e) { String message = String.format("Error instantiating custom DI module '%s' by filter '%s': %s", moduleName, getClass().getName(), e.getMessage()); throw new ServletException(message, e); } modules.add(module); } } return modules; }
WebConfiguration { public Collection<Module> createModules(Module... standardModules) throws ServletException { Set<String> existingModules = new HashSet<>(); Collection<Module> modules = new ArrayList<>(); if (standardModules != null) { for (Module module : standardModules) { modules.add(module); existingModules.add(module.getClass().getName()); } } String extraModules = configuration.getInitParameter(EXTRA_MODULES_PARAMETER); if (extraModules != null) { StringTokenizer toks = new StringTokenizer(extraModules, ", \n\r"); while (toks.hasMoreTokens()) { String moduleName = toks.nextToken(); if (!existingModules.add(moduleName)) { continue; } Module module; try { module = (Module) Util.getJavaClass(moduleName).newInstance(); } catch (Exception e) { String message = String.format("Error instantiating custom DI module '%s' by filter '%s': %s", moduleName, getClass().getName(), e.getMessage()); throw new ServletException(message, e); } modules.add(module); } } return modules; } }
WebConfiguration { public Collection<Module> createModules(Module... standardModules) throws ServletException { Set<String> existingModules = new HashSet<>(); Collection<Module> modules = new ArrayList<>(); if (standardModules != null) { for (Module module : standardModules) { modules.add(module); existingModules.add(module.getClass().getName()); } } String extraModules = configuration.getInitParameter(EXTRA_MODULES_PARAMETER); if (extraModules != null) { StringTokenizer toks = new StringTokenizer(extraModules, ", \n\r"); while (toks.hasMoreTokens()) { String moduleName = toks.nextToken(); if (!existingModules.add(moduleName)) { continue; } Module module; try { module = (Module) Util.getJavaClass(moduleName).newInstance(); } catch (Exception e) { String message = String.format("Error instantiating custom DI module '%s' by filter '%s': %s", moduleName, getClass().getName(), e.getMessage()); throw new ServletException(message, e); } modules.add(module); } } return modules; } WebConfiguration(final ServletConfig servletConfiguration);  WebConfiguration(FilterConfig filterConfiguration); }
WebConfiguration { public Collection<Module> createModules(Module... standardModules) throws ServletException { Set<String> existingModules = new HashSet<>(); Collection<Module> modules = new ArrayList<>(); if (standardModules != null) { for (Module module : standardModules) { modules.add(module); existingModules.add(module.getClass().getName()); } } String extraModules = configuration.getInitParameter(EXTRA_MODULES_PARAMETER); if (extraModules != null) { StringTokenizer toks = new StringTokenizer(extraModules, ", \n\r"); while (toks.hasMoreTokens()) { String moduleName = toks.nextToken(); if (!existingModules.add(moduleName)) { continue; } Module module; try { module = (Module) Util.getJavaClass(moduleName).newInstance(); } catch (Exception e) { String message = String.format("Error instantiating custom DI module '%s' by filter '%s': %s", moduleName, getClass().getName(), e.getMessage()); throw new ServletException(message, e); } modules.add(module); } } return modules; } WebConfiguration(final ServletConfig servletConfiguration);  WebConfiguration(FilterConfig filterConfiguration); String getConfigurationLocation(); String getDataDomainName(); Collection<Module> createModules(Module... standardModules); Map<String, String> getParameters(); Map<String, String> getOtherParameters(); }
WebConfiguration { public Collection<Module> createModules(Module... standardModules) throws ServletException { Set<String> existingModules = new HashSet<>(); Collection<Module> modules = new ArrayList<>(); if (standardModules != null) { for (Module module : standardModules) { modules.add(module); existingModules.add(module.getClass().getName()); } } String extraModules = configuration.getInitParameter(EXTRA_MODULES_PARAMETER); if (extraModules != null) { StringTokenizer toks = new StringTokenizer(extraModules, ", \n\r"); while (toks.hasMoreTokens()) { String moduleName = toks.nextToken(); if (!existingModules.add(moduleName)) { continue; } Module module; try { module = (Module) Util.getJavaClass(moduleName).newInstance(); } catch (Exception e) { String message = String.format("Error instantiating custom DI module '%s' by filter '%s': %s", moduleName, getClass().getName(), e.getMessage()); throw new ServletException(message, e); } modules.add(module); } } return modules; } WebConfiguration(final ServletConfig servletConfiguration);  WebConfiguration(FilterConfig filterConfiguration); String getConfigurationLocation(); String getDataDomainName(); Collection<Module> createModules(Module... standardModules); Map<String, String> getParameters(); Map<String, String> getOtherParameters();  }