Problem
Tim Rowledge
tim at sumeru.stanford.edu
Fri Dec 7 03:20:28 UTC 2001
Dan Ingalls <Dan at SqueakLand.org> is widely believed to have written:
> 1. There USED to be a mechanism that read in a .so file if present to do exactly this kind of thing. It was in the method readDocumentFile, but I now find there only the comment
> "No longer used. Everything is now done in ProjectLauncher."
> So I think PL might be useful if you can get some help on how to do what you want (Michael...?).
I had a more or less similar problem a few months ago and found the
attached changes useful. Maybe they will help Benoit or even Micheal.
tim
--
Tim Rowledge, tim at sumeru.stanford.edu, http://sumeru.stanford.edu/tim
Useful random insult:- One chip short of a megabyte.
-------------- next part --------------
'From Squeak3.1alpha of 7 March 2001 [latest update: #4164] on 28 August 2001 at 3:14:25 pm'!
"Change Set: AutoStartfixes
Date: 28 August 2001
Author: tim at sumeru.stanford.edu
When you shrink an image and remove Morphic you suddenly find that commandline scripts no longer get processed. This is because:-
a) ProjectLauncher tries to setup some Flaps, which no longer exist
b) AutoStart only starts its installed launchers if there is a WorldState - which no longer exists.
This changeset provides a reasonably tidy fix by making AutoStart delegate a bit better to the luncher class involved, and by providing a default #startUp that continues to check for WorldState. The CommandLineLauncher is an example of overriding that to work without Morphic in a shrunk, headless image.
To activate CommandLineLauncher, remember to use
ProjectLauncher deactivate.
CommandLineLauncher activate
before saving the image.
"!
AbstractLauncher subclass: #CommandLineLauncher
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Framework-Download'!
!AbstractLauncher methodsFor: 'running' stamp: 'tpr 8/28/2001 13:31'!
startUp
"Default - add a deferred UI action to do the real startup work.
Subclasses can override to handle Morphiclessness etc"
Smalltalk at: #WorldState ifPresent: [ :ws | ws addDeferredUIMessage: [self actualStartUp]]! !
!AutoStart class methodsFor: 'class initialization' stamp: 'tpr 8/28/2001 13:38'!
startUp
| startupParameters launchers |
self checkForUpdates
ifTrue: [^self].
self checkForPluginUpdate.
startupParameters _ AbstractLauncher extractParameters.
launchers _ self installedLaunchers collect: [:launcher |
launcher new].
launchers do: [:launcher |
launcher parameters: startupParameters].
launchers do: [:launcher |
launcher startUp]! !
!CommandLineLauncher methodsFor: 'running' stamp: 'tpr 8/28/2001 13:41'!
startUp
"Override the default - this is intended for headless type systems andchecking for a WorldState will do us no good at all"
| scriptName loader isUrl |
scriptName _ (Smalltalk getSystemAttribute: 2) ifNil:[''].
scriptName isEmpty ifFalse:[
"figure out if script name is a URL by itself"
isUrl _ (scriptName asLowercase beginsWith:'http://') or:[
(scriptName asLowercase beginsWith:'file://') or:[
(scriptName asLowercase beginsWith:'ftp://')]].
isUrl ifFalse:[scriptName _ 'file://',scriptName]].
scriptName isEmptyOrNil ifTrue:[^self].
loader _ CodeLoader new.
loader loadSourceFiles: (Array with: scriptName).
loader installSourceFiles! !
!CommandLineLauncherExample methodsFor: 'running' stamp: 'tpr 8/28/2001 13:32'!
actualStartUp
| className |
className _ self parameterAt: 'class'.
(Smalltalk at: className asSymbol ifAbsent: [Object]) browse! !
!ProjectLauncher methodsFor: 'running' stamp: 'tpr 8/28/2001 13:29'!
actualStartUp
| scriptName loader isUrl |
World ifNotNil: [World install].
HTTPClient determineIfRunningInBrowser.
HTTPClient isRunningInBrowser ifTrue:[
self setupFromParameters.
scriptName _ self parameterAt: 'src'.
CodeLoader defaultBaseURL: (self parameterAt: 'Base').
] ifFalse:[
scriptName _ (Smalltalk getSystemAttribute: 2) ifNil:[''].
scriptName isEmpty ifFalse:[
"figure out if script name is a URL by itself"
isUrl _ (scriptName asLowercase beginsWith:'http://') or:[
(scriptName asLowercase beginsWith:'file://') or:[
(scriptName asLowercase beginsWith:'ftp://')]].
isUrl ifFalse:[scriptName _ 'file://',scriptName]].
].
scriptName isEmptyOrNil ifTrue:[^self].
self setupFlaps.
loader _ CodeLoader new.
loader loadSourceFiles: (Array with: scriptName).
(scriptName asLowercase endsWith: '.pr')
ifTrue:[self installProjectFrom: loader]
ifFalse:[loader installSourceFiles].
! !
ProjectLauncher removeSelector: #startUp!
CommandLineLauncherExample removeSelector: #startUp!
More information about the Squeak-dev
mailing list
|