首页
随机
最近更改
特殊页面
社群首页
参数设置
关于WHY42
免责声明
WHY42
搜索
用户菜单
登录
欢迎来到Riguz的小站!这是一个私人wiki,用来记录一些我的笔记。
查看“︁Java:JSR330”︁的源代码
←
Java:JSR330
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
[https://jcp.org/en/jsr/detail?id=330 JSR330]定义了Java依赖注入的标准。主要提供了一系列的定义([http://docs.oracle.com/javaee/6/api/javax/inject/package-summary.html javax.inject.*]): *Provider<T> Provides instances of T. *Inject Identifies injectable constructors, methods, and fields. *Named String-based qualifier. *Qualifier Identifies qualifier annotations. *Scope Identifies scope annotations. *Singleton Identifies a type that the injector only instantiates once. =@Inject= see [https://dzone.com/articles/java-ee6-cdi-named-components this] post <source lang="java"> public interface Payment { void pay(BigDecimal amount); } public class CashPaymentImpl implements Payment { private static final Logger LOGGER = Logger.getLogger(CashPaymentImpl.class.toString()); @Override public void pay(BigDecimal amount) { LOGGER.log(Level.INFO, "payed {0} cash", amount.toString()); } } @Inject private Payment payment; </source> =@Named= =@Singleton= =@Qualifier= =@Scope= =Provider<T>= [[Category:Programe]]
返回
Java:JSR330
。