Changeset 70 for trunk/src/main/java/omq/common/broker/Broker.java
- Timestamp:
- 06/28/13 12:41:11 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/main/java/omq/common/broker/Broker.java
r66 r70 2 2 3 3 import java.io.IOException; 4 import java.lang.reflect.Proxy; 4 5 import java.net.URL; 5 6 import java.util.HashMap; … … 10 11 import omq.Remote; 11 12 import omq.client.listener.ResponseListener; 13 import omq.client.proxy.MultiProxymq; 12 14 import omq.client.proxy.Proxymq; 13 15 import omq.common.event.Event; … … 46 48 private Map<String, RemoteObject> remoteObjs; 47 49 private Map<String, Object> proxies = new Hashtable<String, Object>(); 50 private Map<String, Object> multiProxies = new Hashtable<String, Object>(); 48 51 49 52 public Broker(Properties env) throws Exception { … … 73 76 responseListener.kill(); 74 77 eventDispatcher.kill(); 75 // TODO proxies = null; ??78 // TODO proxies = null; ?? 76 79 } 77 80 // Stop all the remote objects working … … 136 139 Proxymq proxy = new Proxymq(reference, contract, this); 137 140 Class<?>[] array = { contract }; 138 Object newProxy = Proxy mq.newProxyInstance(contract.getClassLoader(), array, proxy);141 Object newProxy = Proxy.newProxyInstance(contract.getClassLoader(), array, proxy); 139 142 proxies.put(reference, newProxy); 140 143 return (T) newProxy; … … 147 150 } 148 151 152 @SuppressWarnings("unchecked") 153 public synchronized <T extends Remote> T lookupMulti(String reference, Class<T> contract) throws RemoteException { 154 try { 155 if (!multiProxies.containsKey(reference)) { 156 MultiProxymq proxy = new MultiProxymq(reference, contract, this); 157 Class<?>[] array = { contract }; 158 Object newProxy = Proxy.newProxyInstance(contract.getClassLoader(), array, proxy); 159 multiProxies.put(reference, newProxy); 160 return (T) newProxy; 161 } 162 return (T) multiProxies.get(reference); 163 164 } catch (Exception e) { 165 throw new RemoteException(e); 166 } 167 } 168 149 169 public void bind(String reference, RemoteObject remote) throws RemoteException { 150 170 try { … … 155 175 } 156 176 } 157 177 158 178 public void startTriggerEvent(String reference, RemoteObject remote) throws RemoteException { 159 179 try {
Note: See TracChangeset
for help on using the changeset viewer.