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

Reg HttpSessionActivationListener

 
B.Sathish
Ranch Hand
Posts: 372
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Should HttpSessionActivationListener be registered in the DD? The book clearly says that it should, but the errata says it cant. The errata says that the entire bang box that says HttpSessionActivationListeners should be registered in the DD is wrong. Can anyone please clarify.

Also, can HttpSessionActivationListeners be used for both attributes and classes as given in the book or is that also a mistake?
 
Sergey Tyulkin
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HttpSessionActivationListener shouldn't be registered in DD. If a class implements this interface, and an object of this class is added to the session, then this object (in other words, attribute) will be notified of the session actiovation/passivation.
 
Claudio Lande
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also found this part very confusing and the book (and the errata) adds more confusion to the matter

My understanding is:
HttpSessionListener and HttpSessionAttributeListener -> declared in DD
HttpSessionActivationListener and HttpSessionBindingListener -> NOT declared in DD

I guess that the point is that in case of session migration or of binding/unbinding a class attribute, the container checks to see (by means of reflection) whether the attributes in the session implement a HttpSessionActivationListener or HttpSessionBindingListener and in that case calls the corresponding event handlers (valueBound, valueUnbound, etc).

For all the other events, though you need to explicitly register a class to specific events, so that the container knows who to notify if these events occur. If there weren't this registration, the container should check all the web components (servlets, filters, utility classes, etc) to see if they are "interested" in specific events.

Hope it helps.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic