Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Doubt regarding Listeners

 
Ranch Hand
Posts: 558
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi pramod,


Specifiaction

setAttribute
public void setAttribute(java.lang.String name,
java.lang.Object value)Binds an object to this session, using the name specified. If an object of the same name is already bound to the session, the object is replaced.
After this method executes, and

1. if the new object implements HttpSessionBindingListener, the container calls HttpSessionBindingListener.valueBound. The container then notifies any HttpSessionAttributeListeners in the web application.

2. If an object was already bound to this session of this name that implements HttpSessionBindingListener, its HttpSessionBindingListener.valueUnbound method is called.

3. If the value passed in is null, this has the same effect as calling removeAttribute().


Parameters:
name - the name to which the object is bound; cannot be null
value - the object to be bound
Throws:
IllegalStateException - if this method is called on an invalidated session




I am again re-emphasizing that step2 1,2,3 are mutually exclusive if conditions. That means they have no-depedencies.

I DON"T THINK SPECIFICATION DICTATING THE ORDER THERE.
ORDER WILL BE SPECIFIED IF THERE ARE DEPENDENCIES.

For example, If you take point (1). There it is combination of two atomic steps.
1.
1.1 if the new object implements HttpSessionBindingListener, the container
calls HttpSessionBindingListener.valueBound.
1.2 The container then notifies any HttpSessionAttributeListeners in the
web application.
***** HERE 1.2 can't execute before 1.1 This is order



Hence Websphere is a robust application server.

Proof for step 1 automicity (on websphere)

Check with this listener


Now call:



Result is :
[8/10/07 19:51:17:453 IST] 00000020 SystemOut O B
[8/10/07 19:51:17:453 IST] 00000020 SystemOut O Attribute added: (name = key,one)
[8/10/07 19:51:17:453 IST] 00000020 SystemOut O UB
[8/10/07 19:51:17:453 IST] 00000020 SystemOut O B
[8/10/07 19:51:17:453 IST] 00000020 SystemOut O Attribute replaced: (name = key,one)
[8/10/07 19:51:17:453 IST] 00000020 SystemOut O UB
[8/10/07 19:51:17:453 IST] 00000020 SystemOut O Attribute removed: (name = key,two)
[8/10/07 19:51:17:453 IST] 00000020 SystemOut O Attribute removed: (name = key,null)

Thats all guys,
This is my opinion. Any contradictions invited.
because discussion can only makes us clear with this.
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I thank each and every one who responded so well with their explanations.
I couldn't able to check this forum yesterday to post my opinion.

Any way tomorrow i'm taking this exam.
Hope i won't get this question in the exam.
If i get,i will go by the suggestion given by Srinivasan -
If both are present - I'll select both
If only either of the two exits - No Choice (Have to select that one)

I'll share my experiences once i'm done with the exam.

And finally going by all the practical tests and their explanations by every one regarding this Listener Bound/Unbound problem,
Shall we have to conclude that Different Containers provide different implementation to this Listener Bound/Unbound concept because of lack of clarity in the Spec?

[ August 10, 2007: Message edited by: Rajesh Kodali ]
[ August 10, 2007: Message edited by: Rajesh Kodali ]
 
Srinivasan thoyyeti
Ranch Hand
Posts: 558
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rajesh,

CONCLUSION:
Specification need not be specific about the order IF there are no dependencies. and this type of questions will not appear in real exam if they apply some thought and common sense.

In setAttribute specification After setAttribute call, Depending on value set need to call one if they satisfy the condition specified.

A.if (cond) { valueBound(), [attributeAdded, attributeReplaced] }
B.if (cond) { valueUnBound(). }
C.if (cond) { attributeRemoved() }

The implementing function should include checks for A,B,C. Thats all.
They can check order like this: (A,B,C), (B,A,C).


Thanks every body who participated in this Thread and Rajesh you inited this therad and made my eyes wide open.

We had a very good discussion.
[ August 10, 2007: Message edited by: Srinivasan thoyyeti ]
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nice thread, this cant be on the exam, its container dependent !!!
 
Think of how dumb the average person is. Mathematically, half of them are EVEN DUMBER. Smart tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic