Utilities for Restlet
If you are a Restlet Java programmer, Prudence may still be of use to you. The Prudence standalone Jar has several well-documented classes useful for any Restlet application. They're all in the "com.threecrickets.prudence.util" package, and introduced below.
We wish these general-purpose utilities existed in the standard Restlet library!
- CacheControlFilter: A Filter that adds cache control directives to responses. Great for wrapping around a Directory.
- CorsFilter: A Filter that add Cross-Origin Resource Sharing (CORS) response headers.
- CustomEncoder: A more localized alternative to using the EncoderService. Place it as a Filter before any restlet.
- ForwardedFilter: A Filter that applies the X-Forwarded-Proto, X-Forwarded-Host, and X-Forwarded-Port HTTP headers to the request's references.
- Injector: A Filter that adds values to the request attributes before moving to the next restlet. It allows for a straightforward implementation of IoC (Inversion of Control). Automatically supports casting of Template instances.
- StatusRestlet: A restlet that always sets a specific status and does nothing else.
- VirtualHostInjector: A Filter that sets the virtual host as a request attribute.
These classes add no new functionality, but make working with some client data a bit easier.
- CompressedStringRepresentation: This is a ByteArrayRepresentation that can be constructed using text and an encoding, which it then compresses into bytes according the encoding. This is an alternative to using an Encoder filter, allowing you direct control over and access to the final representation.
- ConversationCookie: A modifiable extension of a regular Cookie. Tracks modifications, and upon calling save() stores them as a CookieSetting, likely in the Response. Also supports cookie deletion via remove().
- FormWithFiles: A form that can parse MediaType.MULTIPART_FORM_DATA entities by accepting file uploads. Files will appear as parameters of type FileParameter.
- InternalRepresentation: A representation used to transfer internal objects. Uses a custom "application/internal" media type.
Restlet's server-side redirection works by creating a new request. Unfortunately, this means that some information from the original request is lost. Prudence includes a set of classes that work together to preserve the original URI, which we here call the "captured" URI.
- CapturingRedirector: A Redirector that keeps track of the "captured" (original) reference.
- NormalizingRedirector: A Redirector that normalizes relative paths. This may be unnecessary in future versions of Restlet: see Restlet issue 238.
"Fallback" is a powerful new routing paradigm introduced in Prudence that lets you attach multiple restlets to a single route.
- Fallback: A restlet that delegates Restlet.handle(Request, Response) to a series of targets in sequence, stopping at the first target that satisfies the condition of wasHandled. This is very useful for allowing multiple restlets a chance to handle a request, while "falling back" to subsequent restlets when those "fail."
- FallbackRouter: A Router that takes care to bunch identical routes under Fallback restlets.
Restlet does not provide an easy way to use different template variable resolver instances (see Restlet issue 798 for more information). We've created new implementations of a few of the core classes that let you choose which resolver to use.
- ResolvingTemplate: A Template that allows control over which Resolver instances it will use.
- ResolvingRedirector: A Redirector that uses ResolvingTemplate. It also allows another useful feature: turning off the cleaning of headers during server-side redirections.
- ResolvingRouter: A Router that uses ResolvingTemplate for all routes.
A set of Filter classes for web technologies.
- CssUnifyMinifyFilter: Automatically unifies and/or compresses CSS source files, saving them as a single file. Unifying them allows clients to retrieve the CSS via one request rather than many. Compressing them makes their retrieval faster. Compression is done via CSSMin.
- LessFilter: Automatically parses LESS code and renders CSS using the Less4j library. Also supports minifying files, if the ".min.css" extension is used.
- ZussFilter: Automatically parses ZUSS code and renders CSS. Also supports minifying files, if the ".min.css" extension is used.
- CustomAuthenticatorHelper: Makes it easy to register custom authentication schemes.
- EnhancedCallResolver: Improves on the default Restlet CallResolver.
The Prudence Manual is provided for you under the terms of the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. The complete manual is available for download as a PDF.