DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Coding
  3. Languages
  4. Turn a Java annotation into a CDI qualifier

Turn a Java annotation into a CDI qualifier

A. Programmer user avatar by
A. Programmer
·
Apr. 25, 11 · Interview
Like (0)
Save
Tweet
Share
5.90K Views

Join the DZone community and get the full member experience.

Join For Free

A CDI qualifier is an annotation that itself is annotated with the @javax.inject.Qualifier meta-annotation. Per example, if you add the @Qualifier to the MyAnnotation (http://e-blog-java.blogspot.com/2011/04/what-is-java-annotation.html) you obtain a CDI qualifier:

@Qualifier
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface MyAnnotation
{
// Property Definitions here.
}

CDI provide a set of built-in qualifiers:

Qualifier                         
 
 
Description
 
@javax.enterprise.inject.Named 
 
This qualifier is used to un-typed access from
non-Java code. Commonly this qualifier serves the
JSF pages that access beans through EL.
 
@javax.enterprise.inject.New 
 
This qualifier forces the creation of a new
instance, instead of using the contextual
instance. It allows us to obtain a dependent
object of a specified class.
 

@javax.enterprise.inject.Any
 
This qualifier “belongs” to all beans and 
injection points (not applicable when @New is
present). This is useful if you want to iterate
over all beans with a certain bean type.
 
@javax.enterprise.inject.Default
 
As the qualifier name suggests, whenever a bean
or injection point does not explicitly declare a
qualifier, the container assumes the qualifier
@Default.

 

From http://e-blog-java.blogspot.com/2011/04/turn-java-annotation-into-cdi-qualifier.html

CDI Annotation Java (programming language)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Best CI/CD Tools for DevOps: A Review of the Top 10
  • Introduction to Spring Cloud Kubernetes
  • REST vs. Messaging for Microservices
  • Create Spider Chart With ReactJS

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: