Nov 18th, 2006, 06:44 PM
SpringContracts - Design by Contract for Spring
After nearly one year of development, SpringContracts is out and now Open Source on SourceForge (http://springcontracts.sourceforge.net/home.html).
SpringContracts is a configurable Java solution for Design by Contract, which fits seamlessly into the Spring framework.
It allows the notation of Preconditions, Postconditions and Invariants to Interfaces and classes by Annotations.
For example, SpringContracts allows to configure (via ApplicationContext) which parts of a Contract (Pre-, Postcondition, Invariant) should be recognized at runtime and how to react, when Violations occur (exceptions, logging, ...).
Another pluggable Module is the language, used to describe the single constraints of Pre-, Postconditions and Invariants. While providing a default implementation, based on the Expression Language (Commons-EL) with Extensions for first order logic (all quator, exist quantor, implications), there will be the choice to use other Languages like MVEL, OGNL or another Scripting Language (for example Groovy or JRuby) as 'plug-ins' in the next future.
Some minor features include full support (recognition of Contract elements) for deep inheritance and multi-inheritance on interfaces, definition of messages in case of contract violations with reference to it's context (called class / method, args, return value) and usage of named constraints (configurable, global available (i.e. domain specific) constraints, which can be referenced and instantiated in a specific context within any Pre-, Postcondition, invariant by a symbolic name).
Next steps will bring support for MVEL and OGNL as constraint language, a ContractAttributeSource for defining Contracts in a reusable, declarative way in an ApplicationContext (as an alternative to Annotations) and a NameSpaceHandler for compact and easy configuration.
By now, you can fetch the sources and all unit tests from SourceForge. A more detailed Documentation and binaries will follow in the next days.
If you like to support further development or give any kind of comments - any kind of feedback is highly appreciated!
Last edited by magle; Nov 26th, 2006 at 06:02 PM.
Nov 26th, 2006, 06:19 PM
Release 0.2 is availible
SpringContracts Rel. 0.2 is now available for download at http://sourceforge.net/projects/springcontracts.
The release comes with full support for external contract definitions (inside Spring's ApplicationContext) without touching the Sources using Annotations.
Further on, SpringContracts now supports OGNL and Groovy as alternative specification languages. Switching the language is a matter of configuration.
The current dev branch includes support for contract validation of objects, which are created outside Spring's ApplicationContext (i.e. ad hoc instantiations of domain objects or object creation by ORM tools) due to the usage of Load Time Weaving (LTW) with AspectJ-AOP, while configuration of SpringContracts remains inside Spring's ApplicationContext.
Using LTW also gives support for contract validation for constructors.
More information, including a quick start document with first steps for writing your first constract can be found at the project homepage under http://springcontracts.sourceforge.net.