`

@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 ourJSR 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

 

分享到:
评论

相关推荐

    javax.inject.Provider

    Spring 依赖的 javax.inject.Provider

    javax-inject-1.0-201002241208.jar.zip

    javax.inject通常与实现JSR 330规范的依赖注入容器一起使用,如Google的Guice、Spring框架的Spring Core模块等。这些容器负责解析注解并处理依赖关系,从而简化了对象的创建和管理。 四、总结 javax.inject提供的...

    .javax.inject_1.0.0.jar

    javax.inject_1.0.0.jar是Java依赖注入规范的一个实现,它是Java EE 6及后续版本中的核心组件之一。这个库提供了标准的注解和接口,使得开发者能够更加灵活地管理对象间的依赖关系。 首先,我们要明确什么是依赖...

    javax.inject-1.jar

    支持注入,spring ,类别注入,很好用的jar包,还有原码和文档

    官方jar包javax-inject.jar

    7. **优势**:使用`javax-inject.jar`进行依赖注入,可以使代码更加清晰、简洁,减少硬编码,增强代码的可读性和可维护性,同时便于单元测试,因为测试时可以更容易地替换或模拟依赖。 8. **使用方法**:在Java项目...

    javax.enterprise.inject.spi.BeanManagerjar包

    javax.enterprise.inject.spi.BeanManager jar文件,jboss用到了,但是很烦,是javaee6 的东西,历经千辛万苦找到的

    javax.inject.jar

    javax.inject.jar java 开发技术要用到,打包分享给大家,需要的下载学习哈!

    javax-inject.jar.zip

    `javax.inject.Inject`注解是最核心的注解,它用于标注一个构造函数、字段或方法,表明这个构造函数、字段或方法的依赖应该由外部容器(如Google Guice、Spring框架等)自动注入,而不是由类自己创建。通过这种方式...

    javax-inject-1.0.jar

    javax 注解依赖包

    com.springsource.javax.inject-0.9.0.PFD.jar

    jar包,官方版本,自测可用

    guava、javax.inject-1、jsr305-3.0.1 jar包

    javax.inject是Java注射(Dependency Injection,DI)规范的一部分,它定义了一些标准注解,如`@Inject`、`@Singleton`等,用于标记依赖关系和管理对象生命周期。通过DI,开发者可以将对象的创建和依赖关系的维护从...

    com.springsource.javax.inject-1.0.0.jar

    com.springsource.javax.inject-1.0.0.jar

    com.springsource.javax.inject_1.0.0.jar

    jar包,官方版本,自测可用

    javax.enterprise.context.jar

    CDI通过注解如`@Inject`,`@Named`等,使得依赖注入变得简单易用。 **cdi-api.jar**: `cdi-api.jar`是CDI规范的API接口定义,包含了所有CDI相关的接口和注解,比如`@Inject`、`@Named`、`@Scope`、`@Qualifier`等...

    inject:围绕javax.inject批注的简单Kotlin多平台抽象

    注入 围绕注释的简单Kotlin多平台抽象。 这允许在Kotlin通用代码中使用注释,以便特定于平台的注释处理器可以注册它们。 有关该库的更多信息,请参阅的博客文章,该文章在《 Android Weekly》期中有介绍。 该还...

    javax.annotation-3.1.2.2-sources.jar.zip

    @Inject注解允许开发人员声明依赖注入,而无需指定注入的来源,这在某些情况下比@Resource更灵活。 6. @NotNull:这个注解通常用于参数验证,表明该参数不能为null。在Java EE 6及以上版本中,这个注解可以配合Bean...

    javax.annotation.rar

    5. `@Inject`: 来自JSR 330,提供依赖注入的能力,使得对象间的依赖关系可以通过注解来声明,而不是硬编码。 6. `@ApplicationScoped`, `@SessionScoped`, `@RequestScoped`: 这些注解用于定义bean的作用域,分别...

    javax.inject-2.1.88.jar

    java运行依赖jar包

Global site tag (gtag.js) - Google Analytics