• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: session cleanup hooks
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: session cleanup hooks


  • Subject: Re: session cleanup hooks
  • From: Geoff Hopson <email@hidden>
  • Date: Sun, 1 Aug 2004 16:32:03 +0100

I do something like this in Session.java

   public void terminate() {
        NSNotificationCenter nc = NSNotificationCenter.defaultCenter();
        nc.postNotification("MySessionWillTerminate", this);
        super.terminate();
    }

Then I have something listening for the notification, like a controller object or something

In Constructor...
...
NSNotificationCenter nc = NSNotificationCenter.defaultCenter();
nc.addObserver(this, new NSSelector("doTerminate", new Class[] { NSNotification.class }), "OOSessionWillTerminate", session());
....


Terminate method that is called....

	public void doTerminate(NSNotification notification) {
		try {
			OOCoordinator object = (OOCoordinator)notification.object();
			if (object != null && object == session()) {
				// do stuff...
			}
		}
		catch (Exception e) {
			// log it. raise, whatever...
		}
	}

You might have to experiment setting different objects as part of the notification call (I used 'session' above).

Very underused pattern, that Observer one...

HTH,

Geoff


On 1 Aug 2004, at 14:38, Michael Engelhart wrote:

Are there any hooks that can be called when a session is getting terminated by the application. I have legacy network connections that I open and store in a users session to avoid connection overhead with every request and would like to neatly close them down rather then just wait for the legacy system to shut them down when they time out.
From what I can tell it also doesn't appear that WOApplication (or Wonder's ERXApplication which I'm using) does session cleanup by calling terminate() on the session objects at least from Monitor. I saw a thread somewhere saying that Monitor uses an undocumented application shutdown method which doesn't call WOApplication.terminate() or ERXApplication.terminate(). For a framework that is so mature I'm really surprised at how little there is in the way of shutdown hooks there are built into WebObjects.


Does anyone know of any way to write in these hooks?

Thanks
KMike
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: session cleanup hooks
      • From: Michael Engelhart <email@hidden>
References: 
 >session cleanup hooks (From: Michael Engelhart <email@hidden>)

  • Prev by Date: Re: session cleanup hooks
  • Next by Date: Re: session cleanup hooks
  • Previous by thread: Re: session cleanup hooks
  • Next by thread: Re: session cleanup hooks
  • Index(es):
    • Date
    • Thread