Sunday, September 6, 2009

myfaces-extval java-config extension with gooogle guice style

why you might need this add-on

there are many different approaches to configure myfaces-extval.
out-of-the-box it uses zero configuration (convention over configuration) as well as an optional java-api which is mainly for internal usages and add-on developers.

so os890 provides an annotation based config add-on. so you don't have to learn the name conventions and the result is typesafe.

the disadvantage is that classpath scanning is required. you can specify packages to be scanned. anyway, it uses an external lib which performs the classpath scanning.

that's the reason for creating an additional add-on which is typesafe and doesn't use an external lib. as mentioned before extval provides an api and a generic artifact mapping mechanism which is used mainly for internal purposes. you can see the usage in the source-code of some add-ons. anyway, app-developers who don't like conventions need a simple but powerful api which is available for the common artifacts.

google guice provides a nice api to bundle modules. so the api of the add-on is similar to the style of google guice. that means you build modules and register the modules you would like to use.

the usage
first you implement a module. in a module you register global artifacts or you bind together a validation strategy with one or more of the following artifacts: constraint, message resolver, meta data transformer.

the following example shows both:

you just have to add your global artifacts or bind together artifacts which have a relationship. so you see that the syntax is quite easy.

via an extval startup listener you can register one or more modules easily.

the result
it's typesafe, explicit, flexible without external dependency and easy to use.
it's available at

a working example is available at: