论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上的顶级项目. 消息一出,本以为群众的反应是这样 ...
随机推荐
- 常用的flex知识 ,比起float position 好用不少
flex布局具有便捷.灵活的特点,熟练的运用flex布局能解决大部分布局问题,这里对一些常用布局场景做一些总结. web页面布局(topbar + main + footbar) 示例代码 要 ...
- linux network
Linux 1◆ 提供连接 2◆ connection baidu.com 3◆ vm tools install Reboot
- 变量和基本类型——复合类型,const限定符,处理类型
一.复合类型 复合类型是指基于其他类型定义的类型.C++语言有几种复合类型,包括引用和指针. 1.引用 引用并非对象,它只是为一个已存在的对象所起的另外一个名字. 除了以下2种情况,其他所有引用的类型 ...
- Node.js编写be的流程(express)
Node.js编写be的流程 1.当前项目目录下首先安装express 2.自动生成express插件结构 express -e 3.执行完前两步的效果 4.此时的package.json ...
- python之路-网络基础
1.什么是网络: 通过网络设备将各个设备连接在一起,使用协议让设备之间可以通信,共享资源,这些组成了一个网络. 2.osi七层模式: 国际标准化组织(ISO)创建OSI(开放系统互联)参考模型,希望不 ...
- linux150条命令
●线上查询及帮助命令(2 个)man help ●文件和目录操作命令(13 个) ls tree pwd mkdir rmdir cd touch cp mv rm ln find rename ●查 ...
- 【转】Mac OS X Terminal 101:终端使用初级教程
最近学习苹果认证的<Mac OS X Support Essentials>教程,看到 Command Line 一节有很多实用的知识,下面选取一部分翻译 + 笔记,整理成此文. 你可以整 ...
- substr、substring和slice的区别
substr(start,[length])表示从start位置开始取length个字符串:substring(start,end)表示从start,到end之间的字符串,包括start位置的字符但是 ...
- angular自定义指令
1.在directive文件下创建指令的js文件 通常自定义指令需要声明模块(注意定义指令时, js内部指令名称需采用 aaAaBb驼峰的命名方式 html中使用的是aa-aa-bb) e.g (f ...
- Oracle 用户 表 表空间之间的关系和管理
文献地址: https://blog.csdn.net/jmilk/article/details/51599260 https://www.cnblogs.com/roger112/p/768530 ...