/** * Entry point. * * @param args Command line arguments. */ public static void main(String[] args) { final Resources resources = new ResourcesImplementation("net.grinder.console.common.resources.Console"); final Logger logger = new SimpleLogger( resources.getString("shortTitle"), new PrintWriter(System.out), new PrintWriter(System.err)); try { final Console console = new Console(args, resources, logger); console.run(); } catch (LoggedInitialisationException e) { System.exit(1); } catch (GrinderException e) { logger.error("Could not initialise:"); final PrintWriter errorWriter = logger.getErrorLogWriter(); e.printStackTrace(errorWriter); errorWriter.flush(); System.exit(2); } System.exit(0); }
/** * Constructor. * * @param socketFactory Socket factory for creating our server and client sockets. * @param requestFilter Request filter. * @param responseFilter Response filter. * @param logger Logger. * @param localEndPoint Local host and port to listen on. If the <code>EndPoint</code>'s port is * 0, an arbitrary port will be assigned. * @param useColour Whether to use colour. * @param timeout Timeout for server socket in milliseconds. * @exception IOException If an I/O error occurs. */ public AbstractTCPProxyEngine( TCPProxySocketFactory socketFactory, TCPProxyFilter requestFilter, TCPProxyFilter responseFilter, Logger logger, EndPoint localEndPoint, boolean useColour, int timeout) throws IOException { m_logger = logger; m_outputWriter = logger.getOutputLogWriter(); m_socketFactory = socketFactory; m_requestFilter = requestFilter; m_responseFilter = responseFilter; if (useColour) { m_requestColour = TerminalColour.RED; m_responseColour = TerminalColour.BLUE; } else { m_requestColour = TerminalColour.NONE; m_responseColour = TerminalColour.NONE; } m_serverSocket = m_socketFactory.createServerSocket(localEndPoint, timeout); }