Re: App-level globals
I actually went the plug-in route, that seems to work very nicely. Is there any benefit of a ContextListener vs. a plug-in? The only obvious one that comes to mind is that a plug-in is Struts-specific, so your tied to that framework, but that seems a pretty smalll consideration since there's plenty more that ties you to Struts as an app is developed. Thanks! From: "Jacob Weber" <[EMAIL PROTECTED]> Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Subject: Re: App-level globals Date: Mon, 17 May 2004 12:32:18 -0400 You can make a ContextListener class like this: public final class MyContextListener implements ServletContextListener { private ServletContext context = null; public BaseServletContextListener() {} public void contextInitialized(ServletContextEvent event) { this.context = event.getServletContext(); // run your initialization routine here } public void contextDestroyed(ServletContextEvent event) { this.context = null; } } and put this in your web.xml: path.to.MyContextListener Jacob - Original Message - From: "None None" <[EMAIL PROTECTED]> Newsgroups: gmane.comp.jakarta.struts.user Sent: Monday, May 17, 2004 12:17 PM Subject: App-level globals > Hello again everyone... I am starting conversion of a none-Struts app to > Struts, and mostly it's straight-forward, but two things I have questions > about... > > The home-grown framework this app was written with has the notion of an App > Loader. Basically, this is a class that runs at startup and reads in some > config information and stores it in a static config object. The properties > of this object are referenced throughout the app. > > The other concern is that this same process spawns a couple of low-priority > background threads to do some various things throughout the lifetime of the > app. > > My question, which I have been unable to find an answer to on my own, is if > Struts has a similar startup "initialization" mechanism? If not, do I > simply create my own servlet to do all this work and set it to run on > startup in web.xml? I have no problem with the later approach, but I'm > wondering if Struts has a mechanism for this, like our custom framework > does? > > Thanks all! > > _ > Express yourself with the new version of MSN Messenger! Download today - > it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ FREE pop-up blocking with the new MSN Toolbar get it now! http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: App-level globals
You can make a ContextListener class like this: public final class MyContextListener implements ServletContextListener { private ServletContext context = null; public BaseServletContextListener() {} public void contextInitialized(ServletContextEvent event) { this.context = event.getServletContext(); // run your initialization routine here } public void contextDestroyed(ServletContextEvent event) { this.context = null; } } and put this in your web.xml: path.to.MyContextListener Jacob - Original Message - From: "None None" <[EMAIL PROTECTED]> Newsgroups: gmane.comp.jakarta.struts.user Sent: Monday, May 17, 2004 12:17 PM Subject: App-level globals > Hello again everyone... I am starting conversion of a none-Struts app to > Struts, and mostly it's straight-forward, but two things I have questions > about... > > The home-grown framework this app was written with has the notion of an App > Loader. Basically, this is a class that runs at startup and reads in some > config information and stores it in a static config object. The properties > of this object are referenced throughout the app. > > The other concern is that this same process spawns a couple of low-priority > background threads to do some various things throughout the lifetime of the > app. > > My question, which I have been unable to find an answer to on my own, is if > Struts has a similar startup "initialization" mechanism? If not, do I > simply create my own servlet to do all this work and set it to run on > startup in web.xml? I have no problem with the later approach, but I'm > wondering if Struts has a mechanism for this, like our custom framework > does? > > Thanks all! > > _ > Express yourself with the new version of MSN Messenger! Download today - > it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: App-level globals
At 5:33 PM +0100 5/17/04, Paul McCulloch wrote: Struts has plugins which, I think do the kind of thing you are after. Personally I've never used them - I just implement a ServletContextListener to do that sort of thing. This is exactly right: if you're using Servlet 2.2 (which doesn't have ServletContextListener), you can use PlugIn. If you're using Servlet 2.3 or newer, about the only other thing that PlugIn gets you which an SCL doesn't is that its init() method receives a reference to the Struts ModuleConfig for which the plugin is being initialized -- so if you need a handle on that object, using a PlugIn is probably the most straightforward way to get one. Joe Paul -Original Message- From: None None [mailto:[EMAIL PROTECTED] Sent: Monday, May 17, 2004 5:17 PM To: [EMAIL PROTECTED] Subject: App-level globals Hello again everyone... I am starting conversion of a none-Struts app to Struts, and mostly it's straight-forward, but two things I have questions about... The home-grown framework this app was written with has the notion of an App Loader. Basically, this is a class that runs at startup and reads in some config information and stores it in a static config object. The properties of this object are referenced throughout the app. The other concern is that this same process spawns a couple of low-priority background threads to do some various things throughout the lifetime of the app. My question, which I have been unable to find an answer to on my own, is if Struts has a similar startup "initialization" mechanism? If not, do I simply create my own servlet to do all this work and set it to run on startup in web.xml? I have no problem with the later approach, but I'm wondering if Struts has a mechanism for this, like our custom framework does? Thanks all! _ Express yourself with the new version of MSN Messenger! Download today - it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ** Axios Email Confidentiality Footer Privileged/Confidential Information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not copy or deliver this message to anyone. In such case, you should destroy this message, and notify us immediately. If you or your employer does not consent to Internet email messages of this kind, please advise us immediately. Opinions, conclusions and other information expressed in this message are not given or endorsed by my Company or employer unless otherwise indicated by an authorised representative independent of this message. WARNING: While Axios Systems Ltd takes steps to prevent computer viruses from being transmitted via electronic mail attachments we cannot guarantee that attachments do not contain computer virus code. You are therefore strongly advised to undertake anti virus checks prior to accessing the attachment to this electronic mail. Axios Systems Ltd grants no warranties regarding performance use or quality of any attachment and undertakes no liability for loss or damage howsoever caused. ** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Joe Germuska [EMAIL PROTECTED] http://blog.germuska.com "Imagine if every Thursday your shoes exploded if you tied them the usual way. This happens to us all the time with computers, and nobody thinks of complaining." -- Jef Raskin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: App-level globals
Struts has plugins which, I think do the kind of thing you are after. Personally I've never used them - I just implement a ServletContextListener to do that sort of thing. Paul > -Original Message- > From: None None [mailto:[EMAIL PROTECTED] > Sent: Monday, May 17, 2004 5:17 PM > To: [EMAIL PROTECTED] > Subject: App-level globals > > > Hello again everyone... I am starting conversion of a > none-Struts app to > Struts, and mostly it's straight-forward, but two things I > have questions > about... > > The home-grown framework this app was written with has the > notion of an App > Loader. Basically, this is a class that runs at startup and > reads in some > config information and stores it in a static config object. > The properties > of this object are referenced throughout the app. > > The other concern is that this same process spawns a couple > of low-priority > background threads to do some various things throughout the > lifetime of the > app. > > My question, which I have been unable to find an answer to on > my own, is if > Struts has a similar startup "initialization" mechanism? If > not, do I > simply create my own servlet to do all this work and set it to run on > startup in web.xml? I have no problem with the later > approach, but I'm > wondering if Struts has a mechanism for this, like our custom > framework > does? > > Thanks all! > > _ > Express yourself with the new version of MSN Messenger! > Download today - > it's FREE! > http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > ** Axios Email Confidentiality Footer Privileged/Confidential Information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not copy or deliver this message to anyone. In such case, you should destroy this message, and notify us immediately. If you or your employer does not consent to Internet email messages of this kind, please advise us immediately. Opinions, conclusions and other information expressed in this message are not given or endorsed by my Company or employer unless otherwise indicated by an authorised representative independent of this message. WARNING: While Axios Systems Ltd takes steps to prevent computer viruses from being transmitted via electronic mail attachments we cannot guarantee that attachments do not contain computer virus code. You are therefore strongly advised to undertake anti virus checks prior to accessing the attachment to this electronic mail. Axios Systems Ltd grants no warranties regarding performance use or quality of any attachment and undertakes no liability for loss or damage howsoever caused. ** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]