forked from dtschust/javapacman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathServidorPac.java
47 lines (47 loc) · 1.21 KB
/
ServidorPac.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import java.rmi.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.geom.Point2D;
import javax.swing.JApplet;
import java.awt.*;
import java.util.List;
import java.lang.*;
class ServidorPac extends JApplet
{
static public void main (String args[]) {
// Elimina la necesidad de permisos en linea de comando
System.setProperty("java.security.policy", "servidor.permisos");
// Elimina la capacidad de elegir puerto
String puerto="55555";
if (args.length>=2) {
System.err.println("Uso: ServidorPac [<Ip de Salida>]");
return;
}
if (args.length==1) {
System.setProperty("java.rmi.server.hostname", args[0]);
}
if (System.getSecurityManager()==null) {
System.setSecurityManager(new RMISecurityManager());
}
try {
ServicioPacImpl srv=new ServicioPacImpl();
Naming.rebind("rmi://localhost:"+puerto+"/Pacman", srv);
}
catch (RemoteException e) {
System.err.println("Error de comunicacion: "+e.toString());
System.exit(1);
}
catch (Exception e) {
System.err.println("Excepcion en ServidorPac:");
e.printStackTrace();
System.exit(1);
}
}
}
/*
rm *.class
javac *.java
export CLASSPATH=$PWD
rmiregistry 54321
java -Djava.security.policy=servidor.permisos ServidorPac 54321
*/