IBM SC34-6814-04 Server User Manual


 
by one provided in a subclass. It does not implement a writeRecord method, and
such a method must be provided by any subclass to control the output redirection
process.You could imitate this in your own class structure. The initialization of
output redirection can also be performed using a constructor, rather than the
initRedirect method.
Note: The inPS parameter contains either the JVM's original System.out
PrintStream or the JVM's original System.err PrintStream. You may log to
either of these underlying logging destinations. You must not call the close()
method on either of these PrintStreams, as they will remain closed
permanently, and will not be available for use either during the execution of
the current program, or in subsequent reuses of the same JVM.
Possible destinations for output
The CICS-supplied sample classes direct output from JVMs to a directory that is
specific to a CICS region. (The directory name is created using the applid
associated with the CICS region.) When you write your own classes, if you prefer,
you can send output from several CICS regions to the same z/OS UNIX directory or
file. For example, you might want to create a single file containing the output
associated with a particular application that runs in several different CICS regions.
Java applications executing on threads other than the initial process thread (IPT)
are not able to make CICS requests. For these applications, the output from the
JVM is intercepted by the class you have specified for USEROUTPUTCLASS, but it
cannot be redirected using CICS facilities (such as transient data queues). You can
direct output from these applications to z/OS UNIX files, as the supplied sample
classes do. For Java applications that are executing on the IPT, you can use CICS
facilities, such as transient data queues, to redirect the output.
Handling output redirection errors and internal errors
If your classes use CICS facilities to redirect output, they should include appropriate
exception handling to deal with errors in using these facilities. For example, if you
are writing to the transient data queues CSJO and CSJE, and using the
CICS-supplied definitions for these queues, the following exceptions might be
thrown by TDQ.writeData:
v IOErrorException
v LengthErrorException
v NoSpaceException
v NotOpenException
If your classes direct output to z/OS UNIX files, they should include appropriate
exception handling to deal with errors that occur when writing to z/OS UNIX. The
most common cause of these errors is a security exception.
The Java programs that will run in JVMs that name your classes on the
USEROUTPUTCLASS options should include appropriate exception handling to
deal with any exceptions that might be thrown by your classes. The CICS-supplied
sample classes handle exceptions internally, by using a Try/Catch block to catch all
throwable exceptions, and then writing one or more error messages to report the
problem. When an error is detected while redirecting an output message, these
error messages are written to System.err, making them available for redirection.
However, if an error is found while redirecting an error message, then the
messages which report this problem are written to the file indicated by the STDERR
option in the JVM profile used by the JVM that is servicing the request. Because
Chapter 22. Writing programs to customize JVMs 669