@Override public ViewPreparer getPreparer(String name, Request context) { WebApplicationContext webApplicationContext = (WebApplicationContext) context.getContext("request").get( DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE); if (webApplicationContext == null) { webApplicationContext = (WebApplicationContext) context.getContext("application").get( WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); if (webApplicationContext == null) { throw new IllegalStateException("No WebApplicationContext found: no ContextLoaderListener registered?"); } } return getPreparer(name, webApplicationContext); }
@Override protected List<ApplicationResource> getSources(ApplicationContext applicationContext) { if (definitions != null) { List<ApplicationResource> result = new LinkedList<>(); for (String definition : definitions) { Collection<ApplicationResource> resources = applicationContext.getResources(definition); if (resources != null) { result.addAll(resources); } } return result; } else { return super.getSources(applicationContext); } }
@Override @Nullable public ApplicationResource getResource(ApplicationResource base, Locale locale) { Collection<ApplicationResource> urlSet = getResources(base.getLocalePath(locale)); if (!CollectionUtils.isEmpty(urlSet)) { return urlSet.iterator().next(); } return null; }
ApplicationContext tilesAppContext = tilesRequest.getApplicationContext(); BasicTilesContainer container = (BasicTilesContainer) TilesAccess.getContainer(tilesAppContext); tilesRequest.getContext("request").put(ServletRequest.FORCE_INCLUDE_ATTRIBUTE_NAME, true);
/** {@inheritDoc} */ public ApplicationContext getNestedObject(Request obj) { return obj.getApplicationContext(); } }
/** {@inheritDoc} */ public Object getContext() { return context.getContext(); }
@Override protected DefinitionsFactory createDefinitionsFactory(ApplicationContext applicationContext, LocaleResolver resolver) { if (definitionsFactoryClass != null) { DefinitionsFactory factory = BeanUtils.instantiateClass(definitionsFactoryClass); if (factory instanceof ApplicationContextAware) { ((ApplicationContextAware) factory).setApplicationContext(applicationContext); } BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(factory); if (bw.isWritableProperty("localeResolver")) { bw.setPropertyValue("localeResolver", resolver); } if (bw.isWritableProperty("definitionDAO")) { bw.setPropertyValue("definitionDAO", createLocaleDefinitionDao(applicationContext, resolver)); } return factory; } else { return super.createDefinitionsFactory(applicationContext, resolver); } }
/** {@inheritDoc} */ public List<String> getAvailableScopes() { return context.getAvailableScopes(); } }
/** * Includes the result. By default, uses the wrapped request for the inclusion. * * @param path The path whose result will be included. * @throws IOException If something goes wrong. */ protected void doInclude(String path) throws IOException { getWrappedRequest().include(path); } }
/** * Returns the application scope. * * @return The application scope. */ public Map<String, Object> getApplicationScope() { return applicationContext.getApplicationScope(); }
private DispatchRequest getDispatchRequest(Request request) { Request result = request; while (!(result instanceof DispatchRequest) && result instanceof RequestWrapper) { result = ((RequestWrapper) result).getWrappedRequest(); } if (!(result instanceof DispatchRequest)) { result = null; } return (DispatchRequest) result; } }
@Override public void dispatch(String path) throws IOException { setForceInclude(true); doInclude(path); }
/** {@inheritDoc} */ public OutputStream getOutputStream() throws IOException { return context.getOutputStream(); }
/** {@inheritDoc} */ public PrintWriter getPrintWriter() throws IOException { return context.getPrintWriter(); }
@Override public ViewPreparer getPreparer(String name, Request context) { WebApplicationContext webApplicationContext = (WebApplicationContext) context.getContext("request").get( DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE); if (webApplicationContext == null) { webApplicationContext = (WebApplicationContext) context.getContext("application").get( WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); if (webApplicationContext == null) { throw new IllegalStateException("No WebApplicationContext found: no ContextLoaderListener registered?"); } } return getPreparer(name, webApplicationContext); }
@Override protected List<ApplicationResource> getSources(ApplicationContext applicationContext) { if (definitions != null) { List<ApplicationResource> result = new LinkedList<>(); for (String definition : definitions) { Collection<ApplicationResource> resources = applicationContext.getResources(definition); if (resources != null) { result.addAll(resources); } } return result; } else { return super.getSources(applicationContext); } }
@Override @Nullable public ApplicationResource getResource(ApplicationResource base, Locale locale) { Collection<ApplicationResource> urlSet = getResources(base.getLocalePath(locale)); if (!CollectionUtils.isEmpty(urlSet)) { return urlSet.iterator().next(); } return null; }
@Override protected DefinitionsFactory createDefinitionsFactory(ApplicationContext applicationContext, LocaleResolver resolver) { if (definitionsFactoryClass != null) { DefinitionsFactory factory = BeanUtils.instantiateClass(definitionsFactoryClass); if (factory instanceof ApplicationContextAware) { ((ApplicationContextAware) factory).setApplicationContext(applicationContext); } BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(factory); if (bw.isWritableProperty("localeResolver")) { bw.setPropertyValue("localeResolver", resolver); } if (bw.isWritableProperty("definitionDAO")) { bw.setPropertyValue("definitionDAO", createLocaleDefinitionDao(applicationContext, resolver)); } return factory; } else { return super.createDefinitionsFactory(applicationContext, resolver); } }
/** {@inheritDoc} */ public Collection<ApplicationResource> getResources(String path) { return context.getResources(path); } }