/Users/lyon/j4p/src/net/rmi/rmiimage/Server.java
|
1 /* Remote Server*/
2 package net.rmi.rmiimage;
3
4 import java.rmi.RMISecurityManager;
5 import java.rmi.RemoteException;
6 import java.rmi.registry.LocateRegistry;
7 import java.rmi.registry.Registry;
8 import java.rmi.server.UnicastRemoteObject;
9
10 public class Server
11 extends UnicastRemoteObject
12 implements BenchMark {
13 private String name;
14
15 public Server(String s)
16 throws RemoteException {
17 super();
18 name = s;
19 }
20
21 public void multiplyBench(long range)
22 throws RemoteException {
23 long i, product;
24 int d1, d2;
25 d1 = 2;
26 d2 = 3;
27 for (i = 0; i < range; i++)
28 product = d1 * d2;
29 }
30
31 public static void run() {
32 String args[] = {""};
33 main(args);
34 }
35
36 public static void main(String args[]) {
37 System.setSecurityManager(new RMISecurityManager());
38 Registry r = null;
39 try {
40 Server obj = new Server("HelloServer");
41 try {
42 r = LocateRegistry.createRegistry(1099);
43 } catch (Exception e) {
44 System.out.println(e);
45 }
46 try {
47 r.rebind("HelloServer", obj);
48 } catch (Exception e) {
49 System.out.println(e);
50 }
51 System.out.println("HelloServer bound in registry");
52 } catch (Exception e) {
53 System.out.println("Server err: " + e.getMessage());
54 e.printStackTrace();
55 }
56 }
57 }
58
59
60
61
62
63
64
65
66
67
68
69
70
71