This chapter discusses Enterprise JavaBeans (EJBs) and examines the role they play in the Java 2 J2EE 1.3.1 architecture. Although it is impossible in one chapter to cover the vast number of rules, APIs, and interfaces required to develop Enterprise JavaBeans 2.0, the essential requirements necessary to create EJBs are presented. Simple code fragments accompany many of the topics here. The EJBs examined include both session and entity beans. Their respective categories and individual characteristics and life cycles provided for by a container are discussed in the first part of the chapter, and then some hands-on examples are presented.
Enterprise JavaBeans are designed for flexibility, reusability, and rapid application development. They are built to accommodate every possible type of business model requirement. As long as developers conform to the J2EE specification, the application is portable across multiple platforms and diverse operating systems. The J2EE 1.3 architecture is component and interface based, and therein lies its success. Because it is component based, the J2EE infrastructure makes it easy for developers to create distributed applications for the enterprise.
Listed here are the J2EE application development phases:
Application and web component development During this phase, web developers create web components that encapsulate presentation logic. They represent WAR files. Enterprise JavaBean developers create EJB components that encapsulate business logic. These components compile to class files and are assembled to create an EJB-JAR file.
Assembly The assembler is responsible for selecting the WAR and EJB-JAR files and organizing them into an enterprise archive (EAR) file. Depending on context, the assembler may customize some of the fields in the deployment descriptor file as well as resolve any external dependencies and specify them in the descriptor file.
Deployment The deployer uses the EAR file to examine the deployment descriptor file, resolving any external dependencies and configuring the application to deploy and execute in the intended operational environment. Ultimately, the administrator is responsible for monitoring and managing the application servers.