Re: modifying shutdown behaviour?

2003-11-14 Thread Jon Wingfield
$TOMCAT_HOME/webapps/examples/WEB-INF/web.xml

look for the listener element

HTH,

Jon

Patrick Herrera wrote:
Hi all,

I would like to implement a ServletContextListener, but I can't find an
example of the tags I need to add to my web.xml file to register a class as
a listener.
Can anyone point me in the direction of an example?

Thanks,

Patrick

-Original Message-
From: Shapira, Yoav [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, 28 October 2003 1:16 AM
To: Tomcat Users List
Subject: RE: modifying shutdown behaviour?

Howdy,


When the $CATALINA_HOME/bin/shutdown.sh script is called I would like
a

particular web application to release its resources cleanly and
perform

tidy

You could implement a ServletContextListener. The
contextDestroyed()

method

will be called when your application is about to be removed.
If you have a servlet which initializes resource for your context (like
an InitServlet), you can simply implemnent the destroy method to
release your resources.
This may be easier than writing a ServletContextListener, and has fewer
moving parts.


I would strongly disagree ;)  The container is free to destroy and
reload any servlet, including load-on-startup servlets, at any time it
deems such action necessary.
If you need something done on shutdown or startup or both, it's much
cleaner to write a listener for that purpose than a servlet, for
multiple reasons: 
- The footprint of a servlet in memory is bigger
- Another servlet adds to request mapping overhead, reducing performance
- Servlets are not supposed to be written only for init/destroy
functionality, ServletContextListeners are expressly designed for this
purpose
- It's a lot easier to mess up thread-safety in a servlet (which of
course may have multiple instances in memory) than in a listener

The moving parts claim you make -- I'm not sure I understand that.  Mind
elaborating? ;)
Yoav Shapira



This e-mail, including any attachments, is a confidential business
communication, and may contain information that is confidential, proprietary
and/or privileged.  This e-mail is intended only for the individual(s) to
whom it is addressed, and may not be saved, copied, printed, disclosed or
used by anyone else.  If you are not the(an) intended recipient, please
immediately delete this e-mail from your computer system and notify the
sender.  Thank you.
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


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





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


Re: modifying shutdown behaviour?

2003-11-14 Thread Christopher Schultz
Patrick,
I would like to implement a ServletContextListener, but I can't find an
example of the tags I need to add to my web.xml file to register a class as
a listener.
Can anyone point me in the direction of an example?
I just snooped the webapp 2.3 DTD 
(http://java.sun.com/dtd/web-app_2_3.dtd), and came up with this:

listener
listener-classmy.listsner.Class/listener-class
/listener
Here's the element definition for the webapp element:

!ELEMENT web-app (icon?, display-name?, description?, distributable?,
context-param*, filter*, filter-mapping*, listener*, servlet*,
servlet-mapping*, session-config?, mime-mapping*, welcome-file-list?,
error-page*, taglib*, resource-env-ref*, resource-ref*, 
security-constraint*,
login-config?, security-role*, env-entry*, ejb-ref*,  ejb-local-ref*)

So, the listener elements come after any context-params, filters, and 
filter-mappings, but before any servlet defintions.

Hope that helps,
-chris
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: modifying shutdown behaviour?

2003-11-13 Thread Patrick Herrera
Hi all,

I would like to implement a ServletContextListener, but I can't find an
example of the tags I need to add to my web.xml file to register a class as
a listener.

Can anyone point me in the direction of an example?

Thanks,

Patrick

-Original Message-
From: Shapira, Yoav [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, 28 October 2003 1:16 AM
To: Tomcat Users List
Subject: RE: modifying shutdown behaviour?


Howdy,

 When the $CATALINA_HOME/bin/shutdown.sh script is called I would like
a
 particular web application to release its resources cleanly and
perform
tidy
 
  You could implement a ServletContextListener. The
contextDestroyed()
method
  will be called when your application is about to be removed.

If you have a servlet which initializes resource for your context (like
an InitServlet), you can simply implemnent the destroy method to
release your resources.

This may be easier than writing a ServletContextListener, and has fewer
moving parts.

I would strongly disagree ;)  The container is free to destroy and
reload any servlet, including load-on-startup servlets, at any time it
deems such action necessary.

If you need something done on shutdown or startup or both, it's much
cleaner to write a listener for that purpose than a servlet, for
multiple reasons: 
- The footprint of a servlet in memory is bigger
- Another servlet adds to request mapping overhead, reducing performance
- Servlets are not supposed to be written only for init/destroy
functionality, ServletContextListeners are expressly designed for this
purpose
- It's a lot easier to mess up thread-safety in a servlet (which of
course may have multiple instances in memory) than in a listener

The moving parts claim you make -- I'm not sure I understand that.  Mind
elaborating? ;)

Yoav Shapira



This e-mail, including any attachments, is a confidential business
communication, and may contain information that is confidential, proprietary
and/or privileged.  This e-mail is intended only for the individual(s) to
whom it is addressed, and may not be saved, copied, printed, disclosed or
used by anyone else.  If you are not the(an) intended recipient, please
immediately delete this e-mail from your computer system and notify the
sender.  Thank you.


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



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



RE: modifying shutdown behaviour?

2003-10-27 Thread Bodycombe, Andrew
You could implement a ServletContextListener. The contextDestroyed() method
will be called when your application is about to be removed.

-Original Message-
From: Julie McCabe [mailto:[EMAIL PROTECTED] 
Sent: 27 October 2003 13:30
To: [EMAIL PROTECTED]
Subject: modifying shutdown behaviour?


Hello,

Config details: tomcat 4.1.24; java 1.4.1_02

When the $CATALINA_HOME/bin/shutdown.sh script is called I would like a 
particular web application to release its resources cleanly and perform tidy

up operations before Tomcat shuts down.  

What is the best method of doing this?  Does it involve modifying the  
$CATALINA_HOME/bin/catalina.sh script?

Many thanks,
Julie.




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

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



RE: modifying shutdown behaviour?

2003-10-27 Thread Shapira, Yoav

Howdy,
Yup, that's a good suggestion.  You actually have extremely fine tuned
control over the shutdown process, including:
1. Session destroyed
2. Servlet destroyed
3. Filter destroyed
4. Context destroyed
5. Any class finalize() method
6. Runtime#addShutdownHook(Thread hook)

The above list is not exhaustive, there are even more things you can
hook on shutdown ;)  1-4 above are specific to servlet containers, 3 to
servlet 2.3 and later containers, 6 to JDK 1.3 and later.

Yoav Shapira
Millennium ChemInformatics


-Original Message-
From: Bodycombe, Andrew [mailto:[EMAIL PROTECTED]
Sent: Monday, October 27, 2003 8:27 AM
To: 'Tomcat Users List'
Subject: RE: modifying shutdown behaviour?

You could implement a ServletContextListener. The contextDestroyed()
method
will be called when your application is about to be removed.

-Original Message-
From: Julie McCabe [mailto:[EMAIL PROTECTED]
Sent: 27 October 2003 13:30
To: [EMAIL PROTECTED]
Subject: modifying shutdown behaviour?


Hello,

Config details: tomcat 4.1.24; java 1.4.1_02

When the $CATALINA_HOME/bin/shutdown.sh script is called I would like a
particular web application to release its resources cleanly and perform
tidy

up operations before Tomcat shuts down.

What is the best method of doing this?  Does it involve modifying the
$CATALINA_HOME/bin/catalina.sh script?

Many thanks,
Julie.




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

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




This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


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



Re: modifying shutdown behaviour?

2003-10-27 Thread Christopher Schultz
Julie,

When the $CATALINA_HOME/bin/shutdown.sh script is called I would like a 
particular web application to release its resources cleanly and perform tidy

 You could implement a ServletContextListener. The contextDestroyed() method
 will be called when your application is about to be removed.
If you have a servlet which initializes resource for your context (like 
an InitServlet), you can simply implemnent the destroy method to 
release your resources.

This may be easier than writing a ServletContextListener, and has fewer 
moving parts.

-chris

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


RE: modifying shutdown behaviour?

2003-10-27 Thread Shapira, Yoav

Howdy,

 When the $CATALINA_HOME/bin/shutdown.sh script is called I would like
a
 particular web application to release its resources cleanly and
perform
tidy
 
  You could implement a ServletContextListener. The
contextDestroyed()
method
  will be called when your application is about to be removed.

If you have a servlet which initializes resource for your context (like
an InitServlet), you can simply implemnent the destroy method to
release your resources.

This may be easier than writing a ServletContextListener, and has fewer
moving parts.

I would strongly disagree ;)  The container is free to destroy and
reload any servlet, including load-on-startup servlets, at any time it
deems such action necessary.

If you need something done on shutdown or startup or both, it's much
cleaner to write a listener for that purpose than a servlet, for
multiple reasons:
- The footprint of a servlet in memory is bigger
- Another servlet adds to request mapping overhead, reducing performance
- Servlets are not supposed to be written only for init/destroy
functionality, ServletContextListeners are expressly designed for this
purpose
- It's a lot easier to mess up thread-safety in a servlet (which of
course may have multiple instances in memory) than in a listener

The moving parts claim you make -- I'm not sure I understand that.  Mind
elaborating? ;)

Yoav Shapira



This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


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