use of org.apache.tapestry5.ioc.annotations.Symbol in project tapestry-5 by apache.
the class PersistentLocaleImplTest method set_to_unsupported_locale.
/**
* TAP5-537
*/
@Test
public void set_to_unsupported_locale() {
PersistentLocale pl = new PersistentLocaleImpl(new PerthreadManagerImpl(null), "en,fr");
try {
pl.set(Locale.CHINESE);
unreachable();
} catch (IllegalArgumentException ex) {
assertEquals(ex.getMessage(), "Locale 'zh' is not supported by this application. Supported locales are 'en,fr'; this is configured via the tapestry.supported-locales symbol.");
}
}
use of org.apache.tapestry5.ioc.annotations.Symbol in project tapestry-5 by apache.
the class MongodbModule method buildMongoDB.
@Scope(ScopeConstants.PERTHREAD)
public static MongoDB buildMongoDB(Logger logger, final MongoDBSource mongoDBSource, PerthreadManager perthreadManager, @Symbol(MongoDBSymbols.DEFAULT_DB_NAME) String defaultDbName, @Symbol(MongoDBSymbols.CONSISTENT_REQUEST) boolean consistentRequest, @Symbol(MongoDBSymbols.SECURE_MODE) boolean secureMode, @Symbol(MongoDBSymbols.DB_USERNAME) String dbUsername, @Symbol(MongoDBSymbols.DB_PASSWORD) String dbPassword) {
final MongoDBImpl mongoDB = new MongoDBImpl(logger, mongoDBSource, defaultDbName, consistentRequest, secureMode, dbUsername, dbPassword);
perthreadManager.addThreadCleanupListener(mongoDB);
return mongoDB;
}
use of org.apache.tapestry5.ioc.annotations.Symbol in project tapestry-5 by apache.
the class JavaScriptModule method setupApplicationCatalogModules.
@Contribute(ModuleManager.class)
public static void setupApplicationCatalogModules(MappedConfiguration<String, Object> configuration, LocalizationSetter localizationSetter, ComponentMessagesSource messagesSource, ResourceChangeTracker resourceChangeTracker, @Symbol(SymbolConstants.COMPACT_JSON) boolean compactJSON) {
for (Locale locale : localizationSetter.getSupportedLocales()) {
MessageCatalogResource resource = new MessageCatalogResource(locale, messagesSource, resourceChangeTracker, compactJSON);
configuration.add("t5/core/messages/" + locale.toString(), new JavaScriptModuleConfiguration(resource));
}
}
use of org.apache.tapestry5.ioc.annotations.Symbol in project tapestry-5 by apache.
the class JavaScriptModule method setupModuleDispatchers.
@Contribute(Dispatcher.class)
@Primary
public static void setupModuleDispatchers(OrderedConfiguration<Dispatcher> configuration, ModuleManager moduleManager, OperationTracker tracker, ResourceStreamer resourceStreamer, PathConstructor pathConstructor, JavaScriptStackSource javaScriptStackSource, JavaScriptStackPathConstructor javaScriptStackPathConstructor, LocalizationSetter localizationSetter, @Symbol(SymbolConstants.MODULE_PATH_PREFIX) String modulePathPrefix, @Symbol(SymbolConstants.ASSET_PATH_PREFIX) String assetPathPrefix) {
configuration.add("Modules", new ModuleDispatcher(moduleManager, resourceStreamer, tracker, pathConstructor, javaScriptStackSource, javaScriptStackPathConstructor, localizationSetter, modulePathPrefix, assetPathPrefix, false), "after:Asset", "before:ComponentEvent");
configuration.add("ComnpressedModules", new ModuleDispatcher(moduleManager, resourceStreamer, tracker, pathConstructor, javaScriptStackSource, javaScriptStackPathConstructor, localizationSetter, modulePathPrefix, assetPathPrefix, true), "after:Modules", "before:ComponentEvent");
}
use of org.apache.tapestry5.ioc.annotations.Symbol in project tapestry-5 by apache.
the class TapestryModule method contributeRequestHandler.
/**
* Continues a number of filters into the RequestHandler service:
* <dl>
* <dt>StaticFiles</dt>
* <dd>Checks to see if the request is for an actual file, if so, returns true to let the servlet container process
* the request</dd>
* <dt>CheckForUpdates</dt>
* <dd>Periodically fires events that checks to see if the file system sources for any cached data has changed (see
* {@link org.apache.tapestry5.internal.services.CheckForUpdatesFilter}). Starting in 5.3, this filter will be null
* in production mode (it will only be active in development mode).
* <dt>ErrorFilter</dt>
* <dd>Catches request errors and lets the {@link org.apache.tapestry5.services.RequestExceptionHandler} handle them
* </dd>
* <dt>StoreIntoGlobals</dt>
* <dd>Stores the request and response into the {@link org.apache.tapestry5.http.services.RequestGlobals} service (this
* is repeated at the end of the pipeline, in case any filter substitutes the request or response).
* <dt>EndOfRequest</dt>
* <dd>Notifies internal services that the request has ended</dd>
* </dl>
*/
public void contributeRequestHandler(OrderedConfiguration<RequestFilter> configuration, Context context, @Symbol(TapestryHttpSymbolConstants.PRODUCTION_MODE) boolean productionMode) {
RequestFilter staticFilesFilter = new StaticFilesFilter(context);
RequestFilter storeIntoGlobals = new RequestFilter() {
public boolean service(Request request, Response response, RequestHandler handler) throws IOException {
requestGlobals.storeRequestResponse(request, response);
return handler.service(request, response);
}
};
RequestFilter fireEndOfRequestEvent = new RequestFilter() {
public boolean service(Request request, Response response, RequestHandler handler) throws IOException {
try {
return handler.service(request, response);
} finally {
endOfRequestEventHub.fire();
}
}
};
if (productionMode) {
configuration.add("CheckForUpdates", null, "before:*");
} else {
configuration.addInstance("CheckForUpdates", CheckForUpdatesFilter.class, "before:*");
}
configuration.add("StaticFiles", staticFilesFilter);
configuration.add("StoreIntoGlobals", storeIntoGlobals);
configuration.add("EndOfRequest", fireEndOfRequestEvent);
configuration.addInstance("ErrorFilter", RequestErrorFilter.class);
}
Aggregations