'From Pharo0.1 of 16 May 2008 [Latest update: #10373] on 31 August 2009 at 5:24:36 pm'! Object subclass: #SessionManager instanceVariableNames: 'sessionStart' classVariableNames: 'Current' poolDictionaries: '' category: 'Dolphincompatibility-Idioms'! !SessionManager commentStamp: 'Bill Schwab 8/28/2009 17:54' prior: 0! Dolphin session managers do as advertised. Among other things, they fire off events to manage startup and shutdown, and unlike Squeak, those happen when and only when the image loads and closes, respectively. Recreate this basic behavior for Pharo. ! !SessionManager methodsFor: 'as yet unclassified' stamp: 'Bill Schwab 8/31/2009 17:22'! shutDown "8-09 - hopefully this is called only when a session ends vs. on every snapshot." sessionStart isNil ifTrue:[ Transcript nextPutAll:'Shutdown with no time set.'; cr. ] ifFalse:[ sessionStart := nil. ]. "8-09 - use #triggerEvent: to simplify dependence on Dolphin layer" KernelLibrary default outputDebugString:'Trigger #sessionStopped.'. self trigger:#sessionStopped. ! ! !SessionManager methodsFor: 'as yet unclassified' stamp: 'Bill Schwab 8/31/2009 17:22'! startUp "8-09 - hopefully this is called only when a session begins vs. on every snapshot." sessionStart notNil ifTrue:[ Transcript nextPutAll:'Startup with time set.'; cr. ] ifFalse:[ sessionStart := TimeStamp current. ]. "8-09 - use #triggerEvent: to simplify dependence on Dolphin layer" KernelLibrary default outputDebugString:'Trigger #sessionStarted.'. self triggerEvent:#sessionStarted. "8-09 - Sorry, but I see NO reason for this not to be done somewhere on startup." Socket initializeNetwork. ! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! SessionManager class instanceVariableNames: ''! !SessionManager class methodsFor: 'as yet unclassified' stamp: 'Bill Schwab 8/28/2009 09:29'! current "8-09 - lazily create a session manager. This seems like a class variable vs. class instance variable problem, because there should be one of these things regardless of (in the future) which subclass gets the duty. Runtime/deployed, development and console are the likely players." Current isNil ifTrue:[ Current := self new. ]. ^Current. ! ! !SessionManager class methodsFor: 'as yet unclassified' stamp: 'Bill Schwab 8/28/2009 15:52'! initialize "8-09 - these lists are mis-named as the evens are fired around a snapshot. Try make a working session manager that behave as in Dolphin. SessionManager initialize. " Smalltalk addToStartUpList: self. Smalltalk addToShutDownList: self. ! ! !SessionManager class methodsFor: 'as yet unclassified' stamp: 'Bill Schwab 8/28/2009 11:05'! shutDown:quitting "8-09 - see Behavior>>shutDown: which forwards this to #startup regardless of the boolean state. Try to do better here so the notices go out only on a true shutdown. Trigger off of the current session manager." quitting ifTrue:[ self current shutDown. ]. ! ! !SessionManager class methodsFor: 'as yet unclassified' stamp: 'Bill Schwab 8/28/2009 11:05'! startUp:resuming "8-09 - see Behavior>>startup: which forwards this to #startup regardless of the boolean state. Try to do better here so the notices go out only on a true session start. Trigger off of the current session manager." "8-09 - I *think* resuming means loading an image from disk." resuming ifTrue:[ self current startUp. ]. ! ! SessionManager initialize!