KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SOFA > SOFAnet > Admin > RMI > RMIAdminCenter


1 /*
2  * RMIAdminCenter.java
3  *
4  * Created on 10. květen 2004, 20:38
5  */

6
7 package SOFA.SOFAnet.Admin.RMI;
8
9 import SOFA.SOFAnet.Core.*;
10 import SOFA.SOFAnet.Repository.Repository;
11 import SOFA.SOFAnet.Repository.NodeInfo;
12 import SOFA.SOFAnet.TR.TRInterface;
13 import SOFA.SOFAnet.Search.RMI.RMISearchCenter;
14 import java.rmi.RemoteException JavaDoc;
15 import java.rmi.Naming JavaDoc;
16 import java.net.MalformedURLException JavaDoc;
17
18 /**
19  * Managing class of RMI implementation of "admin interface" of the SOFAnet.
20  * This interface is used by SOFA runtime.
21  *
22  * @author Ladislav Sobr
23  */

24 public class RMIAdminCenter
25 {
26   private TRInterface tr;
27   private Repository rep;
28   private LocalOps localOps;
29   private NetOps netOps;
30   private ShareOps shareOps;
31   private SearchOps searchOps;
32   private RMISearchCenter rmiSearchCenter;
33
34   private RMIAdminServer server;
35   
36   boolean started;
37   private String JavaDoc myNodeName;
38   
39   /** Creates a new instance of RMIAdminCenter */
40   public RMIAdminCenter()
41   {
42     started = false;
43     server = null;
44     myNodeName = NodeInfo.getLocalNodeName();
45   }
46
47   public void setRepository(Repository repository)
48   {
49     rep = repository;
50   }
51   
52   public void setTRInterface(TRInterface tr)
53   {
54     this.tr = tr;
55   }
56   
57   public void setLocalOps(LocalOps localOps)
58   {
59     this.localOps = localOps;
60   }
61
62   public void setNetOps(NetOps netOps)
63   {
64     this.netOps = netOps;
65   }
66   
67   public void setShareOps(ShareOps shareOps)
68   {
69     this.shareOps = shareOps;
70   }
71   
72   public void setSearchOps(SearchOps searchOps)
73   {
74     this.searchOps = searchOps;
75   }
76
77   public void setRMISearchCenter(RMISearchCenter rmiSearchCenter)
78   {
79     this.rmiSearchCenter = rmiSearchCenter;
80   }
81   
82   /** Starts RMI administration subsystem */
83   public void start() throws RMIAdminException
84   {
85     started = true;
86
87     //run RMI admin server
88

89     NodeInfo myNodeInfo = new NodeInfo();
90     try
91     {
92       myNodeInfo.setNodeName(myNodeName);
93     }
94     catch (NodeInfo.InvalidNodeNameException e)
95     {
96       throw new RMIAdminException("Invalid name of admin SOFA node: " + myNodeName, e);
97     }
98     
99     try
100     {
101       server = new RMIAdminServer(tr, rep, localOps, netOps, shareOps, searchOps, rmiSearchCenter);
102       Naming.rebind("//" + myNodeInfo.getAddressAndPort() + "/SOFAnet/RMIAdminServer", server);
103     }
104     catch (RemoteException JavaDoc e)
105     {
106       throw new RMIAdminException("RMI admin server failed to start", e);
107     }
108     catch (MalformedURLException JavaDoc e)
109     {
110       throw new RMIAdminException("RMI admin server failed to start", e);
111     }
112   }
113
114   boolean isStarted()
115   {
116     return started;
117   }
118 }
119
Popular Tags