Library Zone Articles
External Articles
Byte Size

Discovery Zone Catalogue
Diary
Links
Bookstore
Interactive Zone Ask the Gurus
Discussion Groups
Newsletters
Feedback
Etc Cartoons
Humour
COMpetition
Advertising ASP Web Ring ASP Web Ring
Click here
The Developer's Resource & Community Site
COM XML ASP Java & Misc. NEW: VS.NET
International This Week Forums Author Central Find a Job

Developing EJB Clients

To work with any of these samples, you will need the following:

To work with the EJB Servlet client, you will need:

1. Define your TellerClient class

Define a class called TellerClient which is a client to our Session Enterprise Bean "Teller". Realize that our Session Bean Teller is itself a client to our Entity Bean "Checkings". As discussed in Modelling using Session and Entity Beans, we use our Session beans as the only interface to the client.

A Three-Tier Architecture for a Typical Bank
A Three-Tier Architecture for a Typical Bank

Bank\TellerClient.java
package Bank;

import java.rmi.*;
import java.util.*;

public class TellerClient
{

 public static void main(String[] args) throws Exception
 {

  TellerHome home = (TellerHome)Naming.lookup("Teller");
  System.out.println( "Naming.lookup successful..." );
  if( home == null )
  {
   System.out.println( "null TellerHome returned..." );
  }
  Teller teller = home.create();
  teller.createCheckingsAccount( "Athul", 100.0);
  teller.createSavingsAccount( "Aditya", 100.0);
  teller.TransferMoney( 50, 11, 10001);
  Checkings check = teller.getCheckings( 11);
  System.out.println("No = " + check.getAccountNumber() +
                     " Name = " + check.getCustomerName() +
                     " Balance = " + check.getBalance());
  Savings save = teller.getSavings( 10001);
  System.out.println("No = " + save.getAccountNumber() +
                     " Name = " + save.getCustomerName() +
                     " Balance = " + save.getBalance());
 }
}

2. Compile and run your client

E:\MyProjects\AccountEJB\Bank>javac TellerClient.java


E:\MyProjects\AccountEJB>cd ..

E:\MyProjects\AccountEJB>java Bank.TellerTest
Naming.lookup successful...
No = 0 Name = Athul Balance = 50.0
No = 0 Name = Aditya Balance = 150.0


E:\MyProjects\AccountEJB>

Next Article....Writing an EJB Servlet Client


What do you think of this article?

Have your say about the article. You can make your point about the article by mailing [email protected] (If you haven't allready joined, you can join by going to https://www.onelist.com/community/dev-java).

You can also write a review. We will publish the best ones here on this article. Send your review to [email protected]. Please include the title of the article you are reviewing.

Further Reading

The Enterprise JavaBeans Series:

Enterprise Java Beans By Gopalan Suresh Raj.
In this introduction to Enterprise Java Beans, Gopalan covers the bases then goes on to demonstrate how to build server side business object components. This article is the introduction to Gopalans series of Enterprise JavaBeans articles. (This series of articles is courtesy of Gopalan Suresh Raj)

Enterprise Java Beans Series - Components at the Server By Gopalan Suresh Raj.

Enterprise Java Beans Series - EJB Model By Gopalan Suresh Raj.

Enterprise Java Beans Series - EJB Naming Services and JNDI By Gopalan Suresh Raj.

Enterprise Java Beans Series - EJB Transactions and JTS By Gopalan Suresh Raj.

Enterprise Java Beans Series - EJB Lifecycle By Gopalan Suresh Raj.

Enterprise Java Beans Series - EJB Servers By Gopalan Suresh Raj.

Enterprise Java Beans Series - EJB Containers By Gopalan Suresh Raj.

Enterprise Java Beans Series - EJB Components By Gopalan Suresh Raj.

Enterprise Java Beans Series - EJB Session Beans By Gopalan Suresh Raj.

Enterprise Java Beans Series - EJB Entity Beans By Gopalan Suresh Raj.

Enterprise Java Beans Series - Writing an Entity Bean By Gopalan Suresh Raj.
Part 1 of a four part series: A four tier bank account example

Enterprise Java Beans Series - Writing a Session Bean By Gopalan Suresh Raj.
Part 2 of a four part series: A four tier bank account example

Enterprise Java Beans Series - Writing an EJB Servlet Client By Gopalan Suresh Raj.
Part 4 of a four part series: A four tier bank account example


Author: Gopalan Suresh Raj

Gopalan has his own site at Author Central (visit him. He also maintains his own site at https://www.execpc.com/~gopalan/) - Contribute to iDevResource.com and you can have one too!

© Copyright 1997-2000 Gopalan Suresh Raj. Reproduced with Permission


Click here

Contribute to IDR:

To contribute an article to IDR, a click here.

To contact us at IDevResource.com, use our feedback form, or email us.

To comment on the site contact our webmaster.

Promoted by CyberSavvy UK - website promotion experts

All content © Copyright 2000 IDevResource.com, Disclaimer notice

Learn C#

Visit our NEW WTL Section

Code Project

WTL Architecture by Richard Grimes

Join the Developers Webring