class ServiceUnavailableHandler implements RejectedExecutionHandler {

    @Override
    public void rejectedExecution(final Runnable r, final ThreadPoolExecutor executor) {
        if (r instanceof ServerRunnable) {
            Socket socket = ((ServerRunnable) r).getSocket();
            try {
                (new HttpError503Handler()).serve(responseFactory.createFromSocket(socket));
            } catch (IOException e) {
            } finally {
                IOUtilities.closeSilently(socket);
            }
        }
    }

    public  ServiceUnavailableHandler(final HttpServletResponseImplFactory responseFactory);

}