CanDI (JSR-299) binding pattern tutorial
I’ve put together a CanDI binding pattern tutorial (pdf) for four major binding patterns: services, resources, startup, and plugin/extensions.
Focusing on common CanDI patterns should show how CanDI is used in full applications like SubEtha maillist manager, and avoid the temptation to focus on complicated features that only 1% of applications would ever need.
In the tutorial, the key CanDI classes are:
- @Current - the service and unique bean binding annotation.
- @BindingType - the resource custom binding annotation used for declarative injection.
- Instance<T> - the extension/plugin iterator and programmatic bean factor.
- @Any - the special annotation for extension/plugin matching of any registered beans

June 28th, 2009 at 10:36 am
There is a tiny mistake in your pdf… under the heading “Plugin/Extension Pattern CanDI classes”, it mentions @All instead of @Any
June 28th, 2009 at 10:39 am
“Any CanDI bean with a @Named annotation automatically becomes available to EL
expressions as follows: ${myService.message}”
Just curious, what if there is a naming conflict? For example someone does a ?
June 28th, 2009 at 10:40 am
Darn, my example was stripped out.
<c:set var=”myService” value=”foo” />
June 29th, 2009 at 12:09 pm
Thanks. I’ve changed the text (it’ll be updated on the site in a day or so.)
For EL, if there’s a conflict, the EL will throw an exception when it’s evaluated, according to the spec. (I need to check if Resin’s properly handling that case.)