Java Reference
In-Depth Information
ject contains the bidder placing the bid, the item being bid on, and the bid amount. As you
know, all the method needs to do is save the passed-in Bid data to the database. As you'll
see toward the end of the chapter, the Bid object is really a JPA 2 entity.
Listing 2.1. BidService stateless session bean code
The first thing that you've probably noticed is how plain this code looks. The De-
faultBidService class is just a Plain Old Java Object (POJO) and the BidService
interface is a Plain Old Java Interface (POJI). There's no cryptic interface to implement,
class to extend, or confusing naming convention to follow. The only notable features in
listing 2.1 are the three annotations— @Stateless , @Local , and @Inject :
@Stateless— The @Stateless annotation tells the EJB container that De-
faultBidService is a stateless session bean. This means that the container
automatically makes sure that the bean is completely thread-safe, transactional,
and pooled. Thread-safe and transactional mean that you can use any back-end re-
sources such as a database or message queue without writing any concurrency or
transaction code yourself. Pooling ensures that the service will perform well even
under a very heavy load. You can add additional EJB services to the component,
such as security, scheduling, or interceptors, on an as-needed basis.
@Local— The @Local annotation on the BidService interface tells the con-
tainer that the BidService EJB can be accessed locally through the interface.
Because EJBs and components that use them are typically collocated in the same
Search WWH ::

Custom Search