Files   Prepare   Run   Troubleshooting   Related Topics 

About the Example

This example demonstrates the following features of EJB 3.0:

The example uses a persistent domain model of entity EJBs.

 


Files Used in the Example

Directory Location:

MW_HOME/wlserver_10.3/samples/server/examples/src/examples/ejb/ejb30/

(where MW_HOME is the directory containing your Oracle WebLogic Server installation)

JSPs that invoke JPA directly

common_service.jsp Obtains a EntityManagerFactory reference by direct construction.
transaction.jsp Starts an explicit transaction with direct JPA.
createArtist_service.jsp Creates a new Artist via direct JPA.
addReview_service.jsp Adds a new Review via direct JPA.
showBooks_service.jsp Executes JPQL queries via direct JPA.
showSpecificMusic_service.jsp Executes JPQL queries with predicate via direct JPA.

JSPs that invoke Session Bean

common_session.jsp Obtains a Session Bean injected with a EntityManagerFactory from JNDI.
createArtist_session.jsp Creates a new Artist via Session Bean.
addReview_session.jsp Adds a new Review via Session Bean.
showBooks_session.jsp Executes JPQL queries via Session Bean.
showSpecificMusic_session.jsp Executes JPQL queries with predicate via Session Bean.
addBooks_session_ejb21.jsp Adds a new book via Session Bean with a ejb21 client view.
mdb.jsp Triggers the Message Driven Bean to be invoked.

Persistent EJBs

Item.javaPersistent and abstract Item EJB. A root of inheritance hierarchy with SINGLE_TABLE mapping.
Book.javaPersistent Book EJB.
Music.javaPersistent Music EJB.
Movie.javaPersistent Movie EJB.
Person.javaPersistent Person EJB. Another root of inheritance hierarchy with different mapping strategy.
Artist.javaPersistent Artist EJB.
Reviewer.javaPersistent Reviewer EJB.
Review.javaPersistent Review EJB. Shows examples of relationship mapping.

Functions on Persistent EJBs using direct JPA

PersistenceService.javaWraps EntityManagerFactory to provide EntityManager per-thread.
ReviewService.java Defines business functions on EJB domain model.
ReviewServiceImpl.java Implements business functions on EJB domain model.
SeedDatabase.java Populates a database with EJB domain model via direct JPA.

Session Bean on Persistent EJBs injected with EntityManager

ReviewManagerBean.java Stateless Session Bean that implements a business interface functions on EJB domain model.
ReviewStatManager.java Interface that defines function calculating the items and reviews added during one session.
ReviewStatManagerBean.java Stateful Session Bean that implements ReviewStatManager interface

Session Bean with the usage of EJB Reference

Process.java Business interface adding reviews on a randomly selected Book.
ProcessBean.java Stateless session bean which references EJB ReviewListenerBean to broadcast that a new review is added.

Message Driven Bean

WatchProcessMDB.java Message-driven bean invoked when a new review is added.
SubscriptionService.java POJO used by the WatchProcessMDB to feed reviews into subscriber.
ReviewListener.java Listener interface for new added reviews.
ReviewListenerBean.java Stateless session bean which send a jms message carring new review's id into exmaple jms queue.

Application Execeptions

ObjectExistedException.java Unchecked RuntimeException annotated as application exception.
ObjectNotFoundException.java Unchecked RuntimeException annotated as application exception.
NotLoggedInException.java Checked exception.
BadCommentsException.java Unchecked RuntimeException annotated as application exception.

EJB Interceptors

AuditInterceptor.java Interceptor class including a business method interceptor methoda and lifecycle callback interceptor method annotated with @PreDestroy.
InterceptedProcess.java Business interface for the EJB interceptor sample.
InterceptedProcessBean.java Stateless session bean annotated with a interceptor to valid comments being added.

Session Bean with EJB21 client view.

ItemManager.java Business interface.
ItemManagerHome.java Home interface.
ItemManagerLocal.java Component interface.
ItemManagerBean.java Stateless session bean annotated with Home and Business interface.

Deployment Descriptors

application.xml Deployment descriptor for the application.
web.xml Deployment descriptor for the web module.
persistence.xml Descriptor for the Persistence Provider Runtime.
dwr.xml Descriptor for Direct Web Remoting.
data.properties Sample data to populate the database.

Prepare the Example

Prerequisites

Before working with this example:

  1. Install Oracle WebLogic Server, including the examples.
  2. Start the Examples server.
  3. Set up your environment.

Configure Oracle WebLogic Server

  No special configuration is required for this example

Build and Deploy the Example

  1. Change to the SAMPLES_HOME\server\examples\src\examples\ejb\ejb30 directory, where SAMPLES_HOME refers to the main Oracle WebLogic Server examples directory, such as d:\Oracle\Middleware\wlserver_10.3\samples.
  2. Execute the following command:

    ant build

    This command compiles and stages the example.
  3. Execute the following command:

    ant deploy

    This command deploys the example on the wl_server domain of your Oracle WebLogic Server installation.

Additional information on using the build scripts is found in More About Building Examples.


Run the Example

  1. Complete the steps in the "Prepare the Example" section.
  2. Execute the following command:

    ant run

    which opens your default browser to the following URL:

    http://localhost:port/reviewService/

    where

localhost refers to the machine on which Oracle WebLogic Server is running

port refers to port on which Oracle WebLogic Server is listening


Troubleshooting


Related Topics

(Internet connection required.)


Copyright @1996, 2009, Oracle and/or its affiliates. All Rights Reserved.