*** This interface provides Binary Compatibility only, not Source Compatibility ***
Interface Execution2Interface
- All Superinterfaces:
ExecutionBaseInterface,Remote
- Since:
- 9.2
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe abort method has been called.static final intThe stored process is waiting for a connection to become available.Fields inherited from interface com.sas.services.storedprocess.ExecutionBaseInterface
LOG_ALL_LINES, LOG_FORMAT_HTML, LOG_FORMAT_TEXT, STATUS_COMPLETED_WITHOUT_EXCEPTION, STATUS_DESTROYED, STATUS_EXCEPTION_OCCURRED, STATUS_EXECUTING, STATUS_SAS_EXCEPTION_OCCURRED -
Method Summary
Modifier and TypeMethodDescriptionvoidabort()Abort execution of the stored process.voiddestroy()Free resources allocated by the service for this execution.InputStreamgetInputStream(Object streamKey) Get an input stream.getOutputParameter(String name) Get theOutputParameterInterfaceobject corresponding to the output parameter (SAS macro variable) name specified from the list returned bygetOutputParameters().List<OutputParameterInterface> Returns the list of output parameters asOutputParameterInterfaceobjects.OutputStreamgetOutputStream(Object streamKey) Get an output stream.Get the package produced by the execution of the stored process.intGet the SAS condition code associated with the execution of the stored process.Get the SAS listing associated with this execution.getSASListing(int maxLines) Get the SAS listing associated with this execution./** Get the SAS log associated with this execution.getSASLog(int maxLines) Get the SAS log associated with this execution.StringGet the session id associated with this execution.intGet the status of this execution.StringreadSASLog(int flag, int maxLines) Read the SAS log associated with this execution.voidsetResultPackageLifeCycleBound(boolean boundToLifeCycle) Sets whether the life-cycle of the package is bound to theExecution2Interface.intWait until a connection to the server is available.intwaitForConnection(long milliSecondTimeout) Wait until a connection to the server is available or until the time specified has elapsed.Methods inherited from interface com.sas.services.storedprocess.ExecutionBaseInterface
getExceptions, getInputStreamHeader, getOutputStreamHeader, getStoredProcessAlert, isSynchronous, waitForCompletion, waitForCompletion
-
Field Details
-
STATUS_ABORTED
static final int STATUS_ABORTEDThe abort method has been called. This is one of the values returned bygetStatus().- See Also:
-
STATUS_WAITING_FOR_CONNECTION
static final int STATUS_WAITING_FOR_CONNECTIONThe stored process is waiting for a connection to become available. This is one of the values returned bygetStatus()and is returned ifStoredProcess2Interface.executeAsynch(ExecutionStatusListener2Interface, boolean)is called and a server is not available.- See Also:
-
-
Method Details
-
destroy
void destroy() throws RemoteException, IllegalStateException, ConnectionFactoryException, TransportExceptionFree resources allocated by the service for this execution. This method is called after the client has processed all output from the stored process to perform resource cleanup. The following is done:- If the stored process delivers a package the package is closed unless the life cycle of the package is not bound to the execution interface.
- If a connection was obtained from the connection service by the stored process service the connection is released.
- Frees any logger associated with this object.
If the stored process is executed asynchronously and this method is called while the stored process is still executing an IllegalStateException will be thrown by this method. For such use cases, it's recommended that
ExecutionBaseInterface.waitForCompletion()be called before the call to this method.- Specified by:
destroyin interfaceExecutionBaseInterface- Throws:
ConnectionFactoryException- if thrown by the Connection Service when closing the connectionIllegalStateException- if the status isSTATUS_WAITING_FOR_CONNECTION,ExecutionBaseInterface.STATUS_EXECUTINGor this method is called a second time.TransportException- if there is a problem communicating with the SAS server.RemoteException- if a network anomaly is encountered.
-
getInputStream
InputStream getInputStream(Object streamKey) throws IllegalStateException, RemoteException Get an input stream. Input streams are only available for stored processes with server typeStoredProcessBaseInterface.SERVER_TYPE_STOREDPROCESS. Either the stream needs to be defined as a data target, or, in the case of _WEBOUT, streaming capability should be selected for execution.If execution is via
StoredProcess2Interface.executeAsynch(ExecutionStatusListener2Interface, boolean), this method blocks onwaitForConnection()if a connection to the server is not available.- Specified by:
getInputStreamin interfaceExecutionBaseInterface- Parameters:
streamKey- an object whose toString method provides the stream name.- Returns:
- A serializable object which implements InputStream or null if not available
- Throws:
IllegalStateException- if destroy() has been called.RemoteException- if a network anomaly is encountered.
-
getOutputStream
OutputStream getOutputStream(Object streamKey) throws IllegalStateException, RemoteException Get an output stream. Output streams are only available for stored processes with server typeStoredProcessBaseInterface.SERVER_TYPE_STOREDPROCESS.If execution is via
StoredProcess2Interface.executeAsynch(ExecutionStatusListener2Interface, boolean), this method blocks onwaitForConnection()if a connection to the server is not available.- Specified by:
getOutputStreamin interfaceExecutionBaseInterface- Parameters:
streamKey- an object whose toString method provides the stream name.- Returns:
- A serializable object which implements OutputStream or null if not available
- Throws:
IllegalStateException- if destroy() has been called.RemoteException- if a network anomaly is encountered.
-
getOutputParameters
Returns the list of output parameters asOutputParameterInterfaceobjects. All output parameters defined in metadata are automatically present in this list. However, the list may also contain items not defined in metadata as described ingetOutputParameter(String).For stored processes run on a Workspace server this functionality is unavailable and an IllegalStateException is thrown.
- Throws:
IllegalStateException- if the status isSTATUS_WAITING_FOR_CONNECTION,ExecutionBaseInterface.STATUS_EXECUTINGorExecutionBaseInterface.STATUS_SAS_EXCEPTION_OCCURRED, or if destroy() has been called.RemoteException- if a network anomaly is encountered.TransportException
-
getOutputParameter
Get theOutputParameterInterfaceobject corresponding to the output parameter (SAS macro variable) name specified from the list returned bygetOutputParameters().If no output parameter with that name is found in the list, the server is queried to see if a value is associated with that SAS macro name. If there is no value, a null is returned. If there is a value, a OutputParameterInterface with type String for that name is created and returned; also, the newly created OutputParameterInterface is added to the list of output parameters returned by
getOutputParameters().For stored processes run on a Workspace server this functionality is unavailable and an IllegalStateException is thrown.
- Parameters:
name- the name of the output parameter whose value is desired.- Returns:
- the
OutputParameterInterfacefor the name specified - Throws:
IllegalStateException- if the status isSTATUS_WAITING_FOR_CONNECTION,ExecutionBaseInterface.STATUS_EXECUTING,ExecutionBaseInterface.STATUS_SAS_EXCEPTION_OCCURRED, or if destroy() has been called.TransportException- if there is a problem communicating with the SAS server.RemoteException- if a network anomaly is encountered.
-
getResultPackage
Get the package produced by the execution of the stored process. Packages are only available for those stored processes which the service is aware are creating packages which are SAS server based or DAV server based.- Specified by:
getResultPackagein interfaceExecutionBaseInterface- Returns:
- the package or null if there is none.
- Throws:
RemoteException- if a network anomaly is encountered.IllegalStateException- if the status isSTATUS_WAITING_FOR_CONNECTION,ExecutionBaseInterface.STATUS_EXECUTING,ExecutionBaseInterface.STATUS_SAS_EXCEPTION_OCCURREDorSTATUS_ABORTED, or if destroy() has been called.
-
getSASConditionCode
int getSASConditionCode() throws RemoteExceptionGet the SAS condition code associated with the execution of the stored process. For stored processes run on a Workspace server the condition code is not available and a value of zero is returned.- Specified by:
getSASConditionCodein interfaceExecutionBaseInterface- Returns:
- the SAS condition code.
- Throws:
RemoteException- if a network anomaly is encountered.IllegalStateException- if the status isSTATUS_WAITING_FOR_CONNECTION,ExecutionBaseInterface.STATUS_EXECUTINGorExecutionBaseInterface.STATUS_SAS_EXCEPTION_OCCURRED, or if destroy() has been called.
-
setResultPackageLifeCycleBound
void setResultPackageLifeCycleBound(boolean boundToLifeCycle) throws ResultsBindingException, RemoteException, IllegalStateException Sets whether the life-cycle of the package is bound to theExecution2Interface. By default, the life-cycle of the package is bound to theExecution2Interface. If it is, the package is closed whendestroy()is called. This method is called before the result pacakge is accessed viagetResultPackage().- Parameters:
boundToLifeCycle- true - package is closed by ExecutionInteface's destroy(); false - package life controlled by consumer.- Throws:
ResultsBindingException- if there is no result package or an exception occurs making a copyIllegalStateException- if called after getResultPackage() is accessed or if called a second time with a different argumentRemoteException- if a network anomaly is encountered.
-
getStatus
int getStatus() throws RemoteExceptionGet the status of this execution.If the stored process is executing
STATUS_EXECUTINGis returned. If it has completed, one ofSTATUS_COMPLETED_WITHOUT_EXCEPTION,STATUS_SAS_EXCEPTION_OCCURREDorSTATUS_EXCEPTION_OCCURREDis returned depending on how execution terminated. If stored process execution was aborted by using theabort()method,STATUS_ABORTEDis returned unless execution was complete at the time of the abort.Note: if the exception is due to the more specific reasons specified in
STATUS_SAS_EXCEPTION_OCCURREDthenSTATUS_SAS_EXCEPTION_OCCURREDis returned over the more genericSTATUS_EXCEPTION_OCCURRED.- Specified by:
getStatusin interfaceExecutionBaseInterface- Throws:
IllegalStateException- if destroy() has been called.RemoteException- if a network anomaly is encountered.
-
abort
Abort execution of the stored process. This method can only be called to abort the stored process if the stored process is executed by invokingStoredProcess2Interface.executeAsynch(ExecutionStatusListener2Interface, boolean)or asynchronously viaStoredProcess2Interface.execute(boolean, ExecutionStatusListener2Interface, boolean, Object); however, if execute() has been called synchronously thisExecution2Interfaceobject is not available until after execution is completed and no purpose would be served by calling abort.If the stored process has not completed execution at the time this method is called, the stored process is interrupted (if execution has begun) and the status returned by
getStatus()isSTATUS_ABORTED. If the stored process has completed execution at the time this method is called there is no change in the value returned by thegetStatus().If executeAsynch() was used and execution of the stored process is waiting for a connection to become available, this method does not interrupt that process. However, once a connection does become available execution will not occur due to the pending abort().
The following items, if applicable, may be obtained from an aborted stored process:
- the SAS log (see
ExecutionBaseInterface.readSASLog(int, int)) - output parameters (see
getOutputParameter(String)orgetOutputParameters()) - the SAS condition code (see
ExecutionBaseInterface.getSASConditionCode())
- Throws:
IllegalStateException- if destroy() has been called or if the stored process is being executed synchronouslyRemoteException- if a network anomaly is encountered.TransportException- if there is a problem communicating with the SAS server.
- the SAS log (see
-
getSessionID
String getSessionID() throws IllegalStateException, RemoteExceptionGet the session id associated with this execution. Session ids are unique to stored process executions under the StoredProcess server.- Specified by:
getSessionIDin interfaceExecutionBaseInterface- Returns:
- the session id or null if there is no session id associated with the execution.
- Throws:
RemoteException- if a network anomaly is encountered.IllegalStateException- if the status isSTATUS_WAITING_FOR_CONNECTION,ExecutionBaseInterface.STATUS_EXECUTING,ExecutionBaseInterface.STATUS_SAS_EXCEPTION_OCCURREDorSTATUS_ABORTED, or if destroy() has been called.
-
getSASLog
/** Get the SAS log associated with this execution. The method returns all the lines of the log that are yet to be obtained - a specified number of lines can be obtained by invoking thegetSASLog(int)method. Any subsequent calls to obtain the SAS log return an empty object.The method should only be called after execution is complete.
- Returns:
- a
SASLogobject containing the log - Throws:
RemoteException- if a network anomaly is encountered.IllegalStateException- if the status isSTATUS_WAITING_FOR_CONNECTION,ExecutionBaseInterface.STATUS_EXECUTINGor if destroy() has been called.TransportException- if there is a problem communicating with the SAS server.
-
getSASLog
Get the SAS log associated with this execution. The parameter specifies the number of lines to be returned - all lines in the log can be requested by invoking thegetSASLog()method. If a call does not return all lines available, subsequent calls to obtain remaining SAS log lines return lines in the log after those previously returned. Once all lines have been returned, any subsequent call returns an empty object.The method should only be called after execution is complete.
- Parameters:
maxLines- the maximum number of lines to get- Returns:
- a
SASLogobject containing the log - Throws:
RemoteException- if a network anomaly is encountered.IllegalStateException- if the status isSTATUS_WAITING_FOR_CONNECTION,ExecutionBaseInterface.STATUS_EXECUTINGor if destroy() has been called.TransportException- if there is a problem communicating with the SAS server.
-
getSASListing
Get the SAS listing associated with this execution. The method returns all the lines of the listing that are yet to be obtained - a specified number of lines can be obtained by invoking thegetSASListing(int)method. Any subsequent calls to this method or togetSASListing(int)return an empty object.The method should only be called after execution is complete.
- Returns:
- a
SASLogobject containing the listing - Throws:
RemoteException- if a network anomaly is encountered.IllegalStateException- if the status isSTATUS_WAITING_FOR_CONNECTION,ExecutionBaseInterface.STATUS_EXECUTINGor if destroy() has been called.TransportException- if there is a problem communicating with the SAS server.
-
getSASListing
SASLog getSASListing(int maxLines) throws RemoteException, IllegalStateException, TransportException Get the SAS listing associated with this execution. The parameter specifies the number of lines to be returned - all lines in the listing can be requested by invoking thegetSASListing()method. If a call does not return all lines available, subsequent calls to this method or togetSASListing()return lines in the listing after those previously returned. Once all lines have been returned, any subsequent calls will return an empty object.The method should only be called after execution is complete.
- Parameters:
maxLines- the maximum number of lines to get- Returns:
- a
SASLogobject containing the listing - Throws:
RemoteException- if a network anomaly is encountered.IllegalStateException- if the status isSTATUS_WAITING_FOR_CONNECTION,ExecutionBaseInterface.STATUS_EXECUTINGor if destroy() has been called.TransportException- if there is a problem communicating with the SAS server.
-
readSASLog
String readSASLog(int flag, int maxLines) throws RemoteException, IllegalStateException, TransportException Read the SAS log associated with this execution. Once "read", subsequent calls to this method will return lines in the log after those previously returned. If a call requests all lines (ExecutionBaseInterface.LOG_ALL_LINES) or more lines than are present, that call returns the lines available but subsequent calls return an empty string unless there has been output to the log after that call. System.getProperty("line.separator") is used to obtain the newline character sequence that is inserted after each line in the returned string. IfExecutionBaseInterface.LOG_FORMAT_HTMLtype output is requested the returned string is enclosed by "PRE" tags and another newline character sequence appended after the closing "PRE" tag.- Specified by:
readSASLogin interfaceExecutionBaseInterface- Parameters:
flag- one ofExecutionBaseInterface.LOG_FORMAT_TEXTorExecutionBaseInterface.LOG_FORMAT_HTMLmaxLines- the maximum number of lines to get orExecutionBaseInterface.LOG_ALL_LINESif all lines are needed- Returns:
- a String containing the formatted log
- Throws:
RemoteException- if a network anomaly is encountered.IllegalStateException- if the status isSTATUS_WAITING_FOR_CONNECTION,ExecutionBaseInterface.STATUS_EXECUTINGor if destroy() has been called.TransportException- if there is a problem communicating with the SAS server.
-
waitForConnection
int waitForConnection() throws InterruptedException, RemoteExceptionWait until a connection to the server is available. Besides a server becoming available, the method also waits for streams, if defined, to be connected. If the connections are done it returns immediately; if not, it blocks (using Java's wait/notify mechanism) until the connections are made.- Returns:
- the completion status - same return value as would be obtained by
calling
getStatus(). - Throws:
IllegalStateException- if destroy() has been called.InterruptedException- if the thread executing the method is interruptedRemoteException- if a network anomaly is encountered.- See Also:
-
waitForConnection
int waitForConnection(long milliSecondTimeout) throws InterruptedException, RemoteException Wait until a connection to the server is available or until the time specified has elapsed. Besides a server becoming available, the method also waits for streams, if defined, to be connected. If the connections are done it returns immediately; if not, it blocks (using Java's wait/notify mechanism) until the connections are made or the time specified has elapsed.- Parameters:
milliSecondTimeout- - the maximum time to wait in milliseconds- Returns:
- the completion status - same return value as would be obtained by
calling
getStatus(). - Throws:
IllegalStateException- if destroy() has been called.InterruptedException- if the thread executing the method is interruptedRemoteException- if a network anomaly is encountered.- See Also:
-