Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

order in which listeners are called

 
Chandra Sagi
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

What is the order(with respect to the order in Deployment Descriptor) in which Listeners are called in an application if two Listeners implement the same Interface. I have read that session listeners are processed before context listeners and are called in the reverse order of DD declaration. Is this correct? Please let me know.

Thanks in advance
Chandu
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where did you read this ?

From the spec:
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.
 
Chandra Sagi
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.[/QB]


I have read it from SCWCD Study guide - Bridgewater pg 257. So, the order is not purely dependent on the deployment descriptor itself. How could we know which interfaces are registered first?

Thanks for your reply,
Cheers
Chandu
 
Frederic Esnault
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Listeners are registered and called in the order they're declared in the DD.

When application is shutting down, they are called in the reverse order of their DD declaration.

No listener has precedence over the others. If you want one listener to be called before the others, declare it first in your DD.
 
Chandra Sagi
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Frederic and Satou,

Cheers
Chandu
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Frederic Esnault:
Listeners are registered and called in the order they're declared in the DD.

When application is shutting down, they are called in the reverse order of their DD declaration.

No listener has precedence over the others. If you want one listener to be called before the others, declare it first in your DD.


I think there is no question of precendence of listeners of different types, as they are called when the particular event is occured. If same type of listeners are defined in the web application, then the execution order is as per the DD when the event occur. This is about Calling the listeners. At the loading time the listener are loaded in order they defined in DD.

Thanks
 
Ramasubbhu Allur Kuppusamy
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would someone please consolidate the different answers in this thread to a complete answer to the question originally raised?
I appreciate your help.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To summarize:
Listeners are registered and called in the order they're declared in the DD, no matter of there type.
 
Ramasubbhu Allur Kuppusamy
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Satou,
Thanks for your rapid response .
 
Frederic Esnault
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Satou's summary is correct, but don't forget the special case of application shutdown. In this case, they are called in the reverse order in which they are declared in the DD.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic