Much change is occurring in the Java and Java EE ecosystems, yet, the Servlet specification - one of the oldest components of Java EE - has received little attention.
Rewrite by OCPsoft is an innovative, rule-based HTTP framework that puts a fresh spin on the Servlet programming model. Rules can add/modify/or delete any part of the HTTP request and response flowing in and out of a Servlet container, and at the same time you are guided through established best practices and techniques.
Rewrite delivers what no other Servlet Filter has offered before: type-safe, extensible control of your application's implicit HTTP objects. This control is expressed using a fluent API and supported by a programming model for manipulating the request-response lifecycle; you can create and re-use validators, converters and configuration objects to secure, modify, or dynamically react to HTTP requests in your Servlet (or web-framework enhanced) applications.
The Rewrite Framework has advanced significantly since the last release version, and continues to bring innovation to the Servlet environment with its 2.0.0.Final release.
* Response Content Interceptors - allow full modification of outbound HTML (or Response) content.
* Response Stream Wrappers - enable application of compression, filtering, and extremely performant content filtering and logging.
* Fully safe Configuration system - Rules are now protected from ordering issues, referenced parameters that do not exist, or definitions that will cause security and privacy incidents in production.
* Support for Servlet 2.5 - This release of Rewrite increases the range of support by adding backwards compatibility for Servlet 2.5 environments, in addition to the already supported Servlet 3.0 specification.
* PrettyFaces support - existing PrettyFaces users may migrate to Rewrite using the "rewrite-config-prettyfaces" drop-in extension.
* Standard Parameter Configuration - Rewrite configuration parameters are now unique, one-per-rule objects that reduce complexity of previously tedious Rule construction.
* Structured Configuration API - enforces that Rules, Conditions, Operations, and parameter configurations are always performed in the same order, increasing readability and familiarity of configuration.
Rewrite enables you to perform everything from simple URL-rewriting to request processing; it has even been used to implement REST web-services as a proof of concept. It’s the multi-tool in your web-technology back pocket.
Rewrite is a completely extensible and modular framework; all of the internal rules and primitives are built using the same APIs that users use to extend and add functionality, and if you don’t like the way that piece of the core framework is doing its job then you can simply replace it with your own implementation of the API. If you want to integrate a technology, there are many avenues ranging from direct configuration to service enrichment (i.e., AOP). Enrichers can enhance, wrap, or extend any service class as it is loaded, whether that service is built-in or custom made.
You can even write your own annotations to streamline configuration. Either aggregate existing annotations; or, using the AnnotationHandler API, create an annotation class, and a handler class to define behavior. Once this is complete, you have abstracted away any and all programmatic configuration. These custom annotations can then be re-used throughout the entire application. Want to call a method if the HTTP request comes from a mobile client? Use your imagination; write an annotation - it’s just a single class away.
As an added bonus, performance evaluations of the framework - even with a configuration of over 300 rules (all of which were evaluated) - put overhead of the framework in the microsecond range. This means that the overhead is practically immeasurable compared to the Servlet container itself (0.002% overhead on average for 10000 parallel requests displaying a static HTML page).
The exceptional performance of Rewrite can be attributed to the fact that all rules are built, validated, and cached when the application starts up, and are stored as a Java object graph. (During development, rules can be re-built on every request to enable more rapid programming via hot-swap or runtime code-replacement.)
Rewrite brings new life to the Servlet programming model by introducing dynamic rules to the way we interact with the Request/Response lifecycle in all aspects of HTTP. No longer are we tied to the entire static Servlet interface, or even the interfaces of the frameworks we are using, but have liberty to interact with as few or as many facets of HTTP as are needed for a specific use-case.
Rewrite is not just limited to the native Servlet API. It’s already patching holes in existing web frameworks; we expect it to be a staple in every application in the near future. There are already integration modules - on top of the basic Servlet integration - for Apache Shiro Security, JAAS security, JavaServer Faces, Google Web Toolkit, and Oracle ADF Faces, with configuration integration for CDI, Spring, JodaTime (for time based rules,) and others; you can mix and match features from all of these great libraries with ease.
Want to use a Content Distribution Network (CDN) to host your web-resources in production, but use local resources during development? Rewrite makes that easy. Want to use Spring security and Shiro security together in your application? Rewrite makes that easy. Want to use JAAS security to secure application URLs for only a certain set of domains, ports, or headers using JBoss Drools? Rewrite makes that easy. This is truly an innovative framework that brings power back to the Java web developer in a very light-weight extensible, and modular framework.
Rewrite lets you
.defineRule().when(YouAre.stuck()).thenPerform(Simple.solution()), and if you are not exactly sure what this power toy does, that’s because it does a little bit of everything, and stays out of your way for everything else.
“Rewrite your requests. Rewrite your imagination.”
Learn more at http://ocpsoft.org/rewrite