Extensions for CDI

The JSRs 299/330 are pretty interesting as they offer a nice way to use its flexible structure to easily add new features. For instance inside of the Apache implementation (Apache OpenWebBeans) there is already some extension that adds decent support for the JSF2.0 @ViewScoped annotation. The commit shows that the implementation of this wasn’t that of a big deal.

The Apache MyFaces and Apache OWB communities put together a wiki page to discuss more extensions. The endresult of this effort will be (most-likely) a new subproject of the “Apache MyFaces Extension” project. Note: This project currently hosts ExtVal (Validation-Framework) and ExtScripting (support for dynamic languages, such as Groovy).

299/330 offers a nice tool to also create convenience annotations. One of them, the @Model, is already part of the CDI offerings. This annotation basically combines the @Named and @RequestScoped annotations. Something like that can be done for different scopes, such as @ApplicationScoped, @SessionScoped or @ViewScoped.

This is pretty trival:

package net.wessendorf.enterprise.inject;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import javax.enterprise.context.SessionScoped;
import javax.enterprise.inject.Stereotype;
import javax.inject.Named;

@Target( { TYPE, METHOD, FIELD })
public @interface SessionModel

Put stuff like that into a tiny little JAR and reuse it on all your project; Simple and fast done!

On your beans this particular annotation goes along like this:

package net.wessendorf.facesgoodies;

import java.io.Serializable;

import net.wessendorf.enterprise.inject.SessionModel;

public class SomeRandomBean implements Serializable

So get a change to checkout Apache OWB and give it a shot! Pretty good implementation, so far!



Posted in apache, ejb, fun, java, jsf, myfaces, seam, WebBeans

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

January 2010
« Dec   Feb »
%d bloggers like this: