Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Wiki Markup
h1. EJB3 Examples

All examples come with JUnit unit tests that can be run in any IDE, Maven or Ant without special plugins using OpenEJB as an embedded EJB container.  The easiest way to run the examples in your IDE is to use maven ({{mvn eclipse:eclipse}} or {{mvn idea:idea}}) to generate project descriptors.

{span:class=ExamplesTable}
|| title || description || annotationsAPIs used ||
| *[Simple Stateless|Simple Stateless Example]* | Simple EJB3 Stateless bean with local and remote business interfaces and unit test. |  - javax.ejb.Remote
 - javax.ejb.Local
 - javax.ejb.Stateless
|
| *[Simple Stateful|Simple Stateful Example]* | Simple EJB3 Stateful bean with local and remote business interfaces and unit test. |  - javax.ejb.Remote
 - javax.ejb.Stateful
|
| *[Component InterfacesEJB 2.1 Compatibility|EJB 2.1 Compatibility Example]* | Shows an EJB 3.0 Stateful bean with Business interfaces and EJB 2.1 interfaces (now called "component" interfaces). Four interfaces in total and unit test for each. |  - javax.ejb.CreateException
 - javax.ejb.EJBHome
 - javax.ejb.EJBLocalHome
 - javax.ejb.EJBLocalObject
 - javax.ejb.EJBObject
 - javax.ejb.Init
 - javax.ejb.Local
 - javax.ejb.LocalHome
 - javax.ejb.Remote
 - javax.ejb.RemoteHome
 - javax.ejb.Remove
 - javax.ejb.Stateful
|
| *[Injection of env-entry|Injection of env-entry Example]* | Stateless session bean Shows how @Resource can be used to inject {{env-entry}} values declared in an ejb-jar.xml file |  - javax.annotation.Resource
 - javax.ejb.Local
 - javax.ejb.Remote
 - javax.ejb.Stateful
|
| *[Injection of ejbs]* | desc env-entry 2|Expanded env entries Example]* | Same as the above example but shows how to use a properties file to declare the injection values and demonstrates how to get injection of more types such as java.util.Date, java.lang.Class, java.net.URI and more.  _OpenEJB specific feature_. |  - javax.annotation.Resource
 - javax.ejb.Stateless
|
| *[Injection of other EJBs|Injection of other EJBs Example]* | Shows use of @EJB in a Stateless to have another Stateless bean injected into it. |  - javax.ejb.EJB
 - javax.ejb.Local
 - javax.ejb.Remote
 - javax.ejb.Stateless
|
| *[Injection of DataSource|Injection of DataSource Example]* | descShows use of @Resource to have a JDBC *DataSource* injected into a Stateful bean.  The Stateful bean does basic INSERT, SELECT and DELETE SQL operations. |  - javax.annotation.PostConstruct
 - javax.annotation.Resource
 - javax.ejb.Stateful
 - javax.sql.DataSource
|
| *[Injection of EntityManager|Injection of EntityManager Example]* | desc Shows use of @Resource to have an EntityManager with an EXTENDED persistence context injected into a Stateful.  An EJB 3 @Entity bean is with the EntityManager to create, persist and merge data to a database. |  - javax.ejb.Stateful
 - javax.persistence.Entity
 - javax.persistence.EntityManager
 - javax.persistence.PersistenceContext
 - javax.persistence.PersistenceContextType
 - javax.persistence.Query
|
| *[Interceptors|Interceptor Example]* | desc Shows several EJB 3 Interceptors with @AroundInvoke methods intercepting invocations on a Stateless bean.  |  - javax.ejb.Local
 - javax.ejb.Stateless
 - javax.interceptor.AroundInvoke
 - javax.interceptor.Interceptors
 - javax.interceptor.InvocationContext
|
| *[ExpandedEmbedded envand entriesRemotable]* | desc |  - javax.annotation.Resource
 - javax.ejb.Stateless
|
| *[Telephone Stateful]* | descDemonstrates how to use an OpenEJB feature that allows people embedding OpenEJB into their applications to support remote clients in other VMs.  This is not required for unit testing. |  - javax.ejb.Remote
 - javax.ejb.Stateful
|
| *[Helloworld Weblogic]* | desc Demonstrates OpenEJBs ability to understand and support the WebLogic deployment descriptors so people using that platform in production can still use OpenEJB in their IDE or build to unit test their EJB applications. |  - javax.ejb.CreateException
 - javax.ejb.EJBLocalHome
 - javax.ejb.EJBLocalObject
 - javax.ejb.LocalHome
 - javax.ejb.Stateless
|
{span}