users@glassfish.java.net

Re: An object that runs for the lifetime of the application server???

From: Stephen Connolly <stephen.alan.connolly_at_gmail.com>
Date: Fri, 23 Nov 2007 20:32:55 +0000

Look into a XXXContextListener (I forget what XXX is, but there is a
XXXContextListener) as it is notified when your application is started
up or shutdown. This will include your application being deployed and
undeployed as well, but once your app is deployed it will be notified
of startup and shutdown too.

Perhaps it is only available in a WAR.

Also, I would be careful to check that what you are doing will work in
a clustered environment (NB this is the issue with the singleton
pattern)

-Stephen

On Nov 23, 2007 6:35 PM, <glassfish_at_javadesktop.org> wrote:
> Hi,
>
> What I am trying to do is have an object instantiated at the startup of the application server, stay alive for the lifetime of server and only shut down when the server shuts down.
>
> I want to be able run this component to store state information in runtime memory. Like keeping maps or lists in runtime memory so I don't always have to keep going back to the database for information.
>
> During it's lifetime I want this object to be able to communicate with other application server components (EJBs, make database calls, etc) and be able to have other server components communicate with it.
>
> I was thinking a Custom MBean may be the way to go, but is there something I'm missing from the standard Java EE architecture that would allow for an object like this? Custom MBeans just seem to have a number of issues when interacting with EJBs and other Java EE 5 components.
>
> Any help would be very much appreciated.
> [Message sent by forum member 'bkatnich' (bkatnich)]
>
> http://forums.java.net/jive/thread.jspa?messageID=246958
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>