Search in sources :

Example 41 with Link

use of org.apache.tapestry5.http.Link in project tapestry-5 by apache.

the class TapestryModule method contributeDataTypeAnalyzer.

/**
 * <dl>
 * <dt>Annotation</dt>
 * <dd>Checks for {@link org.apache.tapestry5.beaneditor.DataType} annotation</dd>
 * <dt>Default (ordered last)</dt>
 * <dd>
 * {@link org.apache.tapestry5.commons.internal.services.DefaultDataTypeAnalyzer} service (
 * {@link #contributeDefaultDataTypeAnalyzer(org.apache.tapestry5.commons.MappedConfiguration)} )</dd>
 * </dl>
 */
public static void contributeDataTypeAnalyzer(OrderedConfiguration<DataTypeAnalyzer> configuration, @InjectService("DefaultDataTypeAnalyzer") DataTypeAnalyzer defaultDataTypeAnalyzer) {
    configuration.add("Annotation", new AnnotationDataTypeAnalyzer());
    configuration.add("Default", defaultDataTypeAnalyzer, "after:*");
}
Also used : AnnotationDataTypeAnalyzer(org.apache.tapestry5.commons.internal.services.AnnotationDataTypeAnalyzer)

Example 42 with Link

use of org.apache.tapestry5.http.Link 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)

Example 43 with Link

use of org.apache.tapestry5.http.Link in project tapestry-5 by apache.

the class TapestryModule method contributeObjectRenderer.

/**
 * Contributes a default object renderer for type Object, plus specialized
 * renderers for {@link org.apache.tapestry5.http.services.Request}, {@link org.apache.tapestry5.commons.Location},
 * {@link org.apache.tapestry5.ComponentResources}, {@link org.apache.tapestry5.EventContext},
 * {@link AvailableValues},
 * List, and Object[].
 */
@SuppressWarnings("unchecked")
public void contributeObjectRenderer(MappedConfiguration<Class, ObjectRenderer> configuration, @InjectService("LocationRenderer") ObjectRenderer locationRenderer, final TypeCoercer typeCoercer) {
    configuration.add(Object.class, new DefaultObjectRenderer());
    configuration.addInstance(Request.class, RequestRenderer.class);
    configuration.add(Location.class, locationRenderer);
    ObjectRenderer preformatted = new ObjectRenderer<Object>() {

        public void render(Object object, MarkupWriter writer) {
            writer.element("pre");
            writer.write(typeCoercer.coerce(object, String.class));
            writer.end();
        }
    };
    configuration.addInstance(List.class, ListRenderer.class);
    configuration.addInstance(Object[].class, ObjectArrayRenderer.class);
    configuration.addInstance(ComponentResources.class, ComponentResourcesRenderer.class);
    configuration.addInstance(EventContext.class, EventContextRenderer.class);
    configuration.add(AvailableValues.class, new AvailableValuesRenderer());
}
Also used : AvailableValuesRenderer(org.apache.tapestry5.internal.renderers.AvailableValuesRenderer) ObjectRenderer(org.apache.tapestry5.services.ObjectRenderer) DefaultObjectRenderer(org.apache.tapestry5.services.DefaultObjectRenderer) DefaultObjectRenderer(org.apache.tapestry5.services.DefaultObjectRenderer) JSONObject(org.apache.tapestry5.json.JSONObject) MarkupWriter(org.apache.tapestry5.MarkupWriter)

Example 44 with Link

use of org.apache.tapestry5.http.Link in project tapestry-5 by apache.

the class TapestryModule method contributeMetaWorker.

/**
 * Contributes extractors for {@link Meta}, {@link Secure}, {@link ContentType} and {@link WhitelistAccessOnly} annotations.
 *
 * @since 5.2.0
 */
@SuppressWarnings("unchecked")
public static void contributeMetaWorker(MappedConfiguration<Class, MetaDataExtractor> configuration) {
    configuration.addInstance(Meta.class, MetaAnnotationExtractor.class);
    configuration.add(Secure.class, new FixedExtractor(MetaDataConstants.SECURE_PAGE));
    configuration.addInstance(ContentType.class, ContentTypeExtractor.class);
    configuration.add(WhitelistAccessOnly.class, new FixedExtractor(MetaDataConstants.WHITELIST_ONLY_PAGE));
    configuration.addInstance(UnknownActivationContextCheck.class, UnknownActivationContextExtractor.class);
}
Also used : FixedExtractor(org.apache.tapestry5.services.meta.FixedExtractor)

Example 45 with Link

use of org.apache.tapestry5.http.Link in project tapestry-5 by apache.

the class TapestryModule method contributeComponentTemplateLocator.

/**
 * Contributes two template locators:
 * <dl>
 * <dt>Default</dt>
 * <dd>Searches for the template on the classpath ({@link DefaultTemplateLocator}</dd>
 * <dt>Page</dt>
 * <dd>Searches for <em>page</em> templates in the context ({@link PageTemplateLocator})</dd>
 * </dl>
 *
 * @since 5.2.0
 */
public static void contributeComponentTemplateLocator(OrderedConfiguration<ComponentTemplateLocator> configuration, @ContextProvider AssetFactory contextAssetFactory, @Symbol(SymbolConstants.APPLICATION_FOLDER) String applicationFolder, ComponentClassResolver componentClassResolver) {
    configuration.add("Default", new DefaultTemplateLocator());
    configuration.add("Page", new PageTemplateLocator(contextAssetFactory.getRootResource(), componentClassResolver, applicationFolder));
}
Also used : PageTemplateLocator(org.apache.tapestry5.internal.services.templates.PageTemplateLocator) DefaultTemplateLocator(org.apache.tapestry5.internal.services.templates.DefaultTemplateLocator)

Aggregations

Link (org.apache.tapestry5.http.Link)66 Test (org.testng.annotations.Test)37 Response (org.apache.tapestry5.http.services.Response)19 MarkupWriter (org.apache.tapestry5.MarkupWriter)10 JSONObject (org.apache.tapestry5.json.JSONObject)10 ComponentEventLinkEncoder (org.apache.tapestry5.services.ComponentEventLinkEncoder)10 Request (org.apache.tapestry5.http.services.Request)8 PageRenderRequestParameters (org.apache.tapestry5.services.PageRenderRequestParameters)8 Element (org.apache.tapestry5.dom.Element)7 Contribute (org.apache.tapestry5.ioc.annotations.Contribute)7 Link (org.apache.tapestry5.Link)6 LinkCreationListener2 (org.apache.tapestry5.services.LinkCreationListener2)6 EventContext (org.apache.tapestry5.EventContext)5 ComponentClassResolver (org.apache.tapestry5.services.ComponentClassResolver)5 IOException (java.io.IOException)4 TapestryException (org.apache.tapestry5.commons.internal.util.TapestryException)4 BaseURLSource (org.apache.tapestry5.http.services.BaseURLSource)4 Page (org.apache.tapestry5.internal.structure.Page)4 List (java.util.List)3 ComponentResources (org.apache.tapestry5.ComponentResources)3