Search in sources :

Example 1 with Symbol

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.");
    }
}
Also used : PersistentLocale(org.apache.tapestry5.services.PersistentLocale) PerthreadManagerImpl(org.apache.tapestry5.ioc.internal.services.PerthreadManagerImpl) Test(org.testng.annotations.Test)

Example 2 with 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;
}
Also used : MongoDBImpl(org.apache.tapestry5.internal.mongodb.MongoDBImpl) Scope(org.apache.tapestry5.ioc.annotations.Scope)

Example 3 with Symbol

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));
    }
}
Also used : Locale(java.util.Locale) MessageCatalogResource(org.apache.tapestry5.internal.util.MessageCatalogResource) JavaScriptModuleConfiguration(org.apache.tapestry5.services.javascript.JavaScriptModuleConfiguration) Contribute(org.apache.tapestry5.ioc.annotations.Contribute)

Example 4 with Symbol

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");
}
Also used : ModuleDispatcher(org.apache.tapestry5.internal.services.javascript.ModuleDispatcher) Primary(org.apache.tapestry5.ioc.annotations.Primary) Contribute(org.apache.tapestry5.ioc.annotations.Contribute)

Example 5 with Symbol

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);
}
Also used : StreamResponse(org.apache.tapestry5.StreamResponse) Response(org.apache.tapestry5.http.services.Response) ComponentEventRequestHandler(org.apache.tapestry5.services.ComponentEventRequestHandler) RequestHandler(org.apache.tapestry5.http.services.RequestHandler) ComponentRequestHandler(org.apache.tapestry5.services.ComponentRequestHandler) PageRenderRequestHandler(org.apache.tapestry5.services.PageRenderRequestHandler) Request(org.apache.tapestry5.http.services.Request) HttpServletRequestFilter(org.apache.tapestry5.http.services.HttpServletRequestFilter) ComponentRequestFilter(org.apache.tapestry5.services.ComponentRequestFilter) PageRenderRequestFilter(org.apache.tapestry5.services.PageRenderRequestFilter) RequestFilter(org.apache.tapestry5.http.services.RequestFilter) ComponentEventRequestFilter(org.apache.tapestry5.services.ComponentEventRequestFilter)

Aggregations

Contribute (org.apache.tapestry5.ioc.annotations.Contribute)7 EntityManagerFactory (javax.persistence.EntityManagerFactory)2 Metamodel (javax.persistence.metamodel.Metamodel)2 PersistenceUnitInfo (javax.persistence.spi.PersistenceUnitInfo)2 HttpServletRequestFilter (org.apache.tapestry5.http.services.HttpServletRequestFilter)2 ValueEncoderFactory (org.apache.tapestry5.services.ValueEncoderFactory)2 IFn (clojure.lang.IFn)1 Symbol (clojure.lang.Symbol)1 Method (java.lang.reflect.Method)1 Locale (java.util.Locale)1 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)1 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1 EntityType (javax.persistence.metamodel.EntityType)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 MarkupWriter (org.apache.tapestry5.MarkupWriter)1 StreamResponse (org.apache.tapestry5.StreamResponse)1 ValidationDecorator (org.apache.tapestry5.ValidationDecorator)1 FunctionName (org.apache.tapestry5.clojure.FunctionName)1 Namespace (org.apache.tapestry5.clojure.Namespace)1