background image

Creating Resources

<< Coding the Message-Driven Beans | Building the clientmdbentity Example >>
<< Coding the Message-Driven Beans | Building the clientmdbentity Example >>

Creating Resources

The class contains a no-argument constructor and a constructor that takes two arguments, the
employee ID and name. It also contains getter and setter methods for the employee ID, name,
office number, and equipment list. The getter method for the employee ID has the @Id
annotation to indicate that this field is the primary key:
@Id public String getEmployeeId() {
return id;
}
The class also implements the two business methods, doEquipmentList and doOfficeNumber,
and their helper method, checkIfSetupComplete.
The message-driven beans call the business methods and the getter methods.
The persistence.xml file for the entity specifies the most basic settings:
<persistence>
<persistence-unit name=
"clientmdbentity">
<jta-data-source>jdbc/__default</jta-data-source>
<class>eb.SetupOffice</class>
<properties>
<property name=
"toplink.ddl-generation"
value=
"drop-and-create-tables"/>
</properties>
</persistence-unit>
</persistence>
Creating Resources for the clientmdbentity Example
This example uses the connection factory jms/ConnectionFactory and the topic jms/Topic,
both of which you used in
"A Java EE Application That Uses the JMS API with a Session Bean"
on page 964
. It also uses the JDBC resource named jdbc/__default, which is enabled by
default when you start the Application Server.
If you deleted the connection factory or topic, you can create them again using targets in the
build.xml
file for this example. Use the following commands to create the resources:
ant create-cf
ant create-topic
A Java EE Application That Uses the JMS API with an Entity
The Java EE 5 Tutorial · September 2007
974