users@jsr311.java.net

Re: Application class

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 10 Feb 2010 12:08:12 +0100

On Feb 9, 2010, at 7:19 PM, Marc Hadley wrote:

> On Feb 9, 2010, at 1:00 PM, Eli Doran wrote:
>
>> The Application class as a bridge between an app and the server
>> managing things is very helpful.
>> It seems to be missing one thing though ... It isn't told when it's
>> time to *destroy* the application.
>> Some of the singletons returned by Application#getSingletons() may
>> need special attention at 'destroy' time.
>> What's the expected implementation for handling that situation with
>> the current version?
>> It seems to me I can't simply pass an Application subclass to the
>> server. I have to make a filter, servlet, or listener which will be
>> notified of 'destroy' time.
>>
>> In short:
>> The "Application" javadoc states "Defines the components of a JAX-
>> RS application and supplies additional metadata."
>> After it provides the components to the server a reciprocal action
>> to signify the server is done with them would be great.
>>
>> What do you think?
>>
> In a container that supports managed beans (EE6, JSR 299) you can
> make the Application class a managed bean and then use the
> @PreDestroy annotation to get what you want.
>

Yes,

   @ManagedBean
   public MyApp extends Application {
     @PreDestroy
     public void destroy() { ... }
   }

Paul.