Client view of a stateful session bean in EJB
This module will provide the code for Enterprise Java Beans.
It is only for the client with a glimpse at the home interface in the container; we will code the bean and associated classes and interfaces later.
Note that session beans consume the rest of this course; entity beans and transactions are covered in part two of this series,
Entity Beans, Transactions, and Security.
Home interface: The Java interface that is implemented by the deployer to build the home object.
Looking up and creating the bean instance
To be able to invoke the business methods of a bean, the client will need to look up the remote object in the naming service and download the stub.
Once it has the stub, the client can use it to create an instance of the bean using the home object.
I will explain the responsibilities and illustrate how the home object is used in some detail.
Invoking the bean's business methods
- Naming service: An entity that provides a lookup service to enable clients to find specific remote objects.
- Home object: The EJB bean factory (see above). It listens on the network for client create() and remove() requests.
We will then look at how the business methods are called by the client using the bean's EJBObject .
As the home object, the bean instance, the EJBObject, the container, or the transport may throw one or more exceptions. We'll look at what they are and how to catch them. The final topic covers beanhandles.
Services of Beans
- EJBObject: That skeleton of the bean that implements the bean's interface.
- Handle: An object which contains all the information required to access an existing remote session bean.
To illustrate these aspects of session beans, we will be using a bean called Hello. If it were a class in your program, rather than a remote object, it would be programmed as follows:
Click the link below to view Java Exception Handling.
Java Exception Handling
Please review this code before moving on to the next lesson.
In the next lesson, you will be introduced to the client/bean relationship.