users@jersey.java.net

CloseableService

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 17 Mar 2009 17:38:46 +0100

Hi,

As part of the MIME multipart fixes (detail in my previous email) i
have added a closeable service, that we have discussed on another
thread.

Here is a contrived example, which essentially duplicates the
functionality of @PreDestroy:

     @Path("/")
     public static class PerRequestResource implements Closeable {
         @Context CloseableService cs;

         @GET
         public String doGet() {
             cs.add(this);
         }

         public void close() throws IOException {
            // Do some stuff
         }
     }

This service is of more interest to message body readers or injectable
providers that create instances of something that consume resources,
which need cleaned up when the request goes out of scope.

Paul.