@Override public void start(String tapeName, Map arguments) { if (interceptor == null) { try { interceptor = new ProxyServer(this); } catch (UnknownHostException e) { throw new RuntimeException("Unable to start proxy", e); } } if (!interceptor.isRunning()) { interceptor.start(); } super.start(tapeName, arguments); }
@Override public void stop() { interceptor.stop(); super.stop(); }
/** @return a `java.net.Proxy` instance configured to point to the Betamax proxy. */ public Proxy getProxy() { return new Proxy( Proxy.Type.HTTP, new InetSocketAddress(interceptor.getHost(), interceptor.getPort())); }
/** @return the hostname or address where the proxy will run. */ public String getProxyHost() { return interceptor.getHost(); }