This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Context Listener

 
Neeraj Vij
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

How can we use context listener in real-time applications.

Regards,
Neeraj.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does your app have anything that needs to be initialized at startup?
Does it have anything that needs to be cleaned up at shutdown?
If so, a ContextListener is just the thing for you.
 
Neeraj Vij
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ben,

Thanx for the reply...I justed wanted for improving my knowledge.

Can u provide some scenario, where u have used context-listner. In books I have read for db connections etc. but not satisfied with them..

Regards,
Neeraj.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
True not too many people would make a DB connection in a listener.

It would make sense, however to initialize a connection pool from a listener.
You may also have initialization data that is stored in a database that you want to retrieve and cache when the context initializes.

I have a webservice app that communicates with a non-browser application.
In it there is a login handshake that gives the client an ID string (similar to a JSPSessionID). I have an in-memory object that keeps track of who's logged in and when their session expires. So that I can restart the application without throwing all of these clients out, I serialize that object to disk when the context is destroyed and de-serialize it when the context starts back up.
 
Neeraj Vij
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

thnx Ben for all your inputs.

Regards,
Neeraj.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic