Beans as Injectable Objects - The Java EE 6 Tutorial (original) (raw)

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:

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 Namesexplains how you can make a bean accessible to the EL.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Legal Notices