users@jersey.java.net

Re: [Jersey] Callback hook for when http response finished?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 09 Jul 2009 12:37:07 +0200

On Jul 9, 2009, at 2:52 AM, Marc Hadley wrote:

> You could write a new MessageBodyWriter<File> to override the
> default one. Once you finish writing the last byte to the output
> stream you can delete the temp file.
>

Another solution is to add a Closeable instance to the
CloseableService [1] (which can be injected). The Closeable.close
method on all registered instances are guaranteed to be called after
the response has been sent.

Paul.

[1] https://jersey.dev.java.net/nonav/apidocs/1.1.0-ea/jersey/com/sun/jersey/spi/CloseableService.html

> Marc.
>
> On Jul 8, 2009, at 7:50 PM, Chris Wilkes wrote:
>
>> I'm building up a temp file to return to the user after they hit a
>> POST
>> method in jersey. I'd like to delete that temp file after the user
>> has
>> finished downloading the file.
>>
>> Is there a way to get a notification when a user has finished their
>> download? I'd like to not have to change the return type of my
>> method
>> from File to do this.
>>
>> What do other people do in this situation? Currently I delete the
>> file
>> in a background thread that runs on a timer and deletes old files.
>> I'm
>> worried that if I rely on File.deleteOnExit() that I'll build up
>> thousands of temp files.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>