Enterprise JavaBeans

Enterprise JavaBeans is a very big topic, and we can't do more than provide a few paragraphs of insight here. If you want more information, see Enterprise JavaBeans by Richard Monson-Haefel (Oracle). The thrust of EJB is to take the JavaBeans philosophy of portable, pluggable components and extend it to the server side to accommodate the sorts of things that multitiered, networked and database-centric apps require. Although EJB pays homage to the basic JavaBeans concepts, it is much larger and more specialized. It doesn't have a lot in common with the kinds of things we've been talking about in this chapter. EJBs are server-side components for networked apps. EJBs and plain Java beans are both reusable, portable components that can be deployed and configured for specific environments. But in the case of EJBs, the components encapsulate access to business logic and database tables instead of GUI and program elements. EJB ties together a number of other Java enterprise-oriented APIs, including database access, transactions, and name services, into a single component model for server apps. EJB imposes a lot more structure on how you write code than plain old Java beans. It does so to allow the server-side EJB container to take on a lot of responsibility and optimize your app's activities without you having to write a lot of code. Here are a few things Enterprise JavaBeans tackles:

  • Object life cycle and remote access
  • Container-managed persistence
  • Transaction management
  • Server resource pooling and management
  • Deployment configuration

EJB divides the world into two camps: entity beans, which represent data in a database, and session beans, which implement services and operations over entity beans. These correspond well to the second and third tiers in a three-tiered business app. "Business logic" is represented by session bean services, and database access is made transparent through automated object mapping by entity beans. Many aspects of EJB behavior can be controlled through "deployment descriptors" that customize bean behavior for the target environment. The result is a high level of abstraction over ordinary business-specific code. It allows powerful, networked business app components to be packaged and reused in the sort of way that ordinary beans are reused to build client-side apps. Sun has created a reference EJB platform as part of Java 2 Enterprise version (J2EE), but currently, the most robust EJB implementations are provided by third parties. Usually, the EJB container is packaged as part of a more general app server that performs other duties, such as running web services, servlets, and JSPs. There are many vendors of commercial EJB servers. Two popular alternatives are BEA's WebLogic, an app server with many high-end features, and JBoss, an open source app server and implementation of the J2EE APIs. JBoss can be downloaded from http://www.jboss.org.

Java ScreenShot
Comments