use of org.apache.tapestry5.ioc.services.SymbolProvider in project tapestry-5 by apache.
the class ServletContextSymbolProviderTest method access_of_keys_is_case_insensitive.
@Test
public void access_of_keys_is_case_insensitive() {
ServletContext context = newMock(ServletContext.class);
String key1 = "fred";
String value1 = "Fred Flintstone";
String key2 = "barney";
String value2 = "Barney Rubble";
expect(context.getInitParameterNames()).andReturn(toEnumeration(key1, key2));
expect(context.getInitParameter(key1)).andReturn(value1);
expect(context.getInitParameter(key2)).andReturn(value2);
replay();
SymbolProvider p = new ServletContextSymbolProvider(context);
assertEquals(p.valueForSymbol(key1), value1);
assertEquals(p.valueForSymbol(key2), value2);
// Not in config is null
assertNull(p.valueForSymbol("wilma"));
// Check for case insensitivity
assertEquals(p.valueForSymbol("FRED"), value1);
verify();
}
use of org.apache.tapestry5.ioc.services.SymbolProvider in project tapestry-5 by apache.
the class TapestryIOCModule method setupStandardSymbolProviders.
/**
* <dl>
* <dt>SystemProperties</dt>
* <dd>Exposes JVM System properties as symbols (currently case-sensitive)</dd>
* <dt>EnvironmentVariables</dt>
* <dd>Exposes environment variables as symbols (adding a "env." prefix)</dd>
* <dt>ApplicationDefaults</dt>
* <dd>Values contributed to @{@link SymbolProvider} @{@link ApplicationDefaults}</dd>
* <dt>FactoryDefaults</dt>
* <dd>Values contributed to @{@link SymbolProvider} @{@link FactoryDefaults}</dd>
* </dl>
*/
@Contribute(SymbolSource.class)
public static void setupStandardSymbolProviders(OrderedConfiguration<SymbolProvider> configuration, @ApplicationDefaults SymbolProvider applicationDefaults, @FactoryDefaults SymbolProvider factoryDefaults) {
configuration.add("SystemProperties", new SystemPropertiesSymbolProvider(), "before:*");
configuration.add("EnvironmentVariables", new SystemEnvSymbolProvider());
configuration.add("ApplicationDefaults", applicationDefaults);
configuration.add("FactoryDefaults", factoryDefaults);
}
use of org.apache.tapestry5.ioc.services.SymbolProvider in project tapestry-5 by apache.
the class TapestryFilter method init.
/**
* Initializes the filter using the {@link TapestryAppInitializer}. The application name is the
* capitalization of
* the filter name (as specified in web.xml).
*/
public final void init(FilterConfig filterConfig) throws ServletException {
config = filterConfig;
final ServletContext context = config.getServletContext();
String filterName = config.getFilterName();
SymbolProvider combinedProvider = new DelegatingSymbolProvider(new SystemPropertiesSymbolProvider(), new SingleKeySymbolProvider(TapestryHttpSymbolConstants.CONTEXT_PATH, context.getContextPath()), new ServletContextSymbolProvider(context), new SingleKeySymbolProvider(TapestryHttpSymbolConstants.EXECUTION_MODE, "production"));
String executionMode = combinedProvider.valueForSymbol(TapestryHttpSymbolConstants.EXECUTION_MODE);
TapestryAppInitializer appInitializer = new TapestryAppInitializer(logger, combinedProvider, filterName, executionMode);
appInitializer.addModules(provideExtraModuleDefs(context));
appInitializer.addModules(provideExtraModuleClasses(context));
registry = appInitializer.createRegistry();
context.setAttribute(REGISTRY_CONTEXT_NAME, registry);
ServletApplicationInitializer ai = registry.getService("ServletApplicationInitializer", ServletApplicationInitializer.class);
ai.initializeApplication(context);
registry.performRegistryStartup();
handler = registry.getService("HttpServletRequestHandler", HttpServletRequestHandler.class);
asyncRequestService = registry.getService("AsyncRequestService", AsyncRequestService.class);
init(registry);
appInitializer.announceStartup();
registry.cleanupThread();
}
Aggregations