File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Listener registering and invocation order Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Professional Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply Bookmark "Listener registering and invocation order" Watch "Listener registering and invocation order" New topic
Author

Listener registering and invocation order

Maciek Mike
Greenhorn

Joined: Feb 03, 2010
Posts: 22
Hi,

Do you know what is the order of listener registration, is it according to order in web.xml with respect to type of listeners?
In which order they are invoked? I've heard that this order changes when application is about to shut down?
Please help, thanks in advance


SCJP 5.0 (94%), SCJD (388/400), SCWCD (97%)
Ankit Garg
Saloon Keeper

Joined: Aug 03, 2008
Posts: 9023

From the servlet specs
Servlet Specs wrote:SRV.10.3.3 Listener Registration
TheWeb container creates an instance of each listener class and registers it for event
notifications prior to the processing of the first request by the application. The Web
container registers the listener instances according to the interfaces they implement
and the order in which they appear in the deployment descriptor. During Web
application execution, listeners are invoked in the order of their registration.
SRV.10.3.4 Notifications At Shutdown
On application shutdown, listeners are notified in reverse order to their declarations
with notifications to session listeners preceeding notifications to context listeners.
Session listeners must be notified of session invalidations prior to context listeners
being notified of application shutdown.


Javaranch SCJP FAQ | SCWCD Links
Maciek Mike
Greenhorn

Joined: Feb 03, 2010
Posts: 22
Thanks, now I'm wondering what does

The Web
container registers the listener instances according to the interfaces they implement
and the order in which they appear in the deployment descriptor.


really mean? Which interfaces are first? Maybe it is vendor-specific?
Ninad Kulkarni
Ranch Hand

Joined: Aug 31, 2007
Posts: 754

@ Maciek
Read SRV.10.2.1 from servlet specification 2.4 final release

SCJP 5.0 - JavaRanch FAQ - Java Beginners FAQ - SCJP FAQ - SCJP Mock Tests - Tutorial - JavaSE7 - JavaEE6 -Generics FAQ - JLS - JVM Spec - Java FAQs - Smart Questions
 
 
subject: Listener registering and invocation order
 
jQuery in Action, 2nd edition

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture