|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.rmi.server.RemoteObject | +--java.rmi.server.RemoteServer | +--java.rmi.server.UnicastRemoteObject | +--edu.rice.cs.drjava.model.repl.newjvm.MainJVM
Manages a remote JVM.
Inner Class Summary | |
private class |
MainJVM.RestartThread
|
Field Summary | |
private String |
_identifier
The name of the RMI object for the present JVM. |
private InterpreterJVMRemoteI |
_interpreterJVM
This is the pointer to the interpreter JVM remote object, used to call back to it. |
private Process |
_interpreterProcess
Process object for the running interpreter, or null if none. |
private GlobalModel |
_model
The global model. |
private MainJVM.RestartThread |
_restartThread
|
private Timer |
_restartTimer
|
private static int |
_rmiPort
Port on which RMI registry is running. |
private boolean |
_startupInProgress
Is there a JVM in the process of starting up? This variable is protected by synchronized(this). |
private MainJVM.RestartThread |
_timerThread
|
private static int |
RESET_TIME_OUT
How long to wait for an interpreter to register itself before starting another attempt. |
Fields inherited from class java.rmi.server.UnicastRemoteObject |
csf, port, portFactoryParamTypes, portParamTypes, serialVersionUID, ssf |
Fields inherited from class java.rmi.server.RemoteServer |
log, logname |
Fields inherited from class java.rmi.server.RemoteObject |
ref |
Constructor Summary | |
MainJVM(GlobalModel model)
Creates a new MainJVM to handle communication with the Interpreter JVM, and instantiates the Interpreter JVM. |
|
MainJVM(GlobalModel model,
int rmiPort)
Creates a new MainJVM to handle communication with the Interpreter JVM, and instantiates the Interpreter JVM. |
|
MainJVM(int rmiPort)
Creates a MainJVM without a model. |
Method Summary | |
private String |
_createIdentifier()
Returns a unique identifier to name this Main JVM. |
private static int |
_generateSafeRMIPort()
Returns a unique port to be safely used for RMI. |
private void |
_startNameServiceIfNeeded()
Creates a new RMI registry for this copy on the current rmi port, if it is not already running. |
private void |
_stopTimerThread()
|
private void |
_threwException(Throwable t)
|
(package private) static void |
|
void |
addClassPath(String path)
|
protected boolean |
allowAssertions()
Return whether to allow assertions in the InterpreterJVM. |
void |
checkStillAlive()
Returns whether we are in the process of cleanly resetting the interactions JVM. |
void |
ensureInterpreterConnected()
If an interpreter has not registered itself, this method will block until one does. |
protected int |
getDebugPort()
Returns the debug port to use, as specified by the model. |
String |
getIdentifier()
|
void |
interpret(String s)
|
void |
killInterpreter()
|
void |
nonTestCase()
|
void |
registerInterpreterJVM(InterpreterJVMRemoteI remote)
Registers the interpreter JVM for later callbacks. |
protected void |
replCalledSystemExit(int status)
Action to take if the Repl tries to exit. |
void |
reset()
|
void |
restartInterpreterJVM()
Kills current interpreter JVM if any, then starts a new one. |
void |
returnedResult(String result)
Signifies that the most recent interpretation completed successfully, returning a value. |
void |
returnedVoid()
Signifies that the most recent interpretation completed successfully, returning no value. |
void |
runTest(String className,
String fileName)
|
void |
setModel(GlobalModel model)
For test cases, we reuse the same MainJVM for efficiency. |
void |
setPackageScope(String packageName)
|
void |
systemErrPrint(String s)
|
void |
systemOutPrint(String s)
|
void |
testFinished(JUnitError[] errors)
|
void |
threwException(String exceptionClass,
String message,
String stackTrace)
Signifies that the most recent interpretation was ended due to an exception being thrown. |
Methods inherited from class java.rmi.server.UnicastRemoteObject |
clone, exportObject, exportObject, exportObject, exportObject, readObject, reexport, unexportObject |
Methods inherited from class java.rmi.server.RemoteServer |
getClientHost, getLog, setLog |
Methods inherited from class java.rmi.server.RemoteObject |
equals, getRef, hashCode, toString, toStub, writeObject |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, registerNatives, wait, wait, wait |
Field Detail |
private final String _identifier
private static final int RESET_TIME_OUT
private static int _rmiPort
private GlobalModel _model
private boolean _startupInProgress
private MainJVM.RestartThread _restartThread
private MainJVM.RestartThread _timerThread
private Timer _restartTimer
private InterpreterJVMRemoteI _interpreterJVM
registerInterpreterJVM(edu.rice.cs.drjava.model.repl.newjvm.InterpreterJVMRemoteI)
, which is called by the interpreter
JVM itself over RMI.
This can only be changed while holding the object lock.private Process _interpreterProcess
Constructor Detail |
public MainJVM(GlobalModel model) throws RemoteException
model
- GlobalModel wishing to communicate with the Interpreter.public MainJVM(GlobalModel model, int rmiPort) throws RemoteException
model
- GlobalModel wishing to communicate with the Interpreter.rmiPort
- Port on which to start the RMI registry. If -1,
then a unique port will be used.public MainJVM(int rmiPort) throws RemoteException
port
- on which to run the RMI registry, or -1 for a unique port.Method Detail |
static void()
public void setModel(GlobalModel model)
public void interpret(String s)
public void addClassPath(String path)
public void setPackageScope(String packageName)
public void reset()
public String getIdentifier()
public void systemErrPrint(String s) throws RemoteException
systemErrPrint
in interface MainJVMRemoteI
public void systemOutPrint(String s) throws RemoteException
systemOutPrint
in interface MainJVMRemoteI
public void registerInterpreterJVM(InterpreterJVMRemoteI remote) throws RemoteException
registerInterpreterJVM
in interface MainJVMRemoteI
remote
- The interpreter JVM controller.public void returnedVoid() throws RemoteException
returnedVoid
in interface MainJVMRemoteI
public void returnedResult(String result) throws RemoteException
returnedResult
in interface MainJVMRemoteI
result
- The .toString-ed version of the value that was returned
by the interpretation. We must return the String form
because returning the Object directly would require the
data type to be serializable.public void threwException(String exceptionClass, String message, String stackTrace) throws RemoteException
threwException
in interface MainJVMRemoteI
exceptionClass
- The name of the class of the thrown exceptionmessage
- The exception's messagestackTrace
- The stack trace of the exceptionpublic void killInterpreter()
public void restartInterpreterJVM()
_startupInProgress
guard,
we were starting up two jvms in quick succession sometimes. This caused
nasty problems (sometimes, it was a timing thing!) if the addClasspath
issued after an abort went to the first JVM but then future
interpretations went to the second JVM! So, we can make
restartInterpreterJVM safe for duplicate calls by just not starting
another if the previous one is in the process of starting up.private void _stopTimerThread()
protected int getDebugPort()
protected boolean allowAssertions()
protected void replCalledSystemExit(int status)
status
- Exit code from the interpreter JVMpublic void checkStillAlive() throws RemoteException
checkStillAlive
in interface MainJVMRemoteI
private synchronized boolean _isResetting() {
//DrJava.consoleOut().println("isResetting: resetInProgress: " + _resetInProgress);
return _resetInProgress;
}
private void _threwException(Throwable t)
public void ensureInterpreterConnected()
private static int _generateSafeRMIPort()
private void _startNameServiceIfNeeded()
private String _createIdentifier()
public void runTest(String className, String fileName)
public void nonTestCase() throws RemoteException
nonTestCase
in interface MainJVMRemoteI
public void testFinished(JUnitError[] errors) throws RemoteException
testFinished
in interface MainJVMRemoteI
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |