prima implementazione distaccata di server . utilizzo di codebase per rmi
This commit is contained in:
30
rmi_test_codebase_separate/Server.java
Normal file
30
rmi_test_codebase_separate/Server.java
Normal 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
11
rmi_test_codebase_separate/i.java
Normal file
11
rmi_test_codebase_separate/i.java
Normal 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;
|
||||||
|
}
|
||||||
12
rmi_test_codebase_separate/messaggio.java
Normal file
12
rmi_test_codebase_separate/messaggio.java
Normal 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;
|
||||||
|
|
||||||
|
}
|
||||||
9
rmi_test_codebase_separate/messaggio_extended.java
Normal file
9
rmi_test_codebase_separate/messaggio_extended.java
Normal 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;
|
||||||
|
}
|
||||||
17
rmi_test_codebase_separate/test.java
Normal file
17
rmi_test_codebase_separate/test.java
Normal 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 {
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user