public class BrowserManagerServer extends UnicastRemoteObject implements BrowserManager
Calling main(String[])
can instantiate and register multiple
instances of this class at given RMI namespace locations.
This system has been tested on Internet Explorer 6 & 7. Firefox does not work in the general case; if an existing Firefox process is already running, new processes simply delegate to the existing process and terminate, which breaks the model. A shell script that sets MOZNOREMOTE=1 and cleans up locks/sessions is needed. Safari on MacOS requires very special treatment given Safari's poor command line support, but that is beyond the scope of this documentation.
TODO(scottb): We technically need a watchdog thread to slurp up stdout and stderr from the child processes, or they might block. However, most browsers never write to stdout and stderr, so this is low priority. (There is now a thread that is spawned for each task to wait for an exit value - this might be adapted for that purpose one day.)
This class is not actually serializable as-is, because timer is not serializable.
see http://bugs.sun.com/bugdatabase/view_bug.do;:YfiG?bug_id=4062587ref
Modifier and Type | Method and Description |
---|---|
void |
keepAlive(int token,
long keepAliveMs)
Keeps the browser process represented by token alive for keepAliveMs,
starting now.
|
void |
killBrowser(int token)
Forceably kills the browser process represented by
token ,
disregarding any previous calls to BrowserManager.keepAlive(int, long) . |
int |
launchNewBrowser(String url,
long keepAliveMs)
Launches a new browser window for the specified URL.
|
static void |
main(String[] args)
Starts up and registers one or more browser servers.
|
clone, exportObject, exportObject, exportObject, unexportObject
getClientHost, getLog, setLog
public static void main(String[] args) throws Exception
Exception
public void keepAlive(int token, long keepAliveMs)
BrowserManager
keepAlive
in interface BrowserManager
token
- an opaque token representing the browser windowkeepAliveMs
- the number of milliseconds to let the browser process
live; if roughly keepAliveMs
milliseconds elapse
without a subsequent call to this method, the browser process
associated with token
will be forceably terminatedBrowserManager.keepAlive(int, long)
public void killBrowser(int token)
BrowserManager
token
,
disregarding any previous calls to BrowserManager.keepAlive(int, long)
. If the
process has already terminated, this method completes normally.killBrowser
in interface BrowserManager
token
- an opaque token representing the browser window processBrowserManager.killBrowser(int)
public int launchNewBrowser(String url, long keepAliveMs)
BrowserManager
launchNewBrowser
in interface BrowserManager
url
- the URL to browse tokeepAliveMs
- the initial number of milliseconds to let the browser
process live; if roughly keepAliveMs
milliseconds
expire without a subsequent call to BrowserManager.keepAlive(int, long)
,
the browser process will be forceably terminatedBrowserManager.launchNewBrowser(java.lang.String, long)
Copyright © 2016. All rights reserved.