Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Interface Parc
- package parc;
- import java.rmi.Remote;
- import java.rmi.RemoteException;
- public interface ParcInt extends Remote {
- public int nbPlacesLibres() throws RemoteException;
- public void entreeVisiteur() throws RemoteException;
- public void sortieVisiteur() throws RemoteException;
- }
- //Implementation Parc
- package parc;
- import java.rmi.RemoteException;
- import java.rmi.server.UnicastRemoteObject;
- public class Parc extends UnicastRemoteObject implements ParcInt {
- private int places = 200;
- public Parc() throws RemoteException {
- super();
- }
- @Override
- public int nbPlacesLibres() throws RemoteException {
- return places;
- }
- @Override
- public void entreeVisiteur() throws RemoteException {
- places--;
- }
- @Override
- public void sortieVisiteur() throws RemoteException {
- if(places < 200) places++;
- }
- }
- //Serveur Parc
- package parc;
- import java.rmi.Naming;
- import java.rmi.registry.LocateRegistry;
- public class ParcServer {
- public static void main(String[] args) {
- try {
- Parc p = new Parc();
- LocateRegistry.createRegistry(1099);
- Naming.rebind("rmi://localhost/parc", p);
- } catch (Exception e) {
- System.out.println(e.toString());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement