Courses
Java
Home
Corporate
Consulting
Contact Us
Courses
Jobs
Custom Topics

Customize this course,
choose your topics

Building Your Course
Custom Order Page
Building Guidelines

Selectable Topics
Advanced Applets
Advanced AWT
Collections
CORBA
Custom Components
Drag'n Drop
Enterprise JavaBeans
Event Delegation
GridbagLayout
InfoBus
Inner Classes
Internationalization
Java 2 Overview
JavaBeans
JFC Overview
JSP (Java Server Pages)
JSP Tag Libraries (taglib)
JDBC
JNI
RMI
Security
Serialization
Servlets
Struts
Swing
WebServices Overview
XML

Enterprise JavaBeans (EJB)

What are Enterprise JavaBeans?
Enterprise Definition
"JavaBeans" Versus "Enterprise JavaBeans"

What is an N-tier System?

Goals of EJB Component Model

What is a Container?

Session Beans versus Entity Beans

Course Description
What will I learn?
Specifications

Pre-requisites


Enterprise Java Beans (EJB) are an exciting technology that was first introduced in 1998. Since almost its inception, it has gained widespread support by the industry. The EJB component model is a key part of J2EE and is supported by all J2EE-compliant application servers.

What is the definition of "Enterprise"

The term "Enterprise" (as defined at the Javasoft website):

...implies highly scalable, highly available, highly reliable, highly secure, transactional, distributed applications. Enterprise applications require access to a variety of infrastructure services, such as distributed communication services, naming and directory services, transaction services, messaging services, data access and persistence services, and resource-sharing services. These infrastructure services are frequently implemented on different platforms using different products and technologies, making it difficult to build portable enterprise-class application systems. The Enterprise Java APIs provide a common interface to the underlying infrastructure services, regardless of the actual implementation.

JavaBeans versus Enterprise JavaBeans

A JavaBean is a Java software component that can be manipulated in a visual programming environment (much like VBX or OCX/ActiveX controls can be manipulated in visual builder tool such as Visual Basic, Powerbuilder, or Visual C++). Using a builder tool that supports JavaBeans, application developers can instantiate beans from a component palette and integrate them together into an application by visually manipulating the bean's properties and events. For a brief introduction to JavaBeans, see our JavaBeans topic description.

An Enterprise JavaBean is also a component model, but for server-side (or "middleware") components. An EJB is a non-visual remote Java component or business object, designed to run on a server and be invoked by clients. An EJB can be invoked via CORBA/IIOP, or through RMI.

The Enterprise JavaBeans model provides a framework for components to be "plugged in" to an application server, thereby utilizing the server's functionality. Within an application server, EJBs execute inside a container and delegate major responsibility, including security, transactional behavior, concurrency, and persistence, to the container.

What is an N-Tier System?

The two-tier client/server model was a precursor to the multi-tier, or n-tier model. In a client/server system, the application and business logic appear together in one layer, separate from the database layer.

In a three-tier (or "n-tier") system, the business logic is separated into another layer. Typically the business logic runs inside of an application server. The server provides enterprise-level services that the business logic uses. Such services may including messaging services, file services, transaction processing, load balancing, database services, etc.

Building an n-tier application is not as easy as building a 2-tier client/server application. In an n-tier system, the business logic interacts and interfaces with a variety of services. This involves many lines of intricate coding, handling transactions, state management, multi-threading, resource pooling, and other complex, low-level details.

Some development tools generate code (ie. server objects) that run in an application server and utilize the services of the application server. But this generated code is not portable and does not run in other application servers.

Goals of the EJB Component Model

The goals of the EJB component model is to:

  • Make it easier for the enterprise developer to focus solely on the business logic. Make the services as easy to use as possible, make them transparent if possible.
  • Provide a standard interface to these enterprise-level services, so that the implementation of the business logic is portable and can run any EJB container.
  • Create a market in which business logic components can be bought and sold.

What is a Container?

An application server provides a container to manage the execution of an EJB. When a client invokes a method of the EJB, the container automatically allocates a process thread and invokes the method of the EJB. Clients never access the EJB directly. Access is performed by container-generated methods, which in turn call the EJB's methods.

The container manages all resources and services on behalf of the EJB. It also manages all interactions between the EJB and the external systems. Different containers will use different implementation of the services.

All EJB containers support a "standard" interface. So, if you need to make your business objects use a different set of enterprise services, your business object does not need to be modified. You'll just re-deploy your business object so that it runs in a different container that provides a different implementation of the services.

"An application that uses IBM TXSeries, DCE services, and Oracle on one system could be moved to a different system and automatically use BEA Systems M3, LDAP, and Sybase instead. No porting effort would be required." (Javasoft)

Container provide a number of services, including:

  • Lifecycle
  • State Management
  • Security
  • Transactions
  • Persistence

Session Beans Versus Entity Beans

  • Session Bean: a session bean performs a service on behalf of the client. This type of bean is usually created by the client, and exists (in most cases) for the duration of a client/server session. The session bean may access data on behalf of the client, or perform some calculation. It can be transactional, but it is not usually recoverable after a system crash. The session bean can be stateful (ie. it maintains state information between client calls). Containers manage this "conversational" state of a session bean. Although session beans themselves are not typically persistent, a session bean may be composed of, or access, persistent data.
  • Entity Bean: represents an "entity", such as a business entity, or persistent data in a data store. A primary key is used to identify this type of component. These beans are transactional and can be shared by multiple clients. They are persistent across multiple invocations and survive system shutdown.

What will I learn?

  • Enterprise JavaBeans Concepts
    • Distributed Object Systems: RMI and CORBA
    • Enterprise defined/Goals of EJB
    • Enterprise JavaBeans versus JavaBeans
    • EJB Architecture
      • Application Server
      • EJB
      • EJB Server
      • EJB Container
      • EJB Clients
      • Interfaces: Home, Remote, and EJBObject
      • Auxiliary Systems: JNDI, JTS
      • Session versus Entity Beans
    • Examples and Scenarios
    • Deploying an EJB
  • Session Beans
    • Concepts
      • Passivation/Activation
      • Stateless versus Stateful
      • Persistent Session Beans
    • Interfaces and Classes
    • Writing an EJB Client
      • Locating Bean Container
      • Allocating a Bean
      • Interacting with the Bean
      • Disposing of the Bean
    • Packaging and Deploying EJB
      • .ser files
      • Manifest
      • Deployment Descriptors
    • Deploying Enterprise JavaBean Components
  • Entity Beans
    • Introduction to Entity Beans
    • Persistence
      • Bean-Managed Persistence
      • Container-Managed Persistence
    • Interfaces and Classes
    • Implementing a Finder Interface
    • Calling Entity Beans from Session Beans
    • Container Policies for Providing Synchronization
  • Transactions
    • What are Transactions?
      • What is a distributed transaction?
      • Two-phase Commit
      • Transaction Manager, Monitors, and Services
      • CORBA's OTS 1.1
    • Declarative Transactions
    • Examples of Bean Managed Transactions
    • Client Demarcated Transactions
    • Transaction-Aware Database Drivers
  • Advanced Topics
    • EJB-to-CORBA Bindings
    • Servlets and EJBs
    • Security
      • AccessControlEntry
    • Future Developments

Specifications

  • Duration (total): 3 days
  • Duration of Exercises: 1.25 days
  • Duration of Lecture: 1.75 days

Pre-requisites

If you are building a custom course, you will need to cover these topics before this topic can be presented:

In addition, material covered in this section requires attendees to know the following:
  • Basic Java knowledge including exception handling, threads, full use of all the language constructs, and familiarity with the core Java 1.1 APIs.
  • Those without these pre-requisites should consider one of our Ultimate Java Programming Workshops.

A table of contents of this module is available upon request.

Return to the Custom Order Page.

Copyright ©2007 by Petronio Technology Group, Inc. All rights reserved. Petronio, "Targeted Technology Training", "T3" and "Turning new technologies into your competitive advantage" are trademarks of Petronio Technology Group. All other trademarks are the properties of their respective companies.