Enterprise JavaBeans and POJO-Based Enterprise Frameworks

Enterprise JavaBeans (EJB) 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 (O’Reilly). The thrust of EJB takes the JavaBeans philosophy of portable, pluggable components and extends it to the server side to accommodate the sorts of things that multitiered, networked, and database-centric applications 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 applications. 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 applications. 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 application’s activities without your having to write a lot of code.

The first two major releases of Java Enterprise Edition, which include EJBs, were considered by many to be overly complicated. Many classes, interfaces, and configuration files were required to support EJBs. As a result, a number of popular open source frameworks that make use of Plain Old Java Objects (POJOs) to accomplish the same tasks quickly rose to prominence. POJOs are Java objects that are not required to follow any convention, implement any interface, or inherit from any base class, although in practice they are often JavaBeans. The most notable of the POJO-based frameworks are Hibernate, a framework for mapping Java object state to a database, and Spring, a general-purpose enterprise application development framework.