|
Comments
Did you read today's front page stories & breaking news?
SYS-CON.TV
|
Enterprise Spring and Java EE 5 (PART 1)
Simplicity and power combined
By: Debu Panda
Jun. 26, 2007 09:30 AM
Register for Real-World Java Seminar The Java Platform, Enterprise Edition, or Java EE, is the most popular middleware platform for developing and deploying enterprise applications. Java EE offers developers a choice of vendors, portability, scalability, and robustness. However, it has been criticized for its complexity and its need for a lot of redundant and procedural code. In addition, lightweight frameworks such as Spring and scripting platforms such as Ruby on Rails have emerged to challenge the platform's supremacy in the middleware world.
In this two-part series, I will discuss how Java EE 5 simplifies enterprise application development, then uncover how you can utilize the Spring Framework to fill the gaps left by Java EE 5. Simplified Programming Model with Java EE 5
Let's briefly examine these changes. Simplified Persistence If you've used an object-relational (O/R) mapping framework to build the persistence tier of your application, you'll notice that each framework provides three facilities:
The EJB 3 Java Persistence API (JPA) standardizes the use of persistence for the Java platform by providing a standard mechanism for O/R mapping, an EntityManager API to perform CRUD operations, and a way to extend the EJB query language (EJB-QL) to retrieve entities. Introducing JPA Entities (The code examples that follow are taken from my recently published book, EJB 3 in Action, published by Manning Publications.) I've used annotations to define the mapping of entities to tables; you can also use XML. It's worth mentioning that JPA provides support for rich domain modeling capabilities such as inheritance, and polymorphism. JPA supports several inheritance mapping strategies: single table, joined subclass, and table per class. Unlike EJB 2 container-managed persistence (CMP), JPA is simple and supports automatic generation of primary keys. Now that you've seen an entity, let's examine how you can manipulate entities by using the EntityManager API. The EntityManager API You can use the persist() method to save an instance of entity. For example, if you want to persist an instance of Bid, use the following code: @PersistenceContext(unitName="actionBazaar") Now that you have a sense of how easy it is to use the persistence feature of EJB 3, we'll examine how EJB 3 simplifies the development of business components. Simplified EJB 3 Components EJB 3 simplifies development by adopting the POJO programming model, and simplifies usage of EJB and resources by using dependency injection. It also depends heavily on intelligent defaults and makes the deployment descriptor optional. Listing 2 provides an example of a simple stateless EJB 3 session bean with a remote interface. In this example, PlaceBidBean is a simple POJO class that implements a regular Java interface - or a plain old Java interface (POJI). The @javax.ejb.Remote converts the POJI to a remote interface and @javax.ejb.Stateless converts the POJO to a stateless EJB. You can use @Stateful and @MessageDriven annotations to define stateful and message-driven beans, respectively. Reader Feedback: Page 1 of 1
Latest AJAXWorld RIA Stories
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
|
SYS-CON Featured Whitepapers
Most Read This Week
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||