private HttpClient getTemplateServerClient ( String remoteSource ) throws IOException { // TODO: this was copied from the RemoteCompiler class. This needs // to be moved into a location where both can access it! int port = 80 ; String host = remoteSource . substring ( RemoteCompilationProvider . TEMPLATE_LOAD_PROTOCOL . length ( ) ) ; int portIndex = host . indexOf ( "/" ) ; if ( portIndex >= 0 ) { host = host . substring ( 0 , portIndex ) ; } portIndex = host . indexOf ( ":" ) ; if ( portIndex >= 0 ) { try { port = Integer . parseInt ( host . substring ( portIndex + 1 ) ) ; } catch ( NumberFormatException nfe ) { System . out . println ( "Invalid port number specified" ) ; } host = host . substring ( 0 , portIndex ) ; } // TODO: remove the hardcoded 15 second timeout! SocketFactory factory = new PooledSocketFactory ( new PlainSocketFactory ( InetAddress . getByName ( host ) , port , 15000 ) ) ; return new HttpClient ( factory ) ; }
returns a socket connected to a host running the TemplateServerServlet