MatlabProxyFactory implements ProxyFactory { @Override public Request requestProxy(RequestCallback callback) throws MatlabConnectionException { if(callback == null) { throw new NullPointerException("The request callback may not be null"); } return _delegateFactory.requestProxy(callback); } MatlabProxyFactory();  MatlabProxyFactory(MatlabProxyFactoryOptions options); @Override MatlabProxy getProxy(); @Override Request requestProxy(RequestCallback callback);  }
@Test public void requestProxy() throws MatlabConnectionException, MatlabInvocationException, InterruptedException { MatlabProxyFactory factory = new MatlabProxyFactory(); final ArrayBlockingQueue<MatlabProxy> proxyQueue = new ArrayBlockingQueue<MatlabProxy>(1); factory.requestProxy(new MatlabProxyFactory.RequestCallback() { @Override public void proxyCreated(MatlabProxy proxy) { proxyQueue.add(proxy); } }); MatlabProxy proxy = proxyQueue.take(); proxy.exit(); }