Write the Java code in the client to create session EJBs. The client invokes the methods of the home interface to create its associated bean instance. There is a single home object for each session bean type and an EJBObject/ bean instance pair for each client.
On the creation of a new bean instance, the creation process will return a remote reference to the bean instance's EJBObject.
Note that there must be, at least, a no-arg[1] create() method in the Home object.
The code in the client that creates the bean using the create(String) method will be as simple as:
Hello bean = home.create("Mickey");
During the evolution of the code, I will only show the important features. I will ignore exception handling, when not essential for understanding, as it adds clutter to the code samples. However, in all the complete examples, workshop solutions, etc., I will show full-strength code.
create() methods return remote references to the bean's EJBObject instance. If no exceptions are thrown, the bean instance will be created and is then ready to accept method calls.
Creating Session Bean - Quiz
Click the Quiz link below to test your understanding of session bean architecture and how to create session beans. Creating Session Bean - Quiz
In the next lesson, you will be introduced to the code in the client to call the bean's methods.
[1]no-arg: A method that takes no arguments. For example create() in the home interface.