Tuesday, May 15, 2012

@Nonbinding

I experiment recently a lot with CDI and one point I stumbled upon were the return values of my annotation functions.
Consider an annotation like this:

@Qualifier
@Retention(...)
@Target(...)
public @interface MyInterface{
 String value();
}

I tried to combine this annotation with a producer method and to use the value in the method (by asking the InjectionPoint for its value). Every time my Eclipse tried to deploy the .war it showed me an error.
After a while I found out that the only way to evade this, is to use the annotation @Nonbindung.
The altered annotation looks like this:

@Qualifier
@Retention(...)
@Target(...)
public @interface MyInterface{
 @Nonbinding
 String value();
}


Maybe I didn't read the spec good enough, but it took me a while to find that out.
So I hope you guys won't have the same problem like me ;)

0 comments:

Post a Comment

 

Copyright @ 2013 Wrong tracks of a developer.

Designed by Templateiy