10.12.2012 Views

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

A <strong>Java</strong> <strong>EE</strong> ApplicationThat Uses the JMS API with an Entity<br />

966<br />

<strong>The</strong> class contains a no-argument constructor and a constructor that takes two arguments, the<br />

employee ID and name. It also contains getter and setter methods for the employee ID, name,<br />

office number, and equipment list. <strong>The</strong> getter method for the employee ID has the @Id<br />

annotation to indicate that this field is the primary key:<br />

@Id public String getEmployeeId() {<br />

return id;<br />

}<br />

<strong>The</strong> class also implements the two business methods, doEquipmentList and doOfficeNumber,<br />

and their helper method, checkIfSetupComplete.<br />

<strong>The</strong> message-driven beans call the business methods and the getter methods.<br />

<strong>The</strong> persistence.xml file for the entity specifies the most basic settings:<br />

<br />

<br />

jdbc/__default<br />

eb.SetupOffice<br />

<br />

<br />

<br />

<br />

<br />

Creating Resources for the clientmdbentity Example<br />

This example uses the connection factory jms/ConnectionFactory and the topic jms/Topic,<br />

both of which you used in “A <strong>Java</strong> <strong>EE</strong> Application That Uses the JMS API with a Session Bean”<br />

on page 956. It also uses the JDBC resource named jdbc/__default, which is enabled by<br />

default when you start the Application Server.<br />

If you deleted the connection factory or topic, you can create them again using targets in the<br />

build.xml file for this example. Use the following commands to create the resources:<br />

ant create-cf<br />

ant create-topic<br />

<strong>The</strong> <strong>Java</strong> <strong>EE</strong> 5<strong>Tutorial</strong> • June 2010

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!