Results 1 to 3 of 3

Thread: JSR annotation equivalent of @Qualifier?

  1. #1

    Default JSR annotation equivalent of @Qualifier?

    Hi,

    I was using Spring Autowire annotations in a class that I have to repackage outside my application and make framework agnostic. Consequently, I can no longer use Spring specific annotations. So instead, I was hoping to use JSR annotations instead.

    For the most part, replacing @Autowired with @Inject works fine. However, I do have a case where I have an @Qualifier(<bean_name>) to help determine which bean definition is to be injected.

    Ex:
    Code:
    	// System configuration
    	@Autowired
    	@Qualifier("systemConfiguration")
    	private Configuration configuration;
    I've looked for docs as to what the equivalent is in JSR annotations, but cannot seem to find anything of value.

    Does anyone know the equivalent way of writing this with JSR annotations instead?

    Thanks,

    Eric

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    @Resource is basically a merger between @Autowired and @Qualifier (you can/must speficy a name).
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3

    Default

    Thanks! That works perfectly.

    Ex:
    Code:
    	/**
    	 * System configuration
    	 */
    	@Resource(name="systemConfiguration")
    	private Configuration configuration;
    Eric

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •