/Users/lyon/j4p/src/net/rmi/rmiSynth/RMIServer.java
|
1 //This class was created automatically by CentiJ
2 package net.rmi.rmiSynth;
3
4 import java.rmi.AlreadyBoundException;
5 import java.rmi.RMISecurityManager;
6 import java.rmi.RemoteException;
7 import java.rmi.registry.LocateRegistry;
8 import java.rmi.registry.Registry;
9
10 public class RMIServer
11 extends java.rmi.server.UnicastRemoteObject
12 implements RMIInterface {
13
14 private net.rmi.rmiSynth.LocalServer ls;
15
16 public RMIServer(LocalServer _ls)
17 throws java.rmi.RemoteException {
18 ls = _ls;
19 }
20
21 public RMIServer()
22 throws java.rmi.RemoteException {
23 super();
24 }
25
26
27 public long getBenchMark()
28 throws java.rmi.RemoteException {
29 return ls.getBenchMark();
30 }
31
32 public void hello()
33 throws java.rmi.RemoteException {
34 ls.hello();
35 }
36
37 public java.lang.String getHello()
38 throws java.rmi.RemoteException {
39 return ls.getHello();
40 }
41
42 public void multiplyBench(long p0)
43 throws java.rmi.RemoteException {
44 ls.multiplyBench(p0);
45 }
46
47 public static void main(String args[]) {
48 try {
49 serverFactory(new LocalServer(),
50 RMIInterface.SERVER_NAME);
51 } catch (Exception e) {
52 e.printStackTrace();
53 }
54
55 }
56
57 /**
58 * Use the serverFactor to start the RMIServer
59 * with an arbitrary LocalServer instance.
60 */
61
62 public static void serverFactory(
63 LocalServer ls, String serverName)
64 throws RemoteException,
65 AlreadyBoundException {
66 // Create and install a security manager
67 Registry r = getRegistry();
68 RMIServer rs = new RMIServer(ls);
69 r.bind(serverName, rs);
70 System.out.println(
71 "RMIServer is running");
72 }
73
74 private static Registry getRegistry()
75 throws RemoteException {
76 System.setSecurityManager(
77 new RMISecurityManager());
78 //Create the registry and bind the Server class to the registry
79 LocateRegistry.createRegistry(1099);
80 return LocateRegistry.getRegistry();
81 }
82
83 }