|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |
@Documented @Retention(value=RUNTIME) @Target(value=ANNOTATION_TYPE) public @interface Qualifier
Custom binding annotations are marked with @Qualifier as a meta-annotation.
package example;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.Runtime;
import java.lang.annotation.*;
import javax.inject.Qualifier;
@Qualifier
@Documented
Target({TYPE, METHOD, FIELD, PARAMETER})
Retention(RUNTIME)
public @interface MyBinding {
}
package example;
import example.MyBinding;
import javax.servlet.*;
import java.io.*;
public class MyServlet extends GenericServlet {
@MyBinding MyBean _bean;
public void service(ServletRequest req, ServletResponse res)
throws IOException
{
PrintWriter out = res.getWriter();
out.println("my-bean: " + _bean);
}
}
<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:example="urn:java:example">
<example:MyBean>
<example:MyQualifier/>
</example:MyBean>
</beans>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |