Changeset 47 for trunk/src/main/java/omq/common/broker/Broker.java
- Timestamp:
- 06/18/13 16:51:22 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/main/java/omq/common/broker/Broker.java
r44 r47 12 12 import omq.common.event.EventDispatcher; 13 13 import omq.common.event.EventWrapper; 14 import omq.common.util.Environment;15 14 import omq.common.util.OmqConnectionFactory; 16 15 import omq.common.util.ParameterQueue; … … 33 32 private static boolean clientStarted = false; 34 33 private static boolean connectionClosed = false; 34 private static Properties environment = null; 35 35 // TODO ask Pedro if it can be only one object in the map (an object can 36 36 // have multiple threads in the same broker -see environment-) … … 44 44 */ 45 45 public static synchronized void initBroker(Properties env) throws Exception { 46 if ( Environment.isVoid()) {46 if (environment == null) { 47 47 remoteObjs = new HashMap<String, RemoteObject>(); 48 Environment.setEnvironment(env);48 environment = env; 49 49 connection = OmqConnectionFactory.getNewConnection(env); 50 50 channel = connection.createChannel(); … … 67 67 ResponseListener.stopResponseListner(); 68 68 EventDispatcher.stopEventDispatcher(); 69 Proxymq.stopProxy(); 69 70 } 70 71 // Stop all the remote objects working … … 72 73 unbind(reference); 73 74 } 75 74 76 // Close the connection once all the listeners are died 75 77 closeConnection(); 78 79 clientStarted = false; 80 connectionClosed = false; 81 environment = null; 82 remoteObjs = null; 83 Serializer.removeSerializers(); 76 84 } 77 85 … … 87 95 connectionClosed = true; 88 96 connection.close(); 97 connectionClosed = false; 89 98 } 90 99 … … 111 120 public static <T extends Remote> T lookup(String reference, Class<T> contract) throws RemoteException { 112 121 try { 113 Properties environment = Environment.getEnvironment();114 122 115 123 if (!clientStarted) { … … 132 140 public static void bind(String reference, RemoteObject remote) throws RemoteException { 133 141 try { 134 Properties environment = Environment.getEnvironment();135 142 remote.startRemoteObject(reference, environment); 136 143 remoteObjs.put(reference, remote); … … 244 251 } 245 252 try { 246 Properties env = Environment.getEnvironment(); 247 connection = OmqConnectionFactory.getNewWorkingConnection(env); 253 connection = OmqConnectionFactory.getNewWorkingConnection(environment); 248 254 channel = connection.createChannel(); 249 255 addFaultTolerance(); … … 265 271 } 266 272 273 public static Properties getEnvironment() { 274 return environment; 275 } 276 267 277 }
Note: See TracChangeset
for help on using the changeset viewer.