Remoting JDO objects using RMI

Gopalan Suresh Raj

Note
To work with any of these samples, you will need the following:
.........................................JDK 1.2 or higher (I use JDK 1.3.1)
.........................................PE:JTM - The Productivity Environment for JavaTM (from HYWY Software Corporation)

 

Note: This article assumes that the reader has already created simple bank project using PE:J and JDO.

The Transfer Money Object Interaction Diagram is as shown below:

The Transfer Money logic is as follows:

  1. The IIOP Client (IIOPClient.java) obtains a reference to the TellerRemote (TellerRemote.java) remote object from Teller Server (TellerServer.java).

  2. The IIOP Client (IIOPClient.java) invokes the transferMoney() method of the TellerRemote (TellerRemote.java) object.

  3. The TellerRemote (TellerRemote.java) invokes the TransferMoney() method on the JDO Client (Teller.java).

  4. The JDO Client (Teller.java) obtains a configured PersistenceManagerFactory from the JDOAdapter.

  5. The JDO Client (Teller.java)  uses the configured PMF to get a PersistenceManager.

  6. The JDO Client (Teller.java)  uses the Persistence Manager to obtain a Transaction object.

  7. The JDO Client (Teller.java) begins a new Transaction using the Transaction object.

  8. The JDO Client (Teller.java) invokes the credit method on the Checking object.

  9. The JDO Client (Teller.java) then invokes the debit method on the Savings object.

  10. The JDO Client (Teller.java) then commits the transaction by invoking the method in the Transaction object.

  11. The JDO Client (Teller.java) then closes the Persistence Manager.

  12. The JDO Client (Teller.java) then closes the JDOAdapter.

 

 

com/hywy/samples/remote/TellerRemote.java
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
/**
  * The following example illustrates an RMI Server
  *
  * author: Gopalan Suresh Raj
  * Copyright (c), 2002. All Rights Reserved.
  * URL: https://gsraj.tripod.com/
  * email: gopalan@gmx.net
  */


package com.hywy.samples.remote;

import java.rmi.Remote;
import java.rmi.RemoteException;

import java.util.ArrayList;

/**
* This is an interface to a component that
* functions as a Teller to a Bank
*
* @author Gopalan Suresh Raj
*/

public interface TellerRemote extends Remote {

  /**
   * Create Checking or Savings Account
   */

  void createAccount(String customerNames,
                     int startingBalance,
                     boolean isCheckingAccount) throws RemoteException;

  /**
   * Delete and close the account
   */

  void deleteAccount(long accountNumber) throws RemoteException;

  /**
   * Transfer Money
   */

  boolean transferMoney(long fromAccountNumber,
                        long toAccountNumber,
                        int amount) throws RemoteException;
  /**
   * List out all Checking accounts found
   */

  ArrayList listAllCheckingAccounts() throws RemoteException;

  /**
   * List out all Savings accounts found
   */

  ArrayList listAllSavingsAccounts() throws RemoteException;

}

 

click here to go to
My JDO HomePage...

click here to go to
My Advanced Java Tutorial Page...

About the Author...
Gopalan Suresh Raj is a Software Architect, Developer and an active Author. He has co-authored a number of books including "Professional JMS", "Enterprise Java Computing-Applications and Architecture" and "The Awesome Power of JavaBeans". His expertise spans enterprise component architectures and distributed object computing. Visit him at his Web Cornucopia© site (https://gsraj.tripod.com/) or mail him at gopalan@gmx.net.

Go to the Component Engineering Cornucopia page

This site was developed and is maintained by Gopalan Suresh Raj

This page has been visited times since February 26,2002.

Last Updated : Feb 26, 2002

If you have any questions, comments, or problems regarding this site, please write to me I would love to hear from you.


Copyright (c) 1997-2002, Gopalan Suresh Raj - All rights reserved. Terms of use.

All products and companies mentioned at this site are trademarks of their respective owners.