startup/JavaStartup.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 28 Jan 2013 21:15:59 +0000
branchdevelopment
changeset 2005 f5f046bfdfc6
parent 1818 2e5ed72e7dfd
child 2069 75d40b7b986f
permissions -rw-r--r--
More work on new JavaCodeBundleEditor & preferences. Not yet finished.

"{ Package: 'stx:libjava/startup' }"

StandaloneStartup subclass:#JavaStartup
	instanceVariableNames:''
	classVariableNames:'ClassPath'
	poolDictionaries:''
	category:'Languages-Java-Support'
!


!JavaStartup class methodsFor:'constants & defaults'!

applicationRegistryPath
    "the key under which this application stores its process ID in the registry
     as a collection of path-components.
     i.e. if #('foo' 'bar' 'baz') is returned here, the current applications ID will be stored
     in HKEY_CURRENT_USER\Software\foo\bar\baz\CurrentID.
     (would also be used as a relative path for a temporary lock file under unix).
     Used to detect if another instance of this application is already running."
    
    ^ #('stx' 'java_x')

    "Created: / 07-02-2011 / 10:55:08 / Marcel Hlopko <hlopik@gmail.com>"
!

applicationUUID
    "answer an application-specific unique uuid.
     This is used as the name of some exclusive OS-resource, which is used to find out,
     if another instance of this application is already running.
     Under win32, a mutex is used; under unix, an exclusive file in the tempDir could be used."
    
    ^ 'ST_X_JAVA_X'.

    "Created: / 07-02-2011 / 10:52:50 / Marcel Hlopko <hlopik@gmail.com>"
! !

!JavaStartup class methodsFor:'startup'!

main:argv 
    "Currently only -c option for classpath setting working"
    
    |class arguments classAndArguments classpath classpathFromEnv|

    classpath := OrderedCollection new.
    classpathFromEnv := OperatingSystem getEnvironment:#CLASSPATH.
    classpathFromEnv isNil ifFalse:[
        (classpathFromEnv asArrayOfSubstringsSeparatedBy:$:) do:[:each | 
            classpath add:each
        ]
    ].
    classAndArguments := OrderedCollection new.
    (GetOpt new)
        at:$c
            put:[:opt :arg | (arg asArrayOfSubstringsSeparatedBy:$:) do: [:each | classpath add: each]];
        at:$? put:[:arg | self error:'not yet implemented'];
        default:[:arg | classAndArguments add:arg];
        parse:argv.
    class := classAndArguments at:1.
    arguments := classAndArguments
                removeFirst;
                yourself.
    Java flushAllJavaResources.
    self breakPoint:#mh.
    Java initialize.
    JavaVM initializeVM.
    classpath do:[:each | 
        Java addToClassPath:each
    ].
    (Java classForName:class) main:arguments asArray.

    "Created: / 07-02-2011 / 10:55:41 / Marcel Hlopko <hlopik@gmail.com>"
    "Modified: / 08-02-2011 / 00:55:42 / Marcel Hlopko <hlopik@gmail.com>"
! !

!JavaStartup class methodsFor:'documentation'!

version_SVN
    ^ '$Id$'
! !