Interface IZOSUserProgramConnection
-
- All Superinterfaces:
IHostConnection
public interface IZOSUserProgramConnection extends IHostConnection
A connection to a z/OS user program.z/OS user program connections are used to launch and communicate with z/OS user programs.
launchUserProgram(IZOSCredentials, String, String)
must be called in order to establish a connection to the associated z/OS host and launch a user program.getInputStream()
andgetOutputStream()
should not be called until a connection to the associated z/OS host has been established and a user program is executing. Only one user program may be executing on a z/OS user program connection at once.Examples:
To launch a z/OS user program:IZOSHost zosHost = ... String userID = ... String password = ... String userProcedureName = ... String userProgramName = ... // use one of the several ZOSCredentialsFactory methods to create a z/OS // credentials object IZOSCredentials credentials = ZOSCredentialsFactory .createZOSCredentials(userID, password); // create a z/OS user program connection from the z/OS host IZOSUserProgramConnection zosUserProgramConnection = zosHost .createZOSUserProgramConnection(); try { // launch the z/OS user program zosUserProgramConnection.launchUserProgram(credentials, userProcedureName, userProgramName); // the z/OS user program connection is now able to communicate with the // program (for as long as it remains running) ... } catch (HostCredentialsException e) { // credentials were invalid, likely caused by incorrect login // information or expired password ... }
Note: If writing a plug-in that runs in a Topaz Workbench installation, you can use theZOSUIUserCredentialsManager
class in thecom.compuware.api.topaz.eclpse
plug-in to retrieve the credentials of the currently logged in Topaz Workbench UI user. Seecom.compuware.api.topaz.eclipse.hostcredentials.zos.ZOSUIUserCredentialsManager
for more details.For examples on how to obtain
IZOSHost
s seeIZOSHost
.
For examples on how to send data to a z/OS user program seegetOutputStream()
.
For examples on how to receive data from a z/OS user program seegetInputStream()
.
For examples on how to listen to z/OS user program termination events seeIZOSUserProgramTerminationListener
.- Since:
- 1.0.0
- Version:
- 2.0.0
- Restriction:
- This interface is not intended to be extended by clients.
- Restriction:
- This interface is not intended to be implemented by clients.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addUserProgramTerminationListener(IZOSUserProgramTerminationListener listener)
Adds the specified z/OS user program termination listener.IZOSHost
getHost()
Returns the z/OS host associated with this z/OS user program connection.InputStream
getInputStream()
Returns an input stream that can be used to read data from an executing z/OS user program.OutputStream
getOutputStream()
Returns an output stream that can be used to write data to an executing z/OS user program.String
getUserProcedureName()
Returns the name of the currently executing z/OS user procedure.String
getUserProgramName()
Returns the name of the currently executing z/OS user program.boolean
isUserProgramExecuting()
Returns whether a z/OS user program is currently executing.void
launchUserProgram(IZOSCredentials credentials, String userProcedureName, String userProgramName)
Launches the z/OS user program with the specified credentials, z/OS user procedure name, and z/OS user program name.void
removeUserProgramTerminationListener(IZOSUserProgramTerminationListener listener)
Removes the specified z/OS user program termination listener.-
Methods inherited from interface com.compuware.api.topaz.hostconnections.IHostConnection
disconnect, isConnected
-
-
-
-
Method Detail
-
getHost
IZOSHost getHost()
Returns the z/OS host associated with this z/OS user program connection.- Specified by:
getHost
in interfaceIHostConnection
- Returns:
- the z/OS host
- Since:
- 1.0.0
-
addUserProgramTerminationListener
void addUserProgramTerminationListener(IZOSUserProgramTerminationListener listener)
Adds the specified z/OS user program termination listener.For examples on how to listen to z/OS user program termination events see
IZOSUserProgramTerminationListener
.- Parameters:
listener
- the listener to add- Throws:
IllegalArgumentException
- iflistener
isnull
- Since:
- 1.0.0
- See Also:
removeUserProgramTerminationListener(IZOSUserProgramTerminationListener)
,IZOSUserProgramTerminationListener
-
removeUserProgramTerminationListener
void removeUserProgramTerminationListener(IZOSUserProgramTerminationListener listener)
Removes the specified z/OS user program termination listener.This method has no effect if the specified listener was never added.
For examples on how to listen to z/OS user program termination events see
IZOSUserProgramTerminationListener
.- Parameters:
listener
- the listener to remove- Throws:
IllegalArgumentException
- iflistener
isnull
- Since:
- 1.0.0
- See Also:
addUserProgramTerminationListener(IZOSUserProgramTerminationListener)
,IZOSUserProgramTerminationListener
-
getUserProgramName
String getUserProgramName()
Returns the name of the currently executing z/OS user program.- Returns:
- the name of the currently executing z/OS user program, or
null
if no z/OS user program is currently executing - Since:
- 1.0.0
-
getUserProcedureName
String getUserProcedureName()
Returns the name of the currently executing z/OS user procedure.- Returns:
- the name of the currently executing z/OS user procedure, or
null
if no z/OS user procedure is currently executing - Since:
- 1.0.0
-
isUserProgramExecuting
boolean isUserProgramExecuting()
Returns whether a z/OS user program is currently executing.- Returns:
true
if a z/OS user program is currently executing,false
otherwise- Since:
- 1.0.0
-
launchUserProgram
void launchUserProgram(IZOSCredentials credentials, String userProcedureName, String userProgramName) throws UserIDException, PasswordException, GroupException, DigitalCertificateException
Launches the z/OS user program with the specified credentials, z/OS user procedure name, and z/OS user program name.- Parameters:
credentials
- the credentialsuserProcedureName
- the z/OS user procedureuserProgramName
- the z/OS user program- Throws:
IllegalArgumentException
- ifuserProgramName
isnull
or invalidHostNotConnectedException
- if the z/OS host is not connectedHostNotDefinedException
- if the z/OS host is not definedHostNotReachableException
- if the z/OS host is not reachableHostIOException
- if anIOException
occurs while attempting to launch z/OS user programUserProgramConcurrentExecutionException
- if another z/OS user program is currently executingUserProgramNotFoundException
- if the specified z/OS user program could not be foundUserProgramLaunchException
- if the user program fails to execute API setup or the user procedure does not existZOSSystemException
- if a z/OS system error occurs while attempting to launch z/OS user programZOSAbendException
- if a z/OS ABEND occurs while attempting to launch z/OS user programZOSLicenseException
- if no license is found on the hostUserIDException
- if a user ID is specified but is invalidPasswordException
- if a password is specified but is invalidGroupException
- if a group is specified but is invalidDigitalCertificateException
- if a digital certificate is specified but is invalid- Since:
- 1.0.0
-
getInputStream
InputStream getInputStream()
Returns an input stream that can be used to read data from an executing z/OS user program.An input stream can only be obtained after the z/OS user program is launched.
The returned input stream is only valid for the z/OS user program for which it is associated.
The input stream treats the termination of the z/OS user program as the end of the stream. (Any data sent prior to termination will still be accessible via this input stream.)
As long as the same z/OS user program is executing, this method will return the same input stream. Care should be taken to prevent multiple threads from using this input stream at the same time.
Note: all of
InputStream
'sread
methods will block until the z/OS user program sends data, is terminated, or anIOException
occurs.Examples:
To read byte data from a z/OS user program:IZOSUserProgramConnection zosUserProgramConnection = ... byte[] buffer = ... try { // get the z/OS user program's input stream // Note: a z/OS user program must be executing before calling this method InputStream inputStream = zosUserProgramConnection.getInputStream(); // use any of the input stream's "read" methods to read data int numBytesRead = inputStream.read(buffer); } catch (IOException e) { // an IO error occurred reading data from the input stream ... }
To read text data from a z/OS user program:IZOSUserProgramConnection zosUserProgramConnection = ... try { // get the z/OS user program's input stream // Note: a z/OS user program must be executing before calling this method InputStream inputStream = zosUserProgramConnection.getInputStream(); // wrap the z/OS user program's input stream in a buffered reader // Note: this code assumes the z/OS user program is encoding its data // using UTF-8 BufferedReader reader = new BufferedReader(new InputStreamReader( inputStream, "UTF-8")); // use the any of the reader's "read" methods to read text from the // z/OS user program String data = reader.readLine(); } catch (IOException e) { // an IO error occurred wrapping the input stream or reading data from it ... }
For examples on how to launch a z/OS user program, seeIZOSUserProgramConnection
.
For examples on how to send data to a z/OS user program, seegetOutputStream()
.- Returns:
- the input stream
- Throws:
UserProgramNotExecutingException
- if a z/OS user program is not currently executing- Since:
- 1.0.0
- See Also:
isUserProgramExecuting()
,getOutputStream()
-
getOutputStream
OutputStream getOutputStream()
Returns an output stream that can be used to write data to an executing z/OS user program.An output stream can only be obtained after the z/OS user program is launched.
The returned output stream is only valid for the z/OS user program for which it is associated.
The output stream becomes invalid when the z/OS user program is terminated.
As long as the same z/OS user program is executing, this method will return the same output stream. Care should be taken to prevent multiple threads from using this output stream at the same time.
Examples:
To send byte data to a z/OS user program:IZOSUserProgramConnection zosUserProgramConnection = ... byte[] data = ... try { // get the z/OS user program's output stream // Note: a z/OS user program must be executing before calling this method OutputStream outputStream = zosUserProgramConnection.getOutputStream(); // use any of the output stream's "write" methods to write data outputStream.write(data); } catch (IOException e) { // an IO error occurred writing data to the output stream ... }
To send text data to a z/OS user program:IZOSUserProgramConnection zosUserProgramConnection = ... String data = ... try { // get the z/OS user program's output stream // Note: a z/OS user program must be executing before calling this method OutputStream outputStream = zosUserProgramConnection.getOutputStream(); // wrap the z/OS user program's output stream in a buffered writer // Note: this code assumes the z/OS user program is decoding received // data using UTF-8 BufferedWriter writer = new BufferedWriter(new OutputStreamWriter( outputStream, "UTF-8")); // use any of the writer's "write" methods to write text to the user // program writer.write(data); // flush the writer to ensure the data gets sent to the z/OS user program writer.flush(); } catch (IOException e) { // an IO error occurred wrapping the output stream or writing data to it ... }
For examples on how to launch a z/OS user program seeIZOSUserProgramConnection
.
For examples on how to receive data from a z/OS user program seegetInputStream()
.- Returns:
- the output stream
- Throws:
UserProgramNotExecutingException
- if a z/OS user program is not currently executing- Since:
- 1.0.0
- See Also:
isUserProgramExecuting()
,getInputStream()
-
-