Click me~

  • 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的前世今生的更多相关文章

  1. 【曹工杂谈】Maven底层容器Plexus Container的前世今生,一代芳华终落幕

    Maven底层容器Plexus Container的前世今生,一代芳华终落幕 前言 说实话,我非常地纠结,大家平时只是用Maven,对于内部的实现其实也不关心,我现在非要拉着大家给大家讲.这就有个问题 ...

  2. 【调侃】IOC前世今生

    前些天,参与了公司内部小组的一次技术交流,主要是针对<IOC与AOP>,本着学而时习之的态度及积极分享的精神,我就结合一个小故事来初浅地剖析一下我眼中的“IOC前世今生”,以方便初学者能更 ...

  3. [C#] 回眸 C# 的前世今生 - 见证 C# 6.0 的新语法特性

    回眸 C# 的前世今生 - 见证 C# 6.0 的新语法特性 序 目前最新的版本是 C# 7.0,VS 的最新版本为 Visual Studio 2017 RC,两者都尚未进入正式阶段.C# 6.0 ...

  4. docker4dotnet #1 – 前世今生 & 世界你好

    作为一名.NET Developer,这几年看着docker的流行实在是有些眼馋.可惜的是,Docker是基于Linux环境的,眼瞧着那些 java, python, node.js, go 甚至连p ...

  5. Atitit 智能云网络摄像机的前世今生与历史 优点  密码默认888888

    Atitit 智能云网络摄像机的前世今生与历史 优点  密码默认888888 用户名admin  密码aaaaaa 网络摄像机是一种结合传统摄像机与网络技术所产生的新一代摄像机,它可以将影像通过网络传 ...

  6. 【解决方案】 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userHandler': Injection of resource dependencies failed;

    一个错误会浪费好多青春绳命 鉴于此,为了不让大家也走弯路,分享解决方案. [错误代码提示] StandardWrapper.Throwableorg.springframework.beans.fac ...

  7. low security dvwa--SQL Injection

    登录dvwa后,点击左边的"SQL Injection",出现以下界面: 下面做一些学习总结. 第一步:用 "order by n" 获得表中的属性列数,它的意 ...

  8. Ninject学习(一) - Dependency Injection By Hand

    大体上是把官网上的翻译下而已. http://www.ninject.90iogjkdcrorg/wiki.html Dependency Injection By Hand So what's Ni ...

  9. 阿里开源消息中间件RocketMQ的前世今生-转自阿里中间件

    昨天,我们将分布式消息中间件RocketMQ捐赠给了开源软件基金会Apache. 孵化成功后,RocketMQ或将成为国内首个互联网中间件在Apache上的顶级项目. 消息一出,本以为群众的反应是这样 ...

随机推荐

  1. 整合elk(2)(十三)

    配置.启动kibana 到kibana的安装目录: 1 ./bin/kibana 默认配置即可. 访问localhost:5601,网页显示: 证明启动成功. 创建springboot工程 起步依赖如 ...

  2. JNDI学习总结(一)——JNDI数据源的配置(转)

    一.数据源的由来 在Java开发中,使用JDBC操作数据库的四个步骤如下:   ①加载数据库驱动程序(Class.forName("数据库驱动类");)   ②连接数据库(Conn ...

  3. sqlmap sql注入工具

    下载地址: https://github.com/sqlmapproject/sqlmap 参数可以在sqlmap.conf里指定 url = http://localhost:55556/crm/u ...

  4. Matlab远程调试 转

        Matlab的调试总体分为,直接调试和间接调试.1.直接调试:(1)去掉句末的分号:(2)单独调试一个函数:将第一行的函数声明注释掉,并定义输入量,以脚本方式执行 M 文件:(3)适当地方添加 ...

  5. UVa 11210 - Chinese Mahjong 模拟, 枚举 难度: 0

    题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...

  6. jsp标签之jsp:setProperty用法

    参考:http://blog.csdn.net/wanghaishanren/article/details/2047400

  7. DBProxy 读写分离使用说明

    美团点评DBProxy读写分离使用说明   目的 因为业务架构上需要实现读写分离,刚好前段时间美团点评开源了在360Atlas基础上开发的读写分离中间件DBProxy,关于其介绍在官方文档已经有很详细 ...

  8. Огонек--灯光--IPA--俄语

    苏联老歌总让人沉浸其中.

  9. VSTO - 使用Excel加载项生成表和图表

    此示例显示如何创建Excel的加载项,使用户可以在其工作表中选择库存符号,然后生成一个新工作表,显示库存的历史性能. 工作表包含数据表和图表. 介绍Excel加载项通常不知道工作表包含什么.典型的加载 ...

  10. MATLAB 地图工具箱 m_map 的安装和入门技巧(转)

    reference: http://blog.sina.com.cn/s/blog_8fc890a20102v6pm.html   需要用一些地图工具,arcgis懒得装了,GMT(generic m ...