/** {@inheritDoc} */ public Map<String, Object> getApplicationScope() { return context.getApplicationScope(); }
/** {@inheritDoc} */ public Object getContext() { return rootContext.getContext(); }
/** {@inheritDoc} */ public Map<String, String> getInitParams() { return rootContext.getInitParams(); }
/** {@inheritDoc} */ public Set<URL> getResources(String path) throws IOException { Set<URL> resources = new HashSet<URL>(); resources.addAll(rootContext.getResources(path)); resources.addAll(getClasspathResources(path)); return resources; }
/** {@inheritDoc} */ public URL getResource(String path) throws IOException { URL rootUrl = rootContext.getResource(path); if (rootUrl == null) { Set<URL> resources = getResources(path); resources.remove(null); if (resources.size() > 0) { rootUrl = resources.toArray(new URL[resources.size()])[0]; } } return rootUrl; }
@Override protected List<URL> getSourceURLs(TilesApplicationContext applicationContext, TilesRequestContextFactory contextFactory) { if (definitions != null) { try { List<URL> result = new LinkedList<URL>(); for (String definition : definitions) { Set<URL> resources = applicationContext.getResources(definition); if (resources != null) { result.addAll(resources); } } return result; } catch (IOException ex) { throw new DefinitionsFactoryException("Cannot load definition URLs", ex); } } else { return super.getSourceURLs(applicationContext, contextFactory); } }
/** * Returns a list containing the URLs to be parsed. By default, it returns a * list containing the URL point to "/WEB-INF/tiles.xml". * @param applicationContext The Tiles application context. * @param contextFactory The Tiles context factory. * * @return The source URLs. * @since 2.1.1 */ protected List<URL> getSourceURLs(TilesApplicationContext applicationContext, TilesRequestContextFactory contextFactory) { List<URL> retValue = new ArrayList<URL>(1); try { retValue.add(applicationContext.getResource("/WEB-INF/tiles.xml")); } catch (IOException e) { throw new TilesContainerFactoryException( "Cannot get URL: /WEB-INF/tiles.xml", e); } return retValue; }
@Override protected List<URL> getSourceURLs(final TilesApplicationContext applicationContext, final TilesRequestContextFactory contextFactory) { final String[] definitions = TilesConfigurerSuperClassIntegration.getDefinitions(this.configurer); if (definitions != null) { try { final List<URL> result = new LinkedList<URL>(); for (String definition : definitions) { result.addAll(applicationContext.getResources(definition)); } return result; } catch (IOException ex) { throw new DefinitionsFactoryException("Cannot load definition URLs", ex); } } return super.getSourceURLs(applicationContext, contextFactory); }
/** {@inheritDoc} */ public Map<String, Object> getApplicationScope() { return rootContext.getApplicationScope(); }
/** * Returns the original servlet context. * * @param context The application context. * @return The original servlet context, if found. * @deprecated Use {@link TilesApplicationContext#getContext()}. */ protected ServletContext getServletContext(TilesApplicationContext context) { return (ServletContext) context.getContext(); } }
/** {@inheritDoc} */ public Map<String, String> getInitParams() { return context.getInitParams(); }
@Override protected List<URL> getSourceURLs(final TilesApplicationContext applicationContext, final TilesRequestContextFactory contextFactory) { final String[] definitions = TilesConfigurerSuperClassIntegration.getDefinitions(this.configurer); if (definitions != null) { try { final List<URL> result = new LinkedList<URL>(); for (String definition : definitions) { result.addAll(applicationContext.getResources(definition)); } return result; } catch (IOException ex) { throw new DefinitionsFactoryException("Cannot load definition URLs", ex); } } return super.getSourceURLs(applicationContext, contextFactory); }
/** * Configures the container to be used in the application. * * @param context The Tiles application context object to use. * @param container The container object to set. * @param key The key under which the container will be stored. * @throws TilesAccessException If something goes wrong during manipulation of the * context. * @since 2.1.2 */ public static void setContainer(TilesApplicationContext context, TilesContainer container, String key) { Log log = LogFactory.getLog(TilesAccess.class); if (key == null) { key = CONTAINER_ATTRIBUTE; } if (container == null) { if (log.isInfoEnabled()) { log.info("Removing TilesContext for context: " + context.getClass().getName()); } context.getApplicationScope().remove(key); } if (container != null && log.isInfoEnabled()) { log.info("Publishing TilesContext for context: " + context.getClass().getName()); } context.getApplicationScope().put(key, container); }
/** {@inheritDoc} */ public Object getContext() { return context.getContext(); }
/** * Returns the container key under which the container will be stored. * * @param applicationContext The Tiles application context to use. * @return The container key. * @since 2.1.2 */ protected String getContainerKey(TilesApplicationContext applicationContext) { String key = applicationContext.getInitParams().get( CONTAINER_KEY_INIT_PARAMETER); return key; }
@Override protected List<URL> getSourceURLs(final TilesApplicationContext applicationContext, final TilesRequestContextFactory contextFactory) { final String[] definitions = TilesConfigurerSuperClassIntegration.getDefinitions(this.configurer); if (definitions != null) { try { final List<URL> result = new LinkedList<URL>(); for (String definition : definitions) { result.addAll(applicationContext.getResources(definition)); } return result; } catch (IOException ex) { throw new DefinitionsFactoryException("Cannot load definition URLs", ex); } } return super.getSourceURLs(applicationContext, contextFactory); }
@Override public ViewPreparer getPreparer(String name, TilesRequestContext context) throws TilesException { WebApplicationContext webApplicationContext = (WebApplicationContext) context.getRequestScope().get( DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE); if (webApplicationContext == null) { webApplicationContext = (WebApplicationContext) context.getApplicationContext().getApplicationScope().get( WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); if (webApplicationContext == null) { throw new IllegalStateException("No WebApplicationContext found: no ContextLoaderListener registered?"); } } return getPreparer(name, webApplicationContext); }
/** {@inheritDoc} */ public void setApplicationContext(TilesApplicationContext applicationContext) { Object context = applicationContext.getContext(); if (context instanceof ServletContext) { this.servletContext = (ServletContext) context; } else { throw new IllegalArgumentException( "The application context does not hold an instance of " + "ServletContext, consider using JuelExpressionFactoryFactory"); } }
/** * Derive the resource string from the initialization parameters. * If no parameter {@link #DEFINITIONS_CONFIG} is available, attempts * to retrieve {@link #LEGACY_DEFINITIONS_CONFIG}. If niether are * available, returns "/WEB-INF/tiles.xml". * * @return resource string to be parsed. */ protected String getResourceString() { return getResourceString(context.getInitParams()); }
Set<URL> urls = applicationContext.getResources(resources[i]); if (urls != null && !urls.isEmpty()) { for (URL resourceUrl : urls) {