S-PLUS Connect/Java v1.0

com.insightful.splus
Class SplusWinSessionImpl

java.lang.Object
  extended by com.insightful.splus.SplusWinSessionImpl
All Implemented Interfaces:
SplusSession, com.insightful.splus.SplusWinSession, Remote

public class SplusWinSessionImpl
extends Object
implements com.insightful.splus.SplusWinSession

Implementation of SplusSession that connects to the S-PLUS engine using Connect/C++. This was initially developed as the Windows equivalent of SplusSessionImpl. It has been extended to support a Connect/C++ based connection on either Windows or UNIX.

Remote operation is not currently supported. This class assumes that the Java client and the S-PLUS engine are running in a single process. This does not support accessing an S-PLUS engine from another machine via RMI.

Currently we only support a single S-PLUS engine connection within a Java process.


Constructor Summary
SplusWinSessionImpl()
           
SplusWinSessionImpl(String[] args)
          args are used to initialize the S-PLUS engine.
 
Method Summary
 void addListener(com.insightful.splus.SplusWinSessionListener listener)
           
static String checkoutLicenseFeature(String feature)
           
 SplusDataResult evalDataQuery(String cmd)
          Evaluate an S-PLUS expression in the S-PLUS engine and retrieve the result as an SplusDataResult.
 SplusDataResult evalDataQuery(String cmd, boolean pingEngine, boolean parseTest)
          Evaluate an S-PLUS expression in the S-PLUS engine and retrieve the result as an SplusDataResult.
 SplusDataResult evalDataQuery(String cmd, boolean Output, boolean Result, boolean Errors, boolean Warnings, boolean Expr)
          Evaluate an expression and get the output as an SplusDataResult.
 SplusDataResult evalDataQuery(String cmd, boolean Output, boolean Result, boolean Errors, boolean Warnings, boolean Expr, boolean pingEngine, boolean parseTest)
          Evaluate an S-PLUS expression in the S-PLUS engine and retrieve the result as an SplusDataResult.
 SplusDataResult evalDataQuery(String cmd, boolean Output, boolean Result, boolean Errors, boolean Warnings, boolean Expr, int timeout)
          Evaluate an S-PLUS expression in the S-PLUS engine and retrieve the result as an SplusDataResult.
 SplusDataResult evalDataQuery(String cmd, boolean Output, boolean Result, boolean Errors, boolean Warnings, boolean Expr, int timeout, boolean pingEngine, boolean parseTest)
          Evaluate an S-PLUS expression in the S-PLUS engine and retrieve the result as an SplusDataResult.
 SplusDataResult evalDataQuery(String cmd, int timeout)
          Evaluate an S-PLUS expression in the S-PLUS engine and retrieve the result as an SplusDataResult.
 SplusDataResult evalDataQuery(String cmd, int timeout, boolean pingEngine, boolean parseTest)
          Evaluate an S-PLUS expression in the S-PLUS engine and retrieve the result as an SplusDataResult.
static void flushOutputBuffer()
          public entry to explicitly flush any output in the output buffer.
 char[] getCertAccess()
          Method allowing clients to get the password to a certificate file on the server.
 String getCertFilename()
          These "Cert" methods are additions to the interface to support RMI over SSL in Analytic Server.
static ClientObjectFactory getClientObjectFactory()
           
 ClientUtilities getClientUtilities()
          This method is used to call server-side methods in SplusSessionImpl under remote operation.
 FileInputStreamProxy getFileInputStream(String filename)
          Get a new FileInputStream.
 FileOutputStreamProxy getFileOutputStream(String filename)
          Get a new FileOutputStream.
 String getPendingInputString()
           
protected  String[] getSessionSpecificArgs(String[] args)
          Method used to add session specific args.
 void Interrupt()
          Interrupt the engine.
 boolean isRemote()
          Always returns "false" since remote operation is not implemented.
static boolean isWindowsGUIClosing()
           
static boolean isWindowsGUILoaded()
          code to handle calls to Splus windows gui fns
 int parseSplusString(String str)
           
 String readSplusErr()
          Not supported, use startPollOutput() instead.
 String readSplusOut()
          Not supported, use startPollOutput() instead.
 void removeListener(com.insightful.splus.SplusWinSessionListener listener)
           
 void sessionExit()
          Shut down the session.
 void sessionExit(boolean killClient)
          Shut down the session.
 void setClientObjectFactory(ClientObjectFactory factory)
          Since remote operation is not supported, it's unlikely that the setClientObjectFactory() and getClientObjectFactory() methods will be used.
static void setDialogActivated(int hwnd, boolean on)
           
static void setDialogRegister(int hwnd, boolean on)
           
static void setExecutingScriptThreaded(boolean val)
           
 void setPromptFlag(boolean prompt)
          Set whether prompts should be printed.
 void startPollOutput(SplusOutputHandler handler)
          Register an SplusOutputHandler to be notified when output is available.
 void writeSplusData(String str)
          Evaluates a String in the engine without returning a result.
 void writeSplusIn(String str)
          Write text to the S-PLUS engine's standard input.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SplusWinSessionImpl

public SplusWinSessionImpl(String[] args)
                    throws RemoteException,
                           SplusLicenseException
args are used to initialize the S-PLUS engine. The first arg should be the program name such as "java.exe". We may want to change this so that args is just additional args for consistency with SplusSessionImpl.

Throws:
RemoteException
SplusLicenseException

SplusWinSessionImpl

public SplusWinSessionImpl()
                    throws RemoteException,
                           SplusLicenseException
Throws:
RemoteException
SplusLicenseException
Method Detail

checkoutLicenseFeature

public static String checkoutLicenseFeature(String feature)

getSessionSpecificArgs

protected String[] getSessionSpecificArgs(String[] args)
Method used to add session specific args. By default, no args are added, but, the Workbench connections could add S_ECLIPSE=T in thie method.

Parameters:
args - String array of arguments passed to the engine connection.

parseSplusString

public int parseSplusString(String str)
Specified by:
parseSplusString in interface com.insightful.splus.SplusWinSession

writeSplusIn

public void writeSplusIn(String str)
                  throws RemoteException
Description copied from interface: SplusSession
Write text to the S-PLUS engine's standard input.

Specified by:
writeSplusIn in interface SplusSession
Throws:
RemoteException

writeSplusData

public void writeSplusData(String str)
                    throws RemoteException
Evaluates a String in the engine without returning a result. Uses SyncParseEval() which generates an error if the expression is not a syntactically complete expression.

In SplusSessionImpl this method is provided as a way to try and clear the data channel, but that isn't relevant here.

Specified by:
writeSplusData in interface SplusSession
Throws:
RemoteException

readSplusOut

public String readSplusOut()
                    throws RemoteException
Not supported, use startPollOutput() instead.

Specified by:
readSplusOut in interface SplusSession
Throws:
RemoteException

readSplusErr

public String readSplusErr()
                    throws RemoteException
Not supported, use startPollOutput() instead.

Specified by:
readSplusErr in interface SplusSession
Throws:
RemoteException

evalDataQuery

public SplusDataResult evalDataQuery(String cmd,
                                     boolean Output,
                                     boolean Result,
                                     boolean Errors,
                                     boolean Warnings,
                                     boolean Expr)
                              throws RemoteException,
                                     SplusEngineBusyException,
                                     SplusIncompleteExpressionException
Evaluate an expression and get the output as an SplusDataResult.

The pingEngine and parseTest arguments are currently ignored. They are used to suppress operations that are not performed on Windows.

Specified by:
evalDataQuery in interface SplusSession
Parameters:
cmd - Expression to evaluate.
Output - Include output in the SplusDataResult.
Result - Include data in the SplusDataResult.
Errors - Include errors in the SplusDataResult.
Warnings - Include warnings in the SplusDataResult.
Expr - Include the expression (cmd) reformatted to match the width of the output.
Throws:
RemoteException
SplusEngineBusyException
SplusIncompleteExpressionException

evalDataQuery

public SplusDataResult evalDataQuery(String cmd)
                              throws RemoteException,
                                     SplusEngineBusyException,
                                     SplusIncompleteExpressionException
Description copied from interface: SplusSession
Evaluate an S-PLUS expression in the S-PLUS engine and retrieve the result as an SplusDataResult.

Specified by:
evalDataQuery in interface SplusSession
Parameters:
cmd - Expression to evaluate.
Throws:
RemoteException
SplusEngineBusyException
SplusIncompleteExpressionException

evalDataQuery

public SplusDataResult evalDataQuery(String cmd,
                                     int timeout)
                              throws RemoteException,
                                     SplusEngineBusyException,
                                     SplusIncompleteExpressionException
Description copied from interface: SplusSession
Evaluate an S-PLUS expression in the S-PLUS engine and retrieve the result as an SplusDataResult.

Specified by:
evalDataQuery in interface SplusSession
Parameters:
cmd - Expression to evaluate.
timeout - Seconds to wait before generating an Engine Busy error.
Throws:
RemoteException
SplusEngineBusyException
SplusIncompleteExpressionException

evalDataQuery

public SplusDataResult evalDataQuery(String cmd,
                                     boolean pingEngine,
                                     boolean parseTest)
                              throws RemoteException,
                                     SplusEngineBusyException,
                                     SplusIncompleteExpressionException
Description copied from interface: SplusSession
Evaluate an S-PLUS expression in the S-PLUS engine and retrieve the result as an SplusDataResult.

Additional flags are available to avert the checking for engine availability and command completeness. This is generally unsafe. If, however, one is certain that the command is correct and the engine is not busy with a previous command or with requests from some other thread, it will speed up the method call by about 150 ms.

Specified by:
evalDataQuery in interface SplusSession
Parameters:
cmd - Expression to evaluate.
pingEngine - Perform a check to see if the S-PLUS engine is responsive.
parseTest - Perform a check to see if the command parses before attempting to evaluate it.
Throws:
RemoteException
SplusEngineBusyException
SplusIncompleteExpressionException

evalDataQuery

public SplusDataResult evalDataQuery(String cmd,
                                     int timeout,
                                     boolean pingEngine,
                                     boolean parseTest)
                              throws RemoteException,
                                     SplusEngineBusyException,
                                     SplusIncompleteExpressionException
Description copied from interface: SplusSession
Evaluate an S-PLUS expression in the S-PLUS engine and retrieve the result as an SplusDataResult.

Additional flags are available to avert the checking for engine availability and command completeness. This is generally unsafe. If, however, one is certain that the command is correct and the engine is not busy with a previous command or with requests from some other thread, it will speed up the method call by about 150 ms.

Specified by:
evalDataQuery in interface SplusSession
Parameters:
cmd - Expression to evaluate.
timeout - Seconds to wait before generating an Engine Busy error.
pingEngine - Perform a check to see if the S-PLUS engine is responsive.
parseTest - Perform a check to see if the command parses before attempting to evaluate it.
Throws:
RemoteException
SplusEngineBusyException
SplusIncompleteExpressionException

evalDataQuery

public SplusDataResult evalDataQuery(String cmd,
                                     boolean Output,
                                     boolean Result,
                                     boolean Errors,
                                     boolean Warnings,
                                     boolean Expr,
                                     int timeout)
                              throws RemoteException,
                                     SplusEngineBusyException,
                                     SplusIncompleteExpressionException
Description copied from interface: SplusSession
Evaluate an S-PLUS expression in the S-PLUS engine and retrieve the result as an SplusDataResult.

This version of the method has boolean flags to indicate which elements to include in the SplusDataResult. Set specific flags to false to avoid shipping over unnecessary information.

Specified by:
evalDataQuery in interface SplusSession
Parameters:
cmd - Expression to evaluate.
Output - Include output in the SplusDataResult.
Result - Include data in the SplusDataResult.
Errors - Include errors in the SplusDataResult.
Warnings - Include warnings in the SplusDataResult.
Expr - Include the expression (cmd) reformatted to match the width of the output.
timeout - Seconds to wait before generating an Engine Busy error.
Throws:
RemoteException
SplusEngineBusyException
SplusIncompleteExpressionException

evalDataQuery

public SplusDataResult evalDataQuery(String cmd,
                                     boolean Output,
                                     boolean Result,
                                     boolean Errors,
                                     boolean Warnings,
                                     boolean Expr,
                                     boolean pingEngine,
                                     boolean parseTest)
                              throws RemoteException,
                                     SplusEngineBusyException,
                                     SplusIncompleteExpressionException
Description copied from interface: SplusSession
Evaluate an S-PLUS expression in the S-PLUS engine and retrieve the result as an SplusDataResult.

This version of the method has boolean flags to indicate which elements to include in the SplusDataResult. Set specific flags to false to avoid shipping over unnecessary information.

Additional flags are available to defeat the checking for engine availability and command completeness. This is generally unsafe. If, however, one is certain that the command is correct and the engine is not busy with a previous command or with requests from some other thread, it will speed up the method call by about 150 ms.

Specified by:
evalDataQuery in interface SplusSession
Parameters:
cmd - Expression to evaluate.
Output - Include output in the SplusDataResult.
Result - Include data in the SplusDataResult.
Errors - Include errors in the SplusDataResult.
Warnings - Include warnings in the SplusDataResult.
Expr - Include the expression (cmd) reformatted to match the width of the output.
pingEngine - Perform a check to see if the S-PLUS engine is responsive.
parseTest - Perform a check to see if the command parses before attempting to evaluate it.
Throws:
RemoteException
SplusEngineBusyException
SplusIncompleteExpressionException

evalDataQuery

public SplusDataResult evalDataQuery(String cmd,
                                     boolean Output,
                                     boolean Result,
                                     boolean Errors,
                                     boolean Warnings,
                                     boolean Expr,
                                     int timeout,
                                     boolean pingEngine,
                                     boolean parseTest)
                              throws RemoteException,
                                     SplusEngineBusyException,
                                     SplusIncompleteExpressionException
Description copied from interface: SplusSession
Evaluate an S-PLUS expression in the S-PLUS engine and retrieve the result as an SplusDataResult.

This version of the method has boolean flags to indicate which elements to include in the SplusDataResult. Set specific flags to false to avoid shipping over unnecessary information.

Additional flags are available to defeat the checking for engine availability and command completeness. This is generally unsafe. If, however, one is certain that the command is correct and the engine is not busy with a previous command or with requests from some other thread, it will speed up the method call by about 150 ms.

Specified by:
evalDataQuery in interface SplusSession
Parameters:
cmd - Expression to evaluate.
Output - Include output in the SplusDataResult.
Result - Include data in the SplusDataResult.
Errors - Include errors in the SplusDataResult.
Warnings - Include warnings in the SplusDataResult.
Expr - Include the expression (cmd) reformatted to match the width of the output.
timeout - Seconds to wait before generating an Engine Busy error.
pingEngine - Perform a check to see if the S-PLUS engine is responsive.
parseTest - Perform a check to see if the command parses before attempting to evaluate it.
Throws:
RemoteException
SplusEngineBusyException
SplusIncompleteExpressionException

Interrupt

public void Interrupt()
               throws RemoteException
Interrupt the engine.

Specified by:
Interrupt in interface SplusSession
Throws:
RemoteException

setClientObjectFactory

public void setClientObjectFactory(ClientObjectFactory factory)
                            throws RemoteException
Since remote operation is not supported, it's unlikely that the setClientObjectFactory() and getClientObjectFactory() methods will be used. They just set and get a ClientObjectFactory private instance.

Specified by:
setClientObjectFactory in interface SplusSession
Throws:
RemoteException

getClientObjectFactory

public static ClientObjectFactory getClientObjectFactory()

getFileInputStream

public FileInputStreamProxy getFileInputStream(String filename)
                                        throws FileNotFoundException,
                                               RemoteException
Get a new FileInputStream.

Specified by:
getFileInputStream in interface SplusSession
Throws:
FileNotFoundException
RemoteException

getFileOutputStream

public FileOutputStreamProxy getFileOutputStream(String filename)
                                          throws FileNotFoundException,
                                                 RemoteException
Get a new FileOutputStream.

Specified by:
getFileOutputStream in interface SplusSession
Throws:
FileNotFoundException
RemoteException

isRemote

public boolean isRemote()
Always returns "false" since remote operation is not implemented.

Specified by:
isRemote in interface SplusSession
Specified by:
isRemote in interface com.insightful.splus.SplusWinSession

sessionExit

public void sessionExit()
Description copied from interface: SplusSession
Shut down the session. As part of shutdown, the session will tell the client to shut itself down.

Specified by:
sessionExit in interface SplusSession
Specified by:
sessionExit in interface com.insightful.splus.SplusWinSession

sessionExit

public void sessionExit(boolean killClient)
Description copied from interface: SplusSession
Shut down the session. Call this with killClient set to true to shut down the session from a client. Call this with killClient set to false to shut down both the session and the related client from the server.

Specified by:
sessionExit in interface SplusSession
Specified by:
sessionExit in interface com.insightful.splus.SplusWinSession
Parameters:
killClient - true to tell the client to shut itself down.

startPollOutput

public void startPollOutput(SplusOutputHandler handler)
                     throws RemoteException
Description copied from interface: SplusSession
Register an SplusOutputHandler to be notified when output is available. If an output handler is registered, text will automatically be written to the output handler as it is generated. Alternately, text will be buffered until it is retrieved via calls to readSplusOut() and readSplusErr().

Specified by:
startPollOutput in interface SplusSession
Throws:
RemoteException

setPromptFlag

public void setPromptFlag(boolean prompt)
Set whether prompts should be printed. Currently prompts are generated in the Java code, so engine mechanisms for setting the prompt don't work.

Specified by:
setPromptFlag in interface com.insightful.splus.SplusWinSession

flushOutputBuffer

public static void flushOutputBuffer()
                              throws RemoteException
public entry to explicitly flush any output in the output buffer.

Throws:
RemoteException

getPendingInputString

public String getPendingInputString()
Specified by:
getPendingInputString in interface com.insightful.splus.SplusWinSession

getCertFilename

public String getCertFilename()
                       throws RemoteException
These "Cert" methods are additions to the interface to support RMI over SSL in Analytic Server. They may always remain no-ops in SplusWinSessionImpl.

Specified by:
getCertFilename in interface SplusSession
Throws:
RemoteException

getCertAccess

public char[] getCertAccess()
                     throws RemoteException
Description copied from interface: SplusSession
Method allowing clients to get the password to a certificate file on the server. This allows the client to use the same SSL encryption credentials as the server when instancing client-side remote objects.

Specified by:
getCertAccess in interface SplusSession
Throws:
RemoteException

getClientUtilities

public ClientUtilities getClientUtilities()
                                   throws RemoteException
This method is used to call server-side methods in SplusSessionImpl under remote operation. It just returns a local ClientUtilities object here.

Specified by:
getClientUtilities in interface SplusSession
Throws:
RemoteException

isWindowsGUILoaded

public static boolean isWindowsGUILoaded()
code to handle calls to Splus windows gui fns


isWindowsGUIClosing

public static boolean isWindowsGUIClosing()

setExecutingScriptThreaded

public static void setExecutingScriptThreaded(boolean val)

setDialogRegister

public static void setDialogRegister(int hwnd,
                                     boolean on)

setDialogActivated

public static void setDialogActivated(int hwnd,
                                      boolean on)

addListener

public void addListener(com.insightful.splus.SplusWinSessionListener listener)
Specified by:
addListener in interface com.insightful.splus.SplusWinSession

removeListener

public void removeListener(com.insightful.splus.SplusWinSessionListener listener)
Specified by:
removeListener in interface com.insightful.splus.SplusWinSession

S-PLUS Connect/Java v1.0

Copyright © 2000, 2002 Insightful Corporation
Warning: Classes not documented in the S-PLUS Programmer's Guide may change in future releases.