|
||
Lesson 3
Objective
|
The home object and the home interface Describe the home object and the home interface. |
|
|
Skeleton of the home interface
Here is part of the home interface for the Hello bean created by the Hello bean developer:
import javax.ejb.EJBHome; public interface HelloHome extends EJBHome { . }
Note that it is an interface, not a class.
Metadata: The information about an object: its methods, parameters, return types, etc.
Remote objects
The real home object class will be created as part of the deployment process. The container will instantiate the home object instance when the bean is installed into the container. The home interface always extends EJBHome for structural reasons. EJBHome includes methods to access the bean's metadata .
A remote object is an object that has
Remote object: An object that provides a service through its methods and is located on another host on the network.
The location of the object needs to be known before its methods can be called.
Both the skeleton and the stub are uniquely associated with that specific remote object.
When a client wishes to communicate with the remote object, it will use its unique stub, often known as a remote
reference . In Java terms, the remote reference is the reference to the stub instance in the JVM . This is
illustrated in the following diagram.
Remote reference: The reference to an object, usually the stub, that knows where, and how to communicate with, a remote object.
JVM: The Java Virtual Machine, a software implementation of a portable environment, that executes Java programs.
The data type of the stub is unknown to the client. From the proxy pattern, the stub and the entity for which it is a proxy have the same
interface.
Thus, if we know the interface of the remote object, we know the interface implemented by the stub. Therefore, considering the HelloHome interface code above, the Java type of the stub to the home object is HelloHome. We can write code as follows:
HelloHome home = (HelloHome) nameService.lookup("hello");
Examine now the methods of the EJBHome class in the javadoc J2EE API documentation to help you understand the
methods inherited by the Home interface.
In the next lesson, you will apply the reasoning above to the actual lookup of the home object from the Name Service. |
||
|
|
||