Changeset 83 for trunk/src/main/java/omq/common/broker
- Timestamp:
- 07/08/13 13:29:24 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/main/java/omq/common/broker/Broker.java
r74 r83 16 16 import omq.common.util.ParameterQueue; 17 17 import omq.common.util.Serializer; 18 import omq.exception.AlreadyBoundException; 18 19 import omq.exception.InitBrokerException; 19 20 import omq.exception.RemoteException; … … 30 31 import com.rabbitmq.client.ShutdownSignalException; 31 32 33 /** 34 * A "broker" allows a new connection to a RabbitMQ server. Under this 35 * connection it can have binded object and proxies. 36 * 37 * @author Sergi Toda <sergi.toda@estudiants.urv.cat> 38 * 39 */ 32 40 public class Broker { 33 41 … … 65 73 } 66 74 75 /** 76 * This method stops the broker's connection and all the threads created 77 * 78 * @throws Exception 79 */ 67 80 public void stopBroker() throws Exception { 68 81 logger.warn("Stopping broker"); … … 84 97 environment = null; 85 98 remoteObjs = null; 86 // Serializer.removeSerializers();87 99 } 88 100 … … 95 107 } 96 108 109 /** 110 * This method close the broker's connection 111 * 112 * @throws IOException 113 */ 97 114 public void closeConnection() throws IOException { 98 115 logger.warn("Clossing connection"); … … 103 120 104 121 /** 122 * Return the broker's channel 105 123 * 106 124 * @return Broker's channel … … 121 139 } 122 140 141 /** 142 * Returns the remote object for specified reference. 143 * 144 * @param reference 145 * - Binding name 146 * @param contract 147 * - Remote Interface 148 * @return newProxy 149 * @throws RemoteException 150 */ 123 151 @SuppressWarnings("unchecked") 124 152 public synchronized <T extends Remote> T lookup(String reference, Class<T> contract) throws RemoteException { … … 126 154 127 155 if (!clientStarted) { 128 initClient(environment); 129 clientStarted = true; 156 initClient(); 130 157 } 131 158 … … 144 171 } 145 172 173 /** 174 * Returns the remote object for specified reference. This function returns 175 * an special type of proxy, every method invoked will be multi and 176 * asynchronous. 177 * 178 * @param reference 179 * - Binding name 180 * @param contract 181 * - Remote Interface 182 * @return newProxy 183 * @throws RemoteException 184 */ 146 185 @SuppressWarnings("unchecked") 147 186 public synchronized <T extends Remote> T lookupMulti(String reference, Class<T> contract) throws RemoteException { … … 161 200 } 162 201 163 public void bind(String reference, RemoteObject remote) throws RemoteException { 202 /** 203 * Binds the reference to the specified remote object. This function uses 204 * the broker's environment 205 * 206 * @param reference 207 * - Binding name 208 * @param remote 209 * - RemoteObject to bind 210 * @throws RemoteException 211 * If the remote operation failed 212 * @throws AlreadyBoundException 213 * If name is already bound. 214 */ 215 public void bind(String reference, RemoteObject remote) throws RemoteException, AlreadyBoundException { 164 216 bind(reference, remote, environment); 165 217 } 166 218 167 public void bind(String reference, RemoteObject remote, Properties env) throws RemoteException { 219 /** 220 * Binds the reference to the specified remote object. This function uses 221 * the broker's environment 222 * 223 * @param reference 224 * - Binding name 225 * @param remote 226 * - RemoteObject to bind 227 * @param env 228 * - RemoteObject environment. You can set how many threads will 229 * be listen to the reference, the multiqueue name and the 230 * properties of the object queue and multiqueue 231 * @throws RemoteException 232 * If the remote operation failed 233 * @throws AlreadyBoundException 234 * If name is already bound. 235 */ 236 public void bind(String reference, RemoteObject remote, Properties env) throws RemoteException, AlreadyBoundException { 237 if (remoteObjs.containsKey(reference)) { 238 throw new AlreadyBoundException(reference); 239 } 240 // Try to start the remtoeObject listeners 168 241 try { 169 242 remote.startRemoteObject(reference, this, env); … … 174 247 } 175 248 249 /** 250 * Unbinds a remoteObject from its reference and kills all the threads 251 * created. 252 * 253 * @param reference 254 * - Binding name 255 * @throws RemoteException 256 * If the remote operation failed 257 * @throws IOException 258 * If there are problems while killing the threads 259 */ 176 260 public void unbind(String reference) throws RemoteException, IOException { 177 261 if (remoteObjs.containsKey(reference)) { … … 184 268 } 185 269 186 public void rebind(String name, Remote obj) throws RemoteException { 187 188 } 189 190 /** 191 * This method ensures the client will have only one ResponseListener and 192 * only one EventDispatcher. Both with the same environment. 193 * 194 * @param environment 195 * @throws Exception 196 */ 197 private synchronized void initClient(Properties environment) throws Exception { 270 /** 271 * This method ensures the client will have only one ResponseListener. 272 * 273 * @throws Exception 274 */ 275 private synchronized void initClient() throws Exception { 198 276 if (responseListener == null) { 199 277 responseListener = new ResponseListener(this); 200 278 responseListener.start(); 279 clientStarted = true; 201 280 } 202 281 }
Note: See TracChangeset
for help on using the changeset viewer.