0% found this document useful (0 votes)
50 views4 pages

RMI-Based Banking Application Design

The document describes an RMI-based distributed banking application with the following components: 1. Banque and BanqueNotification interfaces that define remote methods for account operations and notifications. 2. Compte and Position classes that model accounts with balances and transaction histories. 3. BanqueImpl class that implements the Banque interface and manages accounts locally in a Hashtable. 4. BanqueNotificationImpl class that implements notifications when account balances drop below a threshold. 5. BanqueClient class that acts as a client, creating accounts and registering for notifications.

Uploaded by

Majdi Boyka
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views4 pages

RMI-Based Banking Application Design

The document describes an RMI-based distributed banking application with the following components: 1. Banque and BanqueNotification interfaces that define remote methods for account operations and notifications. 2. Compte and Position classes that model accounts with balances and transaction histories. 3. BanqueImpl class that implements the Banque interface and manages accounts locally in a Hashtable. 4. BanqueNotificationImpl class that implements notifications when account balances drop below a threshold. 5. BanqueClient class that acts as a client, creating accounts and registering for notifications.

Uploaded by

Majdi Boyka
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

INSAT 2009-2010

TP 2
Développement d’une application répartie Communicant
par RMI

I. Solution

A. Interface Banque
public interface Banque extends [Link]
{
public void creer_compte(String id, double somme) throws
[Link];
public void ajouter(String id, double somme) throws
[Link];
public void retirer(String id, double somme) throws
[Link];
public Position position(String id) throws [Link];
public void enregistrerNotification(String id, BanqueNotification b,
double minimum) throws [Link];
public void enleverNotification(String id) throws
[Link];
}

B. Interface BanqueNotification
import [Link];
import [Link];
public interface BanqueNotification extends Remote
{
public void notification(double valeur, double mini) throws RemoteException;
}

C. Classe Position
import [Link];
import [Link];
public class Position implements Serializable
{
private double solde;
private Date derniereOperation;
public Position(double solde) {
[Link] = solde; [Link] = new Date();
}
public Date getDerniereOperation() {
return derniereOperation;
}
public void setDerniereOperation(Date derniereOperation) {
[Link] = derniereOperation;
}
1
public double getSolde() {
return solde;
}
public void setSolde(double solde) {

GL2 | TP Applications Réparties


INSAT 2009-2010

[Link] = solde;
}
public String toString() {
return "solde = "+solde+" date dernière op. "+derniereOperation;
}
}

D. Classe Compte
import [Link];
import [Link].*;
import [Link].*;
import [Link].*;
class Compte
{
private Position position;
private BanqueNotification notif;
private double notifMinimum;
public Compte(double somme) {
[Link] = new Position(somme);
}
public Position getPosition() {
return position;
}
public void ajouter(double somme) {
[Link]([Link]()+somme);
[Link](new Date());
}
public void retirer(double somme) {
[Link]([Link]()-somme);
[Link](new Date());
if (notif != null && [Link]() < notifMinimum) {
try{
[Link]([Link](), notifMinimum);
} catch (RemoteException e) {
[Link]();
}
}
}
public void setNotification(BanqueNotification notif, double mini) {
[Link] = notif;
notifMinimum = mini;
}
}

E. Classe BanqueImpl
public class BanqueImpl extends UnicastRemoteObject implements Banque
{
Hashtable comptes;
public BanqueImpl() throws RemoteException {
super();
comptes = new Hashtable(); 2
}
public void creer_compte(String id, double somme) throws RemoteException
{
[Link](id, new Compte(somme));

GL2 | TP Applications Réparties


INSAT 2009-2010

}
public void ajouter(String id, double somme) throws RemoteException {
Compte cpt = (Compte)[Link](id);
[Link](somme);
}
public void retirer(String id, double somme) throws RemoteException {
Compte cpt = (Compte)[Link](id);
[Link](somme);
}
public Position position(String id) throws RemoteException {
Compte cpt = (Compte)[Link](id);
return [Link]();
}
public void enregistrerNotification(String id, BanqueNotification b,
double mini) throws RemoteException {
Compte cpt = (Compte)[Link](id);
[Link](b, mini);
}
public void enleverNotification(String id) throws RemoteException {
Compte cpt = (Compte)[Link](id);
[Link](null, 0);
}
public static void main(String[] args) throws RemoteException,
MalformedURLException {
[Link](new RMISecurityManager());
[Link]("MaBanque", new BanqueImpl());
[Link]("MaBanque est enregistrée");
}
}

F. Classe BanqueNotificationImpl
import [Link];
import [Link];
public class BanqueNotificationImpl implements BanqueNotification,
Unreferenced
{
private String id;
public BanqueNotificationImpl(String id) {
[Link] = id;
}
public void notification(double valeur, double mini) throws
RemoteException {
[Link]("Votre compte "+id+" est inférieur au mini : "+mini+"
solde : "+valeur);
}
public void unreferenced() {
[Link]("La notification pour "+id+" n'est plus utilisée");
}
}

G. Classe BanqueClient
3
import [Link];
import [Link].*;
import [Link];
public class BanqueClient

GL2 | TP Applications Réparties


INSAT 2009-2010

{
public static void main(String[] args) throws MalformedURLException,
RemoteException, NotBoundException {
Banque proxy = (Banque) [Link]("MaBanque");
proxy.creer_compte("Bob", 100);
BanqueNotificationImpl bni = new BanqueNotificationImpl("Bob");
[Link](bni);
[Link]("Bob", bni, 0);
[Link]("Bob", 100);
[Link]("Position du compte de Bob : +[Link]("Bob"));
[Link]("Bob", 300);
[Link]("Bob", 100);
[Link]("Position du compte de Bob : +[Link]("Bob"));
bni = null;
[Link]("Bob");
}
}

GL2 | TP Applications Réparties

You might also like