You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Overview

This example demostrates the use of the injection of environment entries using <b>Resource</b> annotation.

"EJB Core Contracts and Requirements" specification section 16.4.1.1

"A field or method of a bean class may be annotated to request that an entry from the bean's environment
be injected. Any of the types of resources or other environment entries88 described in this chapter may
be injected. Injection may also be requested using entries in the deployment descriptor corresponding to
each of these resource types."

PurchaseOrder bean shows use of @Resource annotation through a bean field.

Invoice bean shows the use of @Resource annotation through a setter method.

The source for this example can be checked out from svn:

$ svn co http://svn.apache.org/repos/asf/incubator/openejb/trunk/openejb3/examples/resource-injection/

To run the example change to the directory containting example and run Maven:
(openejb3_project_dir is the top level directory of OpenEJB3 project)

$ cd <openejb3_project_dir>/examples/resource-injection

$ mvn clean install

The Code

h2 Resource injection through field

In this example we develop two stateful enterprise session beans viz to inject the simple environment entries. Invoice enterprise bean uses <b>maxLineItems</b> field to inject the maximum number of

  • No labels