@Test public void testThatViewsAreCachedInProductionMode() throws Exception { PageView first = provider.getView("home"); assertNotNull(first); PageView second = provider.getView("home"); assertTrue(first == second); }
@Override public PageView getView(String name) { GroovyPageView cached = cache.get(name); if (cached != null) { return cached; } try { String gsp = getViewContents(name); if (gsp == null) return null; String controllerProviderAndName = null; Pattern p = Pattern.compile("<!--\\s*CONTROLLER\\s*:\\s*(\\S*?)\\s*-->"); Matcher m = p.matcher(gsp); if (m.find()) controllerProviderAndName = m.group(1); Template template = engine.createTemplate(gsp); GroovyPageView compiledView = new GroovyPageView(template, controllerProviderAndName); if (developmentFolders == null) { cache.put(name, compiledView); } return compiledView; } catch (Exception ex) { log.error("Error creating GroovyPageView", ex); throw new RuntimeException("Error creating GroovyPageView", ex); } }
GroovyPageViewProvider implements PageViewProvider { @Override public PageView getView(String name) { GroovyPageView cached = cache.get(name); if (cached != null) { return cached; } try { String gsp = getViewContents(name); if (gsp == null) return null; String controllerProviderAndName = null; Pattern p = Pattern.compile("<!--\\s*CONTROLLER\\s*:\\s*(\\S*?)\\s*-->"); Matcher m = p.matcher(gsp); if (m.find()) controllerProviderAndName = m.group(1); Template template = engine.createTemplate(gsp); GroovyPageView compiledView = new GroovyPageView(template, controllerProviderAndName); if (developmentFolders == null) { cache.put(name, compiledView); } return compiledView; } catch (Exception ex) { log.error("Error creating GroovyPageView", ex); throw new RuntimeException("Error creating GroovyPageView", ex); } } }
GroovyPageViewProvider implements PageViewProvider { @Override public PageView getView(String name) { GroovyPageView cached = cache.get(name); if (cached != null) { return cached; } try { String gsp = getViewContents(name); if (gsp == null) return null; String controllerProviderAndName = null; Pattern p = Pattern.compile("<!--\\s*CONTROLLER\\s*:\\s*(\\S*?)\\s*-->"); Matcher m = p.matcher(gsp); if (m.find()) controllerProviderAndName = m.group(1); Template template = engine.createTemplate(gsp); GroovyPageView compiledView = new GroovyPageView(template, controllerProviderAndName); if (developmentFolders == null) { cache.put(name, compiledView); } return compiledView; } catch (Exception ex) { log.error("Error creating GroovyPageView", ex); throw new RuntimeException("Error creating GroovyPageView", ex); } }  }
GroovyPageViewProvider implements PageViewProvider { @Override public PageView getView(String name) { GroovyPageView cached = cache.get(name); if (cached != null) { return cached; } try { String gsp = getViewContents(name); if (gsp == null) return null; String controllerProviderAndName = null; Pattern p = Pattern.compile("<!--\\s*CONTROLLER\\s*:\\s*(\\S*?)\\s*-->"); Matcher m = p.matcher(gsp); if (m.find()) controllerProviderAndName = m.group(1); Template template = engine.createTemplate(gsp); GroovyPageView compiledView = new GroovyPageView(template, controllerProviderAndName); if (developmentFolders == null) { cache.put(name, compiledView); } return compiledView; } catch (Exception ex) { log.error("Error creating GroovyPageView", ex); throw new RuntimeException("Error creating GroovyPageView", ex); } }  @Override PageView getView(String name); String getViewContents(String name); String getResourcePrefix(); void setResourcePrefix(String resourcePrefix); List<File> getDevelopmentFolders(); void setDevelopmentFolders(List<File> developmentFolders); List<String> getDevelopmentFolderNames(); void setDevelopmentFolderNames(List<String> developmentFolderNames); ClassLoader getViewClassLoader(); void setViewClassLoader(ClassLoader viewClassLoader); }
GroovyPageViewProvider implements PageViewProvider { @Override public PageView getView(String name) { GroovyPageView cached = cache.get(name); if (cached != null) { return cached; } try { String gsp = getViewContents(name); if (gsp == null) return null; String controllerProviderAndName = null; Pattern p = Pattern.compile("<!--\\s*CONTROLLER\\s*:\\s*(\\S*?)\\s*-->"); Matcher m = p.matcher(gsp); if (m.find()) controllerProviderAndName = m.group(1); Template template = engine.createTemplate(gsp); GroovyPageView compiledView = new GroovyPageView(template, controllerProviderAndName); if (developmentFolders == null) { cache.put(name, compiledView); } return compiledView; } catch (Exception ex) { log.error("Error creating GroovyPageView", ex); throw new RuntimeException("Error creating GroovyPageView", ex); } }  @Override PageView getView(String name); String getViewContents(String name); String getResourcePrefix(); void setResourcePrefix(String resourcePrefix); List<File> getDevelopmentFolders(); void setDevelopmentFolders(List<File> developmentFolders); List<String> getDevelopmentFolderNames(); void setDevelopmentFolderNames(List<String> developmentFolderNames); ClassLoader getViewClassLoader(); void setViewClassLoader(ClassLoader viewClassLoader);  }