> -----Original Message-----
> From: Milt Epstein [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, September 10, 2002 2:14 PM
> To: Tomcat Users List
> Subject: RE: Managing a Listener
> 
> 
> On Tue, 10 Sep 2002, Turner, John wrote:
> 
> > >From the 4.0 docs:
> >
> > If you have implemented a Java object that needs to know when this
> > Host is started or stopped, you can declare it by nesting a Listener
> > element inside this element. The class name you specify must
> > implement the org.apache.catalina.LifecycleListener interface, and
> > it will be notified about the occurrence of the coresponding
> > lifecycle events. Configuration of such a listener looks like this:
> [ ... ]
> 
> Is this a Tomcat-only feature, or is it in the servlet spec?  If the
> former, be aware that if you use it your setup will not be portable.
> That may or not be an issue, but wanted to bring it up.
> 

That is a Tomcat only feature.  The spec says define context listeners in the 
deployment descriptor.

Here's an example:

<web-app>
  <listener>
    <listener-class>package.Listener</listener-class>
  </listener>
</web-app>

I think this is what you should do if you are just initializing some objects.  I'm 
using this on a project to initialize a cache of "business" objects.  I would use a 
properties file if configuration is needed and use 
getClass().getResourceAsStream("myConfig") to create a Properties object.  You can put 
this properties file in WEB-INF/classes and it will be portable, with no hard coding.



> 
> >  <Host name="localhost" ...>
> >   ...
> >   <Listener className="com.mycompany.mypackage.MyListener" ... >
> >   ...
> > </Host>
> >
> > Note that a Listener can have any number of additional 
> properties that may
> > be configured from this element. Attribute names are matched to
> > corresponding JavaBean property names using the standard 
> property method
> > naming patterns.
> >
> > so basically it looks like you can have:
> >
> > Listener className="com.your.listener.class" 
> param1="value1" param2="value2"
> > param3="value3"
> >
> > The parameters can be anything you want, like a pointer to 
> a properties file
> > or anything else.
> >
> > John
> >
> >
> >
> > > -----Original Message-----
> > > From: Craig Longman [mailto:[EMAIL PROTECTED]]
> > > Sent: Tuesday, September 10, 2002 2:54 PM
> > > To: Tomcat Users List
> > > Subject: RE: Managing a Listener
> > >
> > >
> > > On Tue, 2002-09-10 at 14:21, Turner, John wrote:
> > > >
> > > > Why not just use a properties file?
> > >
> > > properties, xml, it doesn't really matter what the file is.
> > >
> > > i just want to figure out how to point the filter/listener TO
> > > the file,
> > > from the server.xml configuration file.  and also how to find the
> > > logger, so that the filter can log events/info in the 
> right place (as
> > > defined by the Logger element).
> > >
> > > i see now that the ApacheConfig listener appears to get
> > > information from
> > > the server.xml file..  it is defined as:
> > >
> > >  <Listener className="org.apache.ajp.tomcat4.config.ApacheConfig"
> > >            jkConfig="conf/jk/site_mod_jk.conf" />
> > >
> > > i want to do something like that, have the jkConfig 
> property in there
> > > and be initialized with the value.  i'm still trying to 
> figure out how
> > > it does that, its not clear to me at all, it looks like a lot
> > > of custom
> > > code.
> > >
> > > then i still need to figure out how to get the default 
> logger from a
> > > filter.  whew.
> > >
> > > > > -----Original Message-----
> > > > > From: Craig Longman [mailto:[EMAIL PROTECTED]]
> > > > > Sent: Tuesday, September 10, 2002 2:19 PM
> > > > > To: Tomcat Users List
> > > > > Subject: RE: Managing a Listener
> > > > >
> > > > >
> > > > > On Tue, 2002-09-10 at 14:11, Srofe, Douglas (c) wrote:
> > > > > > Craig,
> > > > > >
> > > > > > [...snip...]
> > > > > >
> > > > > > If this is not enough to get you started, I would be happy
> > > > > to fill in some
> > > > > > more specifics.
> > > > >
> > > > > i see your point, and that makes good sense.  in my
> > > particular case, i
> > > > > think that the session would still be a better way to go
> > > though, all i
> > > > > really need is to have it configure the information once.
> > > > >
> > > > > my real problem is more generic i guess, how do i initialize
> > > > > a listener
> > > > > (or a filter for that matter) with some basic webapp
> > > information, like
> > > > > where to log, getting configuration information, etc.
> > > > >
> > > > > until now, i've always just done it via a servlet, but
> > > i'd like to use
> > > > > these new things (listeners/filters/etc) properly, but if i
> > > > > can't log or
> > > > > configure them from the server.xml file, then i will have to
> > > > > resort to a
> > > > > servlet.  i hate not being able to log information from
> > > components.
> > > > >
> > > > > thanks!
> > > > >
> > > >
> > > > --
> > > > To unsubscribe, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > > For additional commands, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > >
> > --
> >
> >     CraigL->Thx();
> >     Be Developer ID: 5852
> >
> >
> > --
> > To unsubscribe, e-mail:   
> <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail: 
> <mailto:[EMAIL PROTECTED]>
> >
> 
> Milt Epstein
> Research Programmer
> Integration and Software Engineering (ISE)
> Campus Information Technologies and Educational Services (CITES)
> University of Illinois at Urbana-Champaign (UIUC)
> [EMAIL PROTECTED]
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: 
> <mailto:[EMAIL PROTECTED]>
> 
> 

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to