public static ServiceProxyImpl forService(ServiceImpl owner, OmiscidService omiscidService) { Map<Integer, ProxyInfo> proxies; synchronized (proxyForService) { proxies = proxyForService.get(owner); if (proxies == null) { proxies = new Hashtable<Integer, ProxyInfo>(); proxyForService.put(owner, proxies); } } ProxyInfo proxyInfo; synchronized (proxies) { proxyInfo = proxies.get(omiscidService.getRemotePeerId()); if (proxyInfo == null) { proxyInfo = new ProxyInfo(); proxies.put(omiscidService.getRemotePeerId(), proxyInfo); } } synchronized (proxyInfo) { long now = System.currentTimeMillis(); if (proxyInfo.timeout < now) { try { proxyInfo.serviceProxyImpl = new ServiceProxyImpl(omiscidService); proxyInfo.timeout = Long.MAX_VALUE; // ignoring timeout for now //now + ???; } catch (RuntimeException e) { proxyInfo.serviceProxyImpl = null; proxyInfo.timeout = now; } } } return proxyInfo.serviceProxyImpl; // return new ServiceProxyImpl(omiscidService); }
/* (non-Javadoc) * @see fr.prima.bip.service.BipServiceProxy#getPeerId() */ public int getPeerId() { return omiscidService.getRemotePeerId(); }