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:

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

(where BEA_HOME is the directory containing your WebLogic Server installation)

JSPs that invoke JPA directly

common_service.jsp Obtains a EntityManagerFactory reference by direct construction
transaction.jsp Starting a explicit transaction with direct JPA
createArtist_service.jsp Create a new Artist via direct JPA
addReview_service.jsp Adds a new Review via direct JPA
showBooks_service.jsp JPQL queries via direct JPA
showSpecificMusic_service.jsp 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 Create a new Artist via Session Bean
addReview_session.jsp Adds a new Review via Session Bean
showBooks_session.jsp JPQL queries via Session Bean
showSpecificMusic_session.jsp JPQL queries with predicate via Session Bean
addBooks_session_ejb21.jsp Add a new book via Session Bean with a ejb21 client view.
mdb.jsp Triggers the Message Driven Bean to be invoked.

Persistent EJBs

Item.javaDefines persistent and abstract Item EJB. A root of inheritance hierarchy with SINGLE_TABLE mapping
Book.javaDefines persistent Book EJB
Music.javaDefines persistent Music EJB
Movie.javaDefines persistent Movie EJB
Person.javaDefines persistent Person EJB. Another root of inheritance hierarchy with different mapping strategy
Artist.javaDefines persistent Artist EJB
Reviewer.javaDefines persistent Reviewer EJB
Review.javaDefines persistent 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 A stateless Session Bean that implements a business interface functions on EJB domain model
ReviewStatManager.java Interface defines function calulating the items and reviews added during one session.
ReviewStatManagerBean.java A stateful Session Bean that implements ReviewStatManager interface

Session Bean with the usage of EJB Reference

Process.java Defines a business interface adding reviews on a randomly selected Book.
ProcessBean.java A stateless Session Bean which references EJB ReviewListenerBean to broadcast that a new review is added.

Message Driven Bean

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

Application Execeptions

ObjectExistedException.java unchecked RuntimeException annoatated as application execption.
ObjectNotFoundException.java unchecked RuntimeException annoatated as application execption.
NotLoggedInException.java Checked Exception.
BadCommentsException.javaunchecked RuntimeException annoatated as application execption.

EJB Interceptors

AuditInterceptor.javaInterceptor class including a business method interceptor methoda and lifecycle callback interceptor method annotated with @PreDestroy.
InterceptedProcess.javaBusiness interface for the EJB interceptor sample.
InterceptedProcessBean.javaA 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 A 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 WebLogic Server, including the examples.
  2. Start the Examples server.
  3. Set up your environment.

Configure 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 WebLogic Server examples directory, such as d:\beahome\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 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 (from the shell where you set your environment):

    ant run

    which opens your default browser to the following URL:

    http://localhost:port/reviewService/

    where

localhost refers to the machine on which WebLogic Server is running

port refers to port on which WebLogic Server is listening


Troubleshooting


Related Topics

(Internet connection required.)


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