prima implementazione distaccata di server . utilizzo di codebase per rmi

This commit is contained in:
2014-12-08 23:55:52 +01:00
commit 001a70c05d
5 changed files with 79 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
package rmi_test_codebase_separate;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
/**
* Created by Giovanni on 08/12/2014.
*/
public class Server {
public static void main (String[] args) {
try {
System.setSecurityManager(new SecurityManager());
i a = new test();
Registry r = LocateRegistry.getRegistry();
r.rebind("server",a);
} catch (RemoteException e) {
e.printStackTrace();
}
}
}

View File

@@ -0,0 +1,11 @@
package rmi_test_codebase_separate;
import java.rmi.Remote;
import java.rmi.RemoteException;
/**
* Created by Giovanni on 08/12/2014.
*/
public interface i extends Remote {
public messaggio message() throws RemoteException;
}

View File

@@ -0,0 +1,12 @@
package rmi_test_codebase_separate;
import java.io.Serializable;
/**
* Created by Giovanni on 08/12/2014.
*/
public class messaggio implements Serializable {
public int variable = 1;
}

View File

@@ -0,0 +1,9 @@
package rmi_test_codebase_separate;
/**
* Created by Giovanni on 08/12/2014.
*/
public class messaggio_extended extends messaggio {
public int variable2 = 2;
}

View File

@@ -0,0 +1,17 @@
package rmi_test_codebase_separate;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
/**
* Created by Giovanni on 08/12/2014.
*/
public class test extends UnicastRemoteObject implements i {
@Override
public messaggio message() throws RemoteException{
return new messaggio_extended();
}
public test() throws RemoteException {
}
}