论Injection的前世今生
- why
Java EE provides injection mechanisms that enable your objects to obtain references to resources and other dependencies without having to instantiate them directly. You declare the required resources and other dependencies in your classes by decorating fields or methods with one of the annotations that mark the field as an injection point. The container then provides the required instances at runtime. Injection simplifies your code and decouples it from the implementations of its dependencies.
Java EE提供了注入机制,使您的对象能够获取对资源和其他依赖项的引用,而无需直接实例化它们。 通过使用将字段标记为注入点的注释之一来装饰字段或方法,可以在类中声明所需的资源和其他依赖项。 然后容器在运行时提供所需的实例。 注入简化了代码并将其与依赖项的实现分离。
- classfication
Resource injection enables you to inject any resource available in the JNDI namespace into any container-managed object, such as a servlet, an enterprise bean, or a managed bean. For example, you can use resource injection to inject data sources, connectors, or custom resources available in the JNDI namespace.
The type you use for the reference to the injected instance is usually an interface, which decouples your code from the implementation of the resource.
通过资源注入,您可以将JNDI名称空间中可用的任何资源注入任何容器管理的对象,例如servlet,企业bean或托管bean。 例如,您可以使用资源注入来注入JNDI名称空间中可用的数据源,连接器或自定义资源。 用于引用注入实例的类型通常是一个接口,它将您的代码与资源的实现分离。
Dependency injection enables you to turn regular Java classes into managed objects and to inject them into any other managed object. Using dependency injection, your code can declare dependencies on any managed object. The container automatically provides instances of these dependencies at the injection points at runtime, and it also manages the lifecycle of these instances for you.
Dependency injection in Java EE defines scopes, which determine the lifecycle of the objects that the container instantiates and injects. For example, a managed object that is only needed to respond to a single client request (such as a currency converter) has a different scope than a managed object that is needed to process multiple client requests within a session (such as a shopping cart).
依赖注入使您可以将常规Java类转换为托管对象,并将它们注入任何其他托管对象。 使用依赖注入,您的代码可以声明对任何托管对象的依赖性。 容器在运行时自动在注入点提供这些依赖项的实例,并且还为您管理这些实例的生命周期。 Java EE中的依赖注入定义了范围,这些范围确定容器实例化和注入的对象的生命周期。 例如,仅响应单个客户端请求(例如货币转换器)的托管对象与在会话中处理多个客户端请求(例如购物车)所需的托管对象具有不同的范围。
- history
- trend
- future
论Injection的前世今生的更多相关文章
- 【曹工杂谈】Maven底层容器Plexus Container的前世今生,一代芳华终落幕
Maven底层容器Plexus Container的前世今生,一代芳华终落幕 前言 说实话,我非常地纠结,大家平时只是用Maven,对于内部的实现其实也不关心,我现在非要拉着大家给大家讲.这就有个问题 ...
- 【调侃】IOC前世今生
前些天,参与了公司内部小组的一次技术交流,主要是针对<IOC与AOP>,本着学而时习之的态度及积极分享的精神,我就结合一个小故事来初浅地剖析一下我眼中的“IOC前世今生”,以方便初学者能更 ...
- [C#] 回眸 C# 的前世今生 - 见证 C# 6.0 的新语法特性
回眸 C# 的前世今生 - 见证 C# 6.0 的新语法特性 序 目前最新的版本是 C# 7.0,VS 的最新版本为 Visual Studio 2017 RC,两者都尚未进入正式阶段.C# 6.0 ...
- docker4dotnet #1 – 前世今生 & 世界你好
作为一名.NET Developer,这几年看着docker的流行实在是有些眼馋.可惜的是,Docker是基于Linux环境的,眼瞧着那些 java, python, node.js, go 甚至连p ...
- Atitit 智能云网络摄像机的前世今生与历史 优点 密码默认888888
Atitit 智能云网络摄像机的前世今生与历史 优点 密码默认888888 用户名admin 密码aaaaaa 网络摄像机是一种结合传统摄像机与网络技术所产生的新一代摄像机,它可以将影像通过网络传 ...
- 【解决方案】 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userHandler': Injection of resource dependencies failed;
一个错误会浪费好多青春绳命 鉴于此,为了不让大家也走弯路,分享解决方案. [错误代码提示] StandardWrapper.Throwableorg.springframework.beans.fac ...
- low security dvwa--SQL Injection
登录dvwa后,点击左边的"SQL Injection",出现以下界面: 下面做一些学习总结. 第一步:用 "order by n" 获得表中的属性列数,它的意 ...
- Ninject学习(一) - Dependency Injection By Hand
大体上是把官网上的翻译下而已. http://www.ninject.90iogjkdcrorg/wiki.html Dependency Injection By Hand So what's Ni ...
- 阿里开源消息中间件RocketMQ的前世今生-转自阿里中间件
昨天,我们将分布式消息中间件RocketMQ捐赠给了开源软件基金会Apache. 孵化成功后,RocketMQ或将成为国内首个互联网中间件在Apache上的顶级项目. 消息一出,本以为群众的反应是这样 ...
随机推荐
- which/whereis/locate/find的区别
which--在$PATH目录下查找文件 whereis--在预定目录下(whereis -l查看)查找文件 locate--在数据库中查找目录或文件 find--遍历目录查找文件 说明: 1.关于w ...
- NumPy for MATLAB users
http://mathesaurus.sourceforge.net/matlab-numpy.html Help MATLAB/Octave Python Description dochelp - ...
- Win7系统的虚拟机中安装win7系统
今天因兼职需要,在家里的win7电脑上安装WIN7虚拟机. 之前在xp和win10系统的虚拟机中,安装各种版本的windows系统都很轻松,这一次居然折腾了很久都没搞定. 下载了好几个系统ios镜像都 ...
- 软件测试职业规划的思考(转)(作者Findyou
前言 入软件测试行至今已经8年多,承领导们的信任与重用,同事的支持与信任,我的职业发展算是相对较好,从入行到各类测试技术岗位,再到测试总监,每一步都刚刚好.最近在自身职业发展瓶颈,人生十字路口,静坐反 ...
- 用flask Flask-RESTful,实现RESTful API
简介: 自从Roy Fielding博士在2000年他的博士论文中提出REST(Representational State Transfer)风格的软件架构模式后,REST就基本上迅速取代了复杂而笨 ...
- Java实现将数字转为大写汉字
public class Int2Big { static String int2big(int src) { final String num[] = {"零", "壹 ...
- macOS Sierra 如何打开任何来源
1.打开应用程序-实用工具-终端: 2.复制以下代码(红色处注意是两个-)到终端中,回车(输入电脑密码): sudo spctl --master-disable 3.打开应用程序-系统偏好设置-安全 ...
- List在遍历中删除t元素
法一:使用普通for循环遍历 注意: 1.从头开始循环,每次删除后 i 减一. 2.从尾开始循环. public class Main { public static voi ...
- C++基础知识:类的静态成员
1.普通成员变量通过对象名能够访问public成员变量每个对象都可以有只属于自己的成员变量成员变量不能在对象之间共享 2.从命名空间的角度:类的静态成员只是类这个命名空间中的全局变量和全局函数不同之处 ...
- FPGA中IBERT核的应用(转)
https://wenku.baidu.com/view/50a12d8b9ec3d5bbfd0a74f7.html (必看) 摘要 IBERT即集成式比特误码率测试仪,是Xilinx专门用于具 ...