The concept of injection has been part of Java technology for some time. Since the Java EE 5 platform was introduced, annotations have made it possible to inject resources and some other kinds of objects into container-managed objects. CDI makes it possible to inject more kinds of objects and to inject them into objects that are not container-managed.
The following kinds of objects can be injected:
(Almost) any Java class
Session beans
Java EE resources: data sources, Java Message Service topics, queues, connection factories, and the like
Persistence contexts (Java Persistence API EntityManager
objects)
Producer fields
Objects returned by producer methods
Web service references
Remote enterprise bean references
For example, suppose that you create a simple Java class with a method that returns a string:
package greetings; public class Greeting { public String greet(String name) { return "Hello, " + name + "."; } }
This class becomes a bean that you can then inject into another class. This bean is not exposed to the EL in this form. Giving Beans EL Names explains how you can make a bean accessible to the EL.
Table of Contents Java Platform, Enterprise Edition: The Java EE TutorialExpand|
CollapseRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4