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:*");
}
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);
}
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());
}
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);
}
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));
}
Aggregations