throw new Error( "Cannot start HTTP client: " + e );
}
// Create server
server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setHost( host );
connector.setPort( 0 );
server.setConnectors( new Connector[] { connector } );
server.setHandler( new AbstractHandler()
{
public void handle( String target, HttpServletRequest servletRequest, HttpServletResponse response,
int dispatch ) throws IOException,
ServletException
{
Request request = (Request) servletRequest;
try
{
Thread.sleep( 2000 );
}
catch ( InterruptedException e )
{
// TODO Auto-generated catch block
e.printStackTrace();
}
request.setHandled( true );
}
} );
try
{
server.start();
_port = connector.getLocalPort();
}
catch ( Exception e )
{
Log.warn( "Cannot create server: " + e );
}