1 21 package org.jacorb.imr; 22 23 import java.util.*; 24 25 import org.jacorb.imr.RegistrationPackage.*; 26 import org.jacorb.imr.AdminPackage.*; 27 28 39 40 public class ImRServerInfo 41 implements java.io.Serializable 42 { 43 protected String command; 44 protected boolean holding = false; 45 protected String host; 46 protected String name; 47 protected boolean active; 48 protected boolean restarting = false; 49 50 private Vector poas = null; 51 private ResourceLock poas_lock = null; 52 53 64 65 public ImRServerInfo(String name, String host, String command) 66 throws IllegalServerName 67 { 68 if (name == null || name.length() == 0) 69 throw new IllegalServerName(name); 70 71 this.name = name; 72 this.host = host; 73 this.command = command; 74 active = false; 75 poas = new Vector(); 76 poas_lock = new ResourceLock(); 77 } 78 79 85 86 public ServerInfo toServerInfo() 87 { 88 poas_lock.gainExclusiveLock(); 89 90 94 POAInfo[] _poas = new POAInfo[poas.size()]; 96 Enumeration _poa_enum = poas.elements(); 97 98 int _i = 0; 100 while(_poa_enum.hasMoreElements()) 101 _poas[_i++] = ((ImRPOAInfo) _poa_enum.nextElement()).toPOAInfo(); 102 103 poas_lock.releaseExclusiveLock(); 104 105 return new ServerInfo(name, command, _poas, host, active, holding); 106 } 107 108 113 114 public void addPOA(ImRPOAInfo poa) 115 { 116 if (! active) 117 active = true; 118 119 poas_lock.gainSharedLock(); 120 poas.addElement(poa); 121 poas_lock.releaseSharedLock(); 122 } 123 124 130 131 protected String [] getPOANames() 132 { 133 String [] _poa_names = new String [poas.size()]; 136 Enumeration _poa_enum = poas.elements(); 137 138 int _i = 0; 139 while(_poa_enum.hasMoreElements()) 140 _poa_names[_i++] = ((ImRPOAInfo) _poa_enum.nextElement()).name; 141 142 return _poa_names; 143 } 144 145 151 152 public void setDown() 153 { 154 for (int _i = 0; _i < poas.size(); _i++) 156 ((ImRPOAInfo) poas.elementAt(_i)).active = false; 157 158 active = false; 159 restarting = false; 160 } 161 162 167 168 public synchronized void awaitRelease() 169 { 170 while(holding) 171 { 172 try 173 { 174 wait(); 175 } 176 catch (java.lang.Exception _e) 177 { 178 } 179 } 180 } 181 182 185 186 public synchronized void release() 187 { 188 holding = false; 189 notifyAll(); 190 } 191 192 202 203 public synchronized boolean shouldBeRestarted() 204 { 205 boolean _restart = !(active || restarting); 206 if (_restart) 207 restarting = true; 208 209 return _restart; 210 } 211 212 public void setNotRestarting() 213 { 214 restarting = false; 215 } 216 217 } 219 | Popular Tags |