@javax.inject.Inject,新的注入依赖规范

Announcing @javax.inject.Inject

 
I'm proud to announce a  new dependency injection specification backed by both Google Guice and Spring. You can catch  the official announcement over on the Google Code Blog:

 

Five years ago, Spring 1.0 brought Java dependency injection into the mainstream. Three years later, Google Guice 1.0 introduced annotation-based dependency injection and made Java programming a little easier. Since then, developers have had to choose between a) writing external configuration or b) importing vendor-specific annotations.

Today, we hope to give developers the best of both worlds. Google Guice and SpringSource have partnered to standardize a proven, non-controversial set of annotations that make injectable classesportable across frameworks. At the moment, the set of specified annotations consists of:

  • @Inject - Identifies injectable constructors, methods, and fields
  • @Qualifier - Identifies qualifier annotations
  • @Scope - Identifies scope annotations
  • @Named - String-based qualifier
  • @Singleton - Identifies a type that the injector only instantiates once
One additional interface is specified for use in conjunction with these annotations:
  • Provider - Provides instances of a type T. For any type T that can be injected, you can also inject Provider.
You can check out an early draft of the  specification. We deliberately left external dependency configuration out, so as not to quash ongoing innovation. We haven't formally submitted this standard to the JCP yet, but we plan to do so shortly. Standards wonks can read a draft of our JSR proposal.

The expert group will be inclusive and will work in the open. For example, our mailing list is publicly readable, and we host the specification at Google Code. Several industry players have already expressed interest in supporting this effort. Contact us if you'd like to help out.

This specification will address the last shortcoming of annotation-based dependency injection. You no longer have to import vendor-specific annotations.

Our hope is that this specification will not only improve interoperability between existing dependency injection frameworks and unify the Java community, but it will also lower the barrier to entry for new injector implementations and foster even more innovation in this space.

I'd like to thank Paul Hammant, Doug Lea, Tim Peierls, James Strachan, Hani Suleiman, and Jason van Zyl for their early reviews and official support. Special thanks goes to our partner in this endeavor SpringSource, especially Rod Johnson, and my fellow Googlers and Guicers Josh Bloch, Jesse Wilson, Kevin Bourrillion, and Dhanji Prasanna.

 

@javax.inject.Inject,一个新的注入依赖规范,既能支持Google Gucie,还能支持Spring。你可以在Google Code的博客上查看官方发布:

五年前,Spring 1.0将依赖注入带入主流。三年后,Google Guice 1.0推出了基于annotation的依赖注入,这使得Java编程变得更轻松。从此之后,开发者只能有两种选择:a)编写外部配置 b)导入vendor-specific 说明

今天,我们为开发者提供了一个两全其美的选择。Google Gucie和SpringSource已经建立了合作的关系,让注入类在框架中的使用更加简便。

具体说明如下:

    * @Inject - Identifies injectable constructors, methods, and fields
    * @Qualifier - Identifies qualifier annotations
    * @Scope - Identifies scope annotations
    * @Named - String-based qualifier
    * @Singleton - Identifies a type that the injector only instantiates once

 

你可能感兴趣的:(java,ssh)