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.