Announcement Announcement Module
Collapse
No announcement yet.
JSR annotation equivalent of @Qualifier? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    @Resource is basically a merger between @Autowired and @Qualifier (you can/must speficy a name).

    Comment


    • #3
      Thanks! That works perfectly.

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

      Comment

      Working...
      X