@Test public void testInitWithStandardModules() throws Exception { MockFilterConfig config = new MockFilterConfig(); config.setFilterName("cayenne-abc"); MockServletContext context = new MockServletContext(); config.setupServletContext(context); CayenneFilter filter = new CayenneFilter(); assertNull(WebUtil.getCayenneRuntime(context)); filter.init(config); CayenneRuntime runtime = WebUtil.getCayenneRuntime(context); assertNotNull(runtime); List<String> locations = runtime.getInjector() .getInstance(Key.getListOf(String.class, Constants.SERVER_PROJECT_LOCATIONS_LIST)); assertEquals(Collections.singletonList("cayenne-abc.xml"), locations); Collection<Module> modules = runtime.getModules(); assertEquals(3, modules.size()); Object[] marray = modules.toArray(); if (marray[0] instanceof ServerModule) { assertTrue(marray[1] instanceof WebModule); } else { assertTrue(marray[0] instanceof WebModule); } RequestHandler handler = runtime.getInjector().getInstance(RequestHandler.class); assertTrue(handler instanceof SessionContextRequestHandler); }
@Override public void init(FilterConfig config) throws ServletException { checkAlreadyConfigured(config.getServletContext()); this.servletContext = config.getServletContext(); WebConfiguration configAdapter = new WebConfiguration(config); String configurationLocation = configAdapter.getConfigurationLocation(); String[] configurationLocations = null; if (configurationLocation != null) { configurationLocations = configurationLocation.split(",\\s*"); } Collection<Module> modules = configAdapter.createModules(); modules.addAll(getAdditionalModules()); String dataDomainName = configAdapter.getDataDomainName(); ServerRuntime runtime = ServerRuntime.builder(dataDomainName) .addConfigs(configurationLocations) .addModules(modules).build(); WebUtil.setCayenneRuntime(config.getServletContext(), runtime); }
CayenneFilter implements Filter { @Override public void init(FilterConfig config) throws ServletException { checkAlreadyConfigured(config.getServletContext()); this.servletContext = config.getServletContext(); WebConfiguration configAdapter = new WebConfiguration(config); String configurationLocation = configAdapter.getConfigurationLocation(); String[] configurationLocations = null; if (configurationLocation != null) { configurationLocations = configurationLocation.split(",\\s*"); } Collection<Module> modules = configAdapter.createModules(); modules.addAll(getAdditionalModules()); String dataDomainName = configAdapter.getDataDomainName(); ServerRuntime runtime = ServerRuntime.builder(dataDomainName) .addConfigs(configurationLocations) .addModules(modules).build(); WebUtil.setCayenneRuntime(config.getServletContext(), runtime); } }
CayenneFilter implements Filter { @Override public void init(FilterConfig config) throws ServletException { checkAlreadyConfigured(config.getServletContext()); this.servletContext = config.getServletContext(); WebConfiguration configAdapter = new WebConfiguration(config); String configurationLocation = configAdapter.getConfigurationLocation(); String[] configurationLocations = null; if (configurationLocation != null) { configurationLocations = configurationLocation.split(",\\s*"); } Collection<Module> modules = configAdapter.createModules(); modules.addAll(getAdditionalModules()); String dataDomainName = configAdapter.getDataDomainName(); ServerRuntime runtime = ServerRuntime.builder(dataDomainName) .addConfigs(configurationLocations) .addModules(modules).build(); WebUtil.setCayenneRuntime(config.getServletContext(), runtime); }  }
CayenneFilter implements Filter { @Override public void init(FilterConfig config) throws ServletException { checkAlreadyConfigured(config.getServletContext()); this.servletContext = config.getServletContext(); WebConfiguration configAdapter = new WebConfiguration(config); String configurationLocation = configAdapter.getConfigurationLocation(); String[] configurationLocations = null; if (configurationLocation != null) { configurationLocations = configurationLocation.split(",\\s*"); } Collection<Module> modules = configAdapter.createModules(); modules.addAll(getAdditionalModules()); String dataDomainName = configAdapter.getDataDomainName(); ServerRuntime runtime = ServerRuntime.builder(dataDomainName) .addConfigs(configurationLocations) .addModules(modules).build(); WebUtil.setCayenneRuntime(config.getServletContext(), runtime); }  @Override void init(FilterConfig config); @Override void destroy(); @Override void doFilter(
            ServletRequest request,
            ServletResponse response,
            FilterChain chain); }
CayenneFilter implements Filter { @Override public void init(FilterConfig config) throws ServletException { checkAlreadyConfigured(config.getServletContext()); this.servletContext = config.getServletContext(); WebConfiguration configAdapter = new WebConfiguration(config); String configurationLocation = configAdapter.getConfigurationLocation(); String[] configurationLocations = null; if (configurationLocation != null) { configurationLocations = configurationLocation.split(",\\s*"); } Collection<Module> modules = configAdapter.createModules(); modules.addAll(getAdditionalModules()); String dataDomainName = configAdapter.getDataDomainName(); ServerRuntime runtime = ServerRuntime.builder(dataDomainName) .addConfigs(configurationLocations) .addModules(modules).build(); WebUtil.setCayenneRuntime(config.getServletContext(), runtime); }  @Override void init(FilterConfig config); @Override void destroy(); @Override void doFilter(
            ServletRequest request,
            ServletResponse response,
            FilterChain chain);  }