ConnectionImpl implements InvocationHandler, Connection { public void end() { if (--beginCalls <= 0) { synchronized (resultStack) { if (resultStack.isEmpty()) { writeResult(LispWriter.NIL); } else { while (!resultStack.isEmpty()) { writeResult(resultStack.removeLast()); } } } if (global != null) { try { global.getNameSpace().setVariable(variableName, null, true); } catch (bsh.UtilEvalError ee) { } } synchronized (ConnectionFactory.connectionLock) { ConnectionFactory.currentConnection = null; } } logger.debug("*** end " + beginCalls); } ConnectionImpl();  ConnectionImpl(This global, Map impls, String variableName); void setOutput(PrintWriter writer); Object invoke(Object object, Method method, Object[] args); void begin(); void end(); void reset(); void pushResult(Object result); Object popResult(); Object peekResult(); void setLoggerFilename(String filename); void evalBshScript(final String statement);  }
@Test public void testConnectionProxy2CallJava2() throws Exception { Echo echo = (Echo) ConnectionFactory.getConnection(EchoImpl.class, null, null); assertEquals("hello world", echo.ack("hello world")); ((Connection) echo).end(); }