Si supponga che una macchina virtuale "server" crei un oggetto di tipo ServerImpl, e che una macchina virtuale "client" esegua un main che usa una variabile server che fa riferimento all'oggetto remoto ServerImpl sul "server", e che esegue le seguenti linee di codice:codice:public interface Server extends Remote { void send(Object[] a) throws RemoteException; } public interface ContRemoto extends Remote { void incr() throws RemoteException; } public class ContRemotoImpl extends UnicastRemoteObject implements ContRemoto { private int n=0; public ContRemotoImpl() throws RemoteException { super(); } public void incr() throws RemoteException { n++; } public int val() { return n; } } public class Contatore implements Serializable { private int n=0; public void incr() { n++; } public int val() { return n; } } class ServerImpl extends UnicastRemoteObject implements Server { public void send(Object[] a) throws RemoteException { ((Contatore)a[0]).incr(); ((ContRemoto)a[1]).incr(); } ............ }
Spiegare come viene passato dal "client" al "server" il parametro a della chiamata server.send(a), e che cosa stampa il "client".codice:Object[] a = new Object[2]; a[0] = new Contatore(); a[1] = new ContRemotoImpl(); server.send(a); System.out.println(((Contatore)a[0]).val()); System.out.println(((ContRemotoImpl)a[1]).val());
1) Come viene passato??? E' giusto dire che il chiama un metodo del proxy ed esso invia la richiesta al proxy (del server) il quale ottenuta la richiesta chiama a sua volta il metodo del server. Il server restituisce al proxy il risultato che esso trasmette al proxy (del client) il risultato e il proxy del client restituisce il risultato al client.
2) Cosa stampa il client... 0 e 1 giusto????
Grazie

