@Test public void testSuccessfulHandshake() throws Exception { final FakeObjectChannel channel = new FakeObjectChannel(Arrays.asList(new Handshake(), new SocketTimeoutException())); SocketServerInstanceImpl instance = createInstance(channel); ILogon logon = instance.getService(ILogon.class); try { logon.logon(new Properties()); fail("Exception expected"); } catch (SingleInstanceCommunicationException e) { assertTrue(e.getCause() instanceof TimeoutException); } }
@Override public synchronized <T> T getService(Class<T> iface) { Object service = this.serviceMap.get(iface); if (service == null) { service = Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {iface}, new RemoteInvocationHandler(iface, false) { @Override protected SocketServerInstanceImpl getInstance() { return SocketServerInstanceImpl.this; } }); this.serviceMap.put(iface, service); } return iface.cast(service); }
SocketServerInstanceImpl implements SocketServerInstance { @Override public synchronized <T> T getService(Class<T> iface) { Object service = this.serviceMap.get(iface); if (service == null) { service = Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {iface}, new RemoteInvocationHandler(iface, false) { @Override protected SocketServerInstanceImpl getInstance() { return SocketServerInstanceImpl.this; } }); this.serviceMap.put(iface, service); } return iface.cast(service); } }
SocketServerInstanceImpl implements SocketServerInstance { @Override public synchronized <T> T getService(Class<T> iface) { Object service = this.serviceMap.get(iface); if (service == null) { service = Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {iface}, new RemoteInvocationHandler(iface, false) { @Override protected SocketServerInstanceImpl getInstance() { return SocketServerInstanceImpl.this; } }); this.serviceMap.put(iface, service); } return iface.cast(service); } SocketServerInstanceImpl(HostInfo info, long synchTimeout, int soTimeout); }
SocketServerInstanceImpl implements SocketServerInstance { @Override public synchronized <T> T getService(Class<T> iface) { Object service = this.serviceMap.get(iface); if (service == null) { service = Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {iface}, new RemoteInvocationHandler(iface, false) { @Override protected SocketServerInstanceImpl getInstance() { return SocketServerInstanceImpl.this; } }); this.serviceMap.put(iface, service); } return iface.cast(service); } SocketServerInstanceImpl(HostInfo info, long synchTimeout, int soTimeout); synchronized void connect(ObjectChannelFactory channelFactory); @Override HostInfo getHostInfo(); @Override InetAddress getLocalAddress(); @Override String getServerVersion(); boolean isOpen(); void send(Message message, ResultsReceiver<Object> listener, Serializable messageKey); void shutdown(); Cryptor getCryptor(); void read(long timeout, TimeUnit unit, ResultsFuture<?> future); @Override synchronized T getService(Class<T> iface); long getSynchTimeout(); }
SocketServerInstanceImpl implements SocketServerInstance { @Override public synchronized <T> T getService(Class<T> iface) { Object service = this.serviceMap.get(iface); if (service == null) { service = Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {iface}, new RemoteInvocationHandler(iface, false) { @Override protected SocketServerInstanceImpl getInstance() { return SocketServerInstanceImpl.this; } }); this.serviceMap.put(iface, service); } return iface.cast(service); } SocketServerInstanceImpl(HostInfo info, long synchTimeout, int soTimeout); synchronized void connect(ObjectChannelFactory channelFactory); @Override HostInfo getHostInfo(); @Override InetAddress getLocalAddress(); @Override String getServerVersion(); boolean isOpen(); void send(Message message, ResultsReceiver<Object> listener, Serializable messageKey); void shutdown(); Cryptor getCryptor(); void read(long timeout, TimeUnit unit, ResultsFuture<?> future); @Override synchronized T getService(Class<T> iface); long getSynchTimeout();  }