users@servlet-spec.java.net

[servlet-spec users] [jsr369-experts] Re: Request/Connection cancellation

From: Greg Wilkins <gregw_at_webtide.com>
Date: Sun, 18 Oct 2015 11:06:27 +1100

On 17 October 2015 at 23:38, Stuart Douglas <sdouglas_at_redhat.com> wrote:

> This seems reasonable, but we should probably include some kind of thread
> safety warning in the docs. The listener will be invoked by a different
> thread to the one that is currently processing, so the end user must take
> care to make sure the listener/processing code is thread safe.
>

+1


> I am also not convinced that ServletRequestListener is the best place for
> this. Likely only specific long running requests will need this
> functionality, and I think that is may make more sense for them to
> explicitly register a listener with the request.
>

I share this concern. Perhaps simplest to create a new Listener that has
to be explicitly set via ServletRequest#addListener on a particular request:

  interface ServletRequestCancellationListener
  {
    void cancelled(ServletRequestCancellationEvent e);
  }

Plus single method interfaces a sooo fashionable at the moment :)



-- 
Greg Wilkins <gregw@webtide.com> CTO http://webtide.com