java decompilation tool and handling request time out

public class ResponseCommunicator
{
    private Logger logger = Logger.getLogger(ResponseCommunicator.class);
    private Timer timer = null;
    private long interval = 60000;

    public ResponseCommunicator()
    {	
    }
    
    public ResponseCommunicator(long interval)
    {
	this.interval = interval;
    }

    /*public void start(final HttpServletResponse res)
    {
	timer = new Timer();
	timer.schedule(new TimerTask()
	{
	    @Override
	    public void run()
	    {
		try
		{
		    PrintWriter pw = res.getWriter();
		    pw.write("");
		    pw.flush();
		}
		catch (Exception e)
		{
		    logger.error("Failed to communicate with client", e);
		}
	    }

	}, interval/2, interval);
    }*/
    
    public void start(final HttpServletResponse res)
    {
	timer = new Timer();
	timer.schedule(new TimerTask()
	{
	    @Override
	    public void run()
	    {
		try
		{
		    OutputStream os = res.getOutputStream();
		    os.write("".getBytes());
		    os.flush();
		}
		catch (Exception e)
		{
		    logger.error("Failed to communicate with client", e);
		}
	    }

	}, interval/2, interval);
    }

    public void stop()
    {
	if (timer != null)
	{
	    timer.cancel();
	    timer.purge();
	}
    }
}

你可能感兴趣的:(request)