• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Listener Registration

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Source: Servlet 2.4 Spec SRV.10.3.3 Listener Registration


The Web 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.

In the statement in bold, I understood that listeners are registered in order in which they appear in DD, but what is exactly meant by registration accd to interfaces they implement ??

On the same lines I wanted to ask if in a webapp's DD I configure an HttpSessionAttributeListener and also define a class A implementing HttpSessionBindingListener interface.

Now when objects of class A are set as attributes in session which listener will run first???
 
Ranch Hand
Posts: 336
Firefox Browser Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the best you can do, is test this by your self.

If you have a problem implementing this, you can ask!!
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kamal Tripathi wrote:

On the same lines I wanted to ask if in a webapp's DD I configure an HttpSessionAttributeListener and also define a class A implementing HttpSessionBindingListener interface.

Now when objects of class A are set as attributes in session which listener will run first???

.

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

If suppose a LisitenerclassA implements HttpSessionAttributeListener ,HttpSessionBindingListener and another class LisitenerclassB implements HttpSessionAttributeListener ,HttpSessionBindingListener

and in dd we declare
<listener><listener-class><com.example.LisitenerclassB ></listener-class></listener>
<listener><listener-class><com.example.LisitenerclassA></listener-class></listener>
Now order of creation of instance of classes is LisitenerclassB ,LisitenerclassA.
and then order of registration of classes for events are LisitenerclassB regstrd against HttpSessionAttributeListener
LisitenerclassB regstrd against HttpSessionBindingListener
LisitenerclassA regstrd against HttpSessionAttributeListener
LisitenerclassA regstrd against HttpSessionBindingListener .

So a HttpSessionAttribute event [replace an attribute including a binding event]occur LisitenerclassB will be notified 1st and method invocation will be in the order attributeReplaced,valueBound- means in the order in which interface is been regstrd.

Kamal Tripathi wrote:On the same lines I wanted to ask if in a webapp's DD I configure an HttpSessionAttributeListener and also define a class A implementing HttpSessionBindingListener interface.

--- When you say configure an HttpSessionAttributeListener in DD that includes that class A implements HttpSessionAttributeListener as well rght .I think now you got the answer for this as well.
Thanks,
Chithra Salam
SCJP-85%,SCWCD-in progress.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic