creato rmi counter. verifica blanda di errori di input
This commit is contained in:
@@ -15,8 +15,7 @@ public class HelloWorldImpl extends UnicastRemoteObject implements HelloWorldInt
|
||||
}
|
||||
|
||||
@Override
|
||||
public String stampa(String in) throws RemoteException {
|
||||
System.out.print(in);
|
||||
return in;
|
||||
public String stampa() throws RemoteException {
|
||||
return "HelloWorld";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,6 @@ import java.rmi.RemoteException;
|
||||
public interface HelloWorldInterface extends Remote {
|
||||
|
||||
|
||||
String stampa (String in) throws RemoteException;
|
||||
String stampa () throws RemoteException;
|
||||
|
||||
}
|
||||
|
||||
39
rmi_hello_world/LaunchClient.java
Normal file
39
rmi_hello_world/LaunchClient.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package rmi_hello_world;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.rmi.Naming;
|
||||
import java.rmi.NotBoundException;
|
||||
import java.rmi.RemoteException;
|
||||
import java.rmi.registry.LocateRegistry;
|
||||
import java.rmi.registry.Registry;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Created by Giovanni on 16/11/2014.
|
||||
*/
|
||||
public class LaunchClient {
|
||||
|
||||
private static final Logger l = Logger.getLogger("Client");
|
||||
|
||||
public static void main (String[] arg) {
|
||||
|
||||
|
||||
try {
|
||||
l.info("Cercando l'oggetto remoto");
|
||||
HelloWorldInterface o = (HelloWorldInterface) Naming.lookup("rmi://localhost/HW");
|
||||
l.info("Found");
|
||||
l.info(o.stampa());
|
||||
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NotBoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -10,19 +10,19 @@ import java.util.logging.Logger;
|
||||
/**
|
||||
* Created by Giovanni on 09/11/2014.
|
||||
*/
|
||||
public class Launch {
|
||||
public class LaunchServer {
|
||||
|
||||
|
||||
public static void main (String[] arg){
|
||||
|
||||
Logger l =Logger.getLogger("hellowordlogger");
|
||||
System.setSecurityManager(new RMISecurityManager());
|
||||
System.setSecurityManager(new SecurityManager());
|
||||
|
||||
try {
|
||||
Registry registry = LocateRegistry.createRegistry(10000);
|
||||
Registry registry = LocateRegistry.getRegistry();
|
||||
HelloWorldImpl obj = new HelloWorldImpl();
|
||||
l.info("Creato oggetto");
|
||||
registry.bind("HW",obj);
|
||||
registry.rebind("HW", obj);
|
||||
l.info("Oggetto registrato");
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user