Monday, April 25, 2011

@Inject inside Servlet Filter

I wanted to apply the Namespace pattern that is suggested in the Google App Engine documentation, with a CDI application (Weld implementation of JSR-299).

Since I wanted to user to choose an application during login, I needed to keep the namespace at a session bean. Since GAE is not an EE container (yet...), rather than a servlet container, I needed a different mechanizm to inject beans. I found this piece of code which came real helpful at DominikDorn.com, and created the following GaeCdiFilter abstract class:


During init(), the following abstract class get a BeanManager instance from the Servlet Context. Then it scans itself during init(), and instancing by injection each field that is annotated with @Inject.

@PostConstruct and @PreDestroy are not supported here, but it can be easily implemented as well. To use it - just extend GaeCdiFilter. If you need to override init(), don't forget to call its super (otherwise the whole thing won't work!)

Wednesday, April 13, 2011

Gson 1.7 is out, but...

Google has announced Gson 1.7 library is out few hours ago (Gson is a Java library to convert JSON to Java objects and vice-versa).

But, seems the wrong jar was uploaded into maven central repository - downloading com.google.code.gson:gson:1.7 yields the javadoc file, instead of the library itself.

I've created a issue report in the code site, and I hope this would get fixed soon enough.


File size is the same:

SHA1 for jar file:

SHA1 for javadoc file: