Web Development with MyEclipse and JBoss – part 2
Design of the EJB Project
In the section below we will explain various aspects of J2EE technology. The design should be understood
as a technology overview introducing technologies like Entity Beans with Container Managed Persistence
(CMP) and design patterns like Data Access Objects (DAO).
As explained earlier in this document, we are using a central Session Bean to implement our business
logic. We will implement two of the use cases introduced in Part One of this three part series:
• Login User
• Local Dealership Inquiry ( for browsing items which are available in stock)
The Login User use case is implemented as a method in the WebStockAccess Session Bean. This bean will be
responsible for authenticating the user by communicating with the database using a Data Access Object
(DAO) which encapsulates the Java Database Connectivity (JDBC) code. In fact, we do not want to
implement the JDBC query directly in this Session Bean method, but move it to a Data Access Object
(DAO). There are a several advantages to using this design:
• First, we have clean separation between our business logic and the underlying JDBC
exceptions and connections.
• Second, in the case where we change the underlying database technology, we only
have to check that our DAOs are still working. We do not have to worry about our
business logic.
• Third, we can implement database specific DAOs when we want to support multiple
database types.
The Local Dealership Inquiry use case is also implemented as a method in the WebStockAccess Session Bean.
The method returns a list of StockItems which are composite classes that include the information from an
Inventory class and an Item class. We moved the implementation into a DAO object, and the
implementation will use a Finder method of a CMP entity bean.
Enterprise Java Bean Development with MyEclipse