com.ibm.as400.access
Class JobLog

java.lang.Object
  |
  +--com.ibm.as400.access.JobLog
All Implemented Interfaces:
java.io.Serializable

public class JobLog
extends java.lang.Object
implements java.io.Serializable

The JobLog class represents an OS/400 job log. This is used to get a list of messages in a job log or to write messages to a job log.

QueuedMessage objects have many attributes. Only some of theses attribute values are set, depending on how a QueuedMessage object is created. The following is a list of attributes whose values are set on QueuedMessage objects returned in a list of job log messages:

See Also:
QueuedMessage, RJobLog, Serialized Form

Constructor Summary
JobLog()
          Constructs a JobLog object.
JobLog(AS400 system)
          Constructs a JobLog object.
JobLog(AS400 system, java.lang.String name, java.lang.String user, java.lang.String number)
          Constructs a JobLog object.
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Adds a PropertyChangeListener.
 void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
          Adds a VetoableChangeListener.
 void close()
          Closes the message list on the system.
 int getLength()
          Returns the number of messages in the job log.
 boolean getListDirection()
          Returns the list direction.
 java.util.Enumeration getMessages()
          Returns the list of messages in the job log.
 QueuedMessage[] getMessages(int listOffset, int number)
          Returns a subset of the list of messages in the job log.
 java.lang.String getName()
          Returns the job name.
 java.lang.String getNumber()
          Returns the job number.
 byte[] getStartingMessageKey()
          Returns the starting message key.
 AS400 getSystem()
          Returns the system.
 java.lang.String getUser()
          Returns the user name.
 void load()
          Loads the list of messages on the system.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Removes a PropertyChangeListener.
 void removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
          Removes a VetoableChangeListener.
 void setListDirection(boolean direction)
          Sets the list direction.
 void setName(java.lang.String name)
          Sets the job name.
 void setNumber(java.lang.String number)
          Sets the job number.
 void setStartingMessageKey(byte[] key)
          Sets the message key used to begin searching for messages to list from the corresponding entry in the message queue.
 void setSystem(AS400 system)
          Sets the system.
 void setUser(java.lang.String user)
          Sets the user name.
static void writeMessage(AS400 system, java.lang.String messageID, int messageType)
          Writes a program message to the job log for the job in which the program is running.
static void writeMessage(AS400 system, java.lang.String messageID, int messageType, byte[] substitutionData)
          Writes a program message to the job log for the job in which the program is running.
static void writeMessage(AS400 system, java.lang.String messageID, int messageType, java.lang.String messageFile)
          Writes a program message to the job log for the job in which the program is running.
static void writeMessage(AS400 system, java.lang.String messageID, int messageType, java.lang.String messageFile, byte[] substitutionData)
          Writes a program message to the job log for the job in which the program is running.
static void writeMessage(AS400 system, java.lang.String messageID, int messageType, java.lang.String messageFile, byte[] substitutionData, boolean onThread)
          Writes a program message to the job log for the job in which the program is running.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JobLog

public JobLog()
Constructs a JobLog object.


JobLog

public JobLog(AS400 system)
Constructs a JobLog object.

Parameters:
system - The system.

JobLog

public JobLog(AS400 system,
              java.lang.String name,
              java.lang.String user,
              java.lang.String number)
Constructs a JobLog object.

Parameters:
system - The system.
name - The job name.
user - The user name.
number - The job number.
Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener. The specified PropertyChangeListener's propertyChange() method will be called each time the value of any bound property is changed.

Parameters:
listener - The listener.
See Also:
removePropertyChangeListener(java.beans.PropertyChangeListener)

addVetoableChangeListener

public void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
Adds a VetoableChangeListener. The specified VetoableChangeListener's vetoableChange() method will be called each time the value of any constrained property is changed.

Parameters:
listener - The listener.
See Also:
removeVetoableChangeListener(java.beans.VetoableChangeListener)

close

public void close()
           throws AS400Exception,
                  AS400SecurityException,
                  ErrorCompletingRequestException,
                  java.lang.InterruptedException,
                  java.io.IOException,
                  ObjectDoesNotExistException
Closes the message list on the system. This releases any system resources previously in use by this message list.

Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
java.lang.InterruptedException - If this thread is interrupted.
java.io.IOException - If an error occurs while communicating with the system.
ObjectDoesNotExistException - If the object does not exist on the system.

getLength

public int getLength()
Returns the number of messages in the job log. This method implicitly calls load().

Returns:
The number of messages, or 0 if no list was retrieved.
See Also:
load()

getListDirection

public boolean getListDirection()
Returns the list direction.

Returns:
true if the messages will be sorted oldest to newest; false if they will be sorted newest to oldest. The default is true.

getMessages

public java.util.Enumeration getMessages()
                                  throws AS400Exception,
                                         AS400SecurityException,
                                         ErrorCompletingRequestException,
                                         java.lang.InterruptedException,
                                         java.io.IOException,
                                         ObjectDoesNotExistException
Returns the list of messages in the job log. The messages are listed from oldest to newest.

Returns:
An Enumeration of QueuedMessage objects.
Throws:
AS400Exception - If the AS/400 system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
ErrorCompletingRequestException - If an error occurs before the request is completed.
java.lang.InterruptedException - If this thread is interrupted.
java.io.IOException - If an error occurs while communicating with the AS/400.
ObjectDoesNotExistException - If the AS/400 object does not exist.
ServerStartupException - If the AS/400 server cannot be started.
java.net.UnknownHostException - If the AS/400 system cannot be located.

getMessages

public QueuedMessage[] getMessages(int listOffset,
                                   int number)
                            throws AS400Exception,
                                   AS400SecurityException,
                                   ErrorCompletingRequestException,
                                   java.lang.InterruptedException,
                                   java.io.IOException,
                                   ObjectDoesNotExistException
Returns a subset of the list of messages in the job log. This method allows the user to retrieve the message list from the server in pieces. If a call to load() is made (either implicitly or explicitly), then the messages at a given offset will change, so a subsequent call to getMessages() with the same listOffset and number will most likely not return the same QueuedMessages as the previous call.

Parameters:
listOffset - The offset into the list of messages. This value must be greater than 0 and less than the list length, or specify -1 to retrieve all of the messages.
number - The number of messages to retrieve out of the list, starting at the specified listOffset. This value must be greater than or equal to 0 and less than or equal to the list length. If the listOffset is -1, this parameter is ignored.
Returns:
The array of retrieved QueuedMessage objects. The length of this array may not necessarily be equal to number, depending upon the size of the list on the server, and the specified listOffset.
Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
java.lang.InterruptedException - If this thread is interrupted.
java.io.IOException - If an error occurs while communicating with the system.
ObjectDoesNotExistException - If the object does not exist on the system.
See Also:
Job

getName

public java.lang.String getName()
Returns the job name.

Returns:
The job name, or "*" if none has been set.
See Also:
setName(java.lang.String)

getNumber

public java.lang.String getNumber()
Returns the job number.

Returns:
The job number, or "" if none has been set.
See Also:
setNumber(java.lang.String)

getStartingMessageKey

public byte[] getStartingMessageKey()
Returns the starting message key.

Returns:
The key.
See Also:
setStartingMessageKey(byte[])

getSystem

public AS400 getSystem()
Returns the system.

Returns:
The system.
See Also:
setSystem(com.ibm.as400.access.AS400)

getUser

public java.lang.String getUser()
Returns the user name.

Returns:
The user name, or "" if none has been set.
See Also:
setUser(java.lang.String)

load

public void load()
          throws AS400Exception,
                 AS400SecurityException,
                 ErrorCompletingRequestException,
                 java.lang.InterruptedException,
                 java.io.IOException,
                 ObjectDoesNotExistException
Loads the list of messages on the system. This method informs the system to build a list of messages. This method blocks until the system returns the total number of messages it has compiled. A subsequent call to getMessages() will retrieve the actual message information and attributes for each message in the list from the system.

This method updates the list length.

Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
ErrorCompletingRequestException - If an error occurs before the request is completed.
java.lang.InterruptedException - If this thread is interrupted.
java.io.IOException - If an error occurs while communicating with the system.
ObjectDoesNotExistException - If the object does not exist on the system.
ServerStartupException - If the server cannot be started.
java.net.UnknownHostException - If the system cannot be located.
See Also:
getLength()

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a PropertyChangeListener.

Parameters:
listener - The listener.
See Also:
addPropertyChangeListener(java.beans.PropertyChangeListener)

removeVetoableChangeListener

public void removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
Removes a VetoableChangeListener.

Parameters:
listener - The listener.
See Also:
addVetoableChangeListener(java.beans.VetoableChangeListener)

setListDirection

public void setListDirection(boolean direction)
Sets the list direction.

Parameters:
direction - true to sort the messages oldest to newest; false to sort them newest to oldest. The default is true.

setName

public void setName(java.lang.String name)
             throws java.beans.PropertyVetoException
Sets the job name. This cannot be changed if the object has established a connection to the server.

Parameters:
name - The job name.
Throws:
java.beans.PropertyVetoException - If the change is vetoed.

setNumber

public void setNumber(java.lang.String number)
               throws java.beans.PropertyVetoException
Sets the job number. This cannot be changed if the object has established a connection to the server.

Parameters:
number - The job number.
Throws:
java.beans.PropertyVetoException - If the change is vetoed.

setStartingMessageKey

public void setStartingMessageKey(byte[] key)
Sets the message key used to begin searching for messages to list from the corresponding entry in the message queue. Any valid message key will work, including MessageQueue.OLDEST and MessageQueue#NEWEST.

Parameters:
key - The key. Specify null to set it back to the default.

setSystem

public void setSystem(AS400 system)
               throws java.beans.PropertyVetoException
Sets the system. This cannot be changed if the object has established a connection to the server.

Parameters:
system - The system.
Throws:
java.beans.PropertyVetoException - If the property change is vetoed.

setUser

public void setUser(java.lang.String user)
             throws java.beans.PropertyVetoException
Sets the user name. This cannot be changed if the object has established a connection to the server.

Parameters:
user - The user name.
Throws:
java.beans.PropertyVetoException - If the change is vetoed.

writeMessage

public static void writeMessage(AS400 system,
                                java.lang.String messageID,
                                int messageType)
                         throws AS400SecurityException,
                                ErrorCompletingRequestException,
                                java.lang.InterruptedException,
                                java.io.IOException,
                                ObjectDoesNotExistException,
                                AS400Exception
Writes a program message to the job log for the job in which the program is running.
Note: The program runs in the job of the Remote Command Host Server (QZRCSRVS) unless it is invoked "on-thread" on the iSeries server.

Parameters:
system - The system. If the system specifies localhost, the message is written to the job log of the process from which this method is called. Otherwise the message is written to the QZRCSRVS job.
messageID - The message ID. The message must be in the default message file /QSYS.LIB/QCPFMSG.MSGF.
messageType - The message type. Possible values are:
  • AS400Message.COMPLETION
  • AS400Message.DIAGNOSTIC
  • AS400Message.INFORMATIONAL
  • AS400Message.ESCAPE
The message type must be AS400Message.INFORMATIONAL for an immediate message.
Throws:
AS400Exception - If the AS/400 system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
ErrorCompletingRequestException - If an error occurs before the request is completed.
java.lang.InterruptedException - If this thread is interrupted.
java.io.IOException - If an error occurs while communicating with the AS/400.
ObjectDoesNotExistException - If the AS/400 object does not exist.
ServerStartupException - If the AS/400 server cannot be started.
java.net.UnknownHostException - If the AS/400 system cannot be located.
See Also:
ProgramCall.isStayOnThread()

writeMessage

public static void writeMessage(AS400 system,
                                java.lang.String messageID,
                                int messageType,
                                byte[] substitutionData)
                         throws AS400SecurityException,
                                ErrorCompletingRequestException,
                                java.lang.InterruptedException,
                                java.io.IOException,
                                ObjectDoesNotExistException,
                                AS400Exception
Writes a program message to the job log for the job in which the program is running.
Note: The program runs in the job of the Remote Command Host Server (QZRCSRVS) unless it is invoked "on-thread" on the iSeries server.

Parameters:
system - The system. If the system specifies localhost, the message is written to the job log of the process from which this method is called. Otherwise the message is written to the QZRCSRVS job.
messageID - The message ID. The message must be in the default message file /QSYS.LIB/QCPFMSG.MSGF.
messageType - The message type. Possible values are:
  • AS400Message.COMPLETION
  • AS400Message.DIAGNOSTIC
  • AS400Message.INFORMATIONAL
  • AS400Message.ESCAPE
The message type must be AS400Message.INFORMATIONAL for an immediate message.
substitutionData - The substitution data. The substitution data can be from 0-32767 bytes for a conventional message and from 1-6000 bytes for an immediate message.
Throws:
AS400Exception - If the AS/400 system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
ErrorCompletingRequestException - If an error occurs before the request is completed.
java.lang.InterruptedException - If this thread is interrupted.
java.io.IOException - If an error occurs while communicating with the AS/400.
ObjectDoesNotExistException - If the AS/400 object does not exist.
ServerStartupException - If the AS/400 server cannot be started.
java.net.UnknownHostException - If the AS/400 system cannot be located.
See Also:
ProgramCall.isStayOnThread()

writeMessage

public static void writeMessage(AS400 system,
                                java.lang.String messageID,
                                int messageType,
                                java.lang.String messageFile)
                         throws AS400SecurityException,
                                ErrorCompletingRequestException,
                                java.lang.InterruptedException,
                                java.io.IOException,
                                ObjectDoesNotExistException,
                                AS400Exception
Writes a program message to the job log for the job in which the program is running.
Note: The program runs in the job of the Remote Command Host Server (QZRCSRVS) unless it is invoked "on-thread" on the iSeries server.

Parameters:
system - The system. If the system specifies localhost, the message is written to the job log of the process from which this method is called. Otherwise the message is written to the QZRCSRVS job.
messageID - The message ID.
messageType - The message type. Possible values are:
  • AS400Message.COMPLETION
  • AS400Message.DIAGNOSTIC
  • AS400Message.INFORMATIONAL
  • AS400Message.ESCAPE
The message type must be AS400Message.INFORMATIONAL for an immediate message.
messageFile - The integrated file system path name of the message file.
Throws:
AS400Exception - If the AS/400 system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
ErrorCompletingRequestException - If an error occurs before the request is completed.
java.lang.InterruptedException - If this thread is interrupted.
java.io.IOException - If an error occurs while communicating with the AS/400.
ObjectDoesNotExistException - If the AS/400 object does not exist.
ServerStartupException - If the AS/400 server cannot be started.
java.net.UnknownHostException - If the AS/400 system cannot be located.
See Also:
ProgramCall.isStayOnThread()

writeMessage

public static void writeMessage(AS400 system,
                                java.lang.String messageID,
                                int messageType,
                                java.lang.String messageFile,
                                byte[] substitutionData)
                         throws AS400SecurityException,
                                ErrorCompletingRequestException,
                                java.lang.InterruptedException,
                                java.io.IOException,
                                ObjectDoesNotExistException,
                                AS400Exception
Writes a program message to the job log for the job in which the program is running.
Note: The program runs in the job of the Remote Command Host Server (QZRCSRVS) unless it is invoked "on-thread" on the iSeries server.

Parameters:
system - The system. If the system specifies localhost, the message is written to the job log of the process from which this method is called. Otherwise the message is written to the QZRCSRVS job.
messageID - The message ID.
messageType - The message type. Possible values are:
  • AS400Message.COMPLETION
  • AS400Message.DIAGNOSTIC
  • AS400Message.INFORMATIONAL
  • AS400Message.ESCAPE
The message type must be AS400Message.INFORMATIONAL for an immediate message.
messageFile - The integrated file system path name of the message file.
substitutionData - The substitution data. The substitution data can be from 0-32767 bytes for a conventional message and from 1-6000 bytes for an immediate message.
Throws:
AS400Exception - If the AS/400 system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
ErrorCompletingRequestException - If an error occurs before the request is completed.
java.lang.InterruptedException - If this thread is interrupted.
java.io.IOException - If an error occurs while communicating with the AS/400.
ObjectDoesNotExistException - If the AS/400 object does not exist.
ServerStartupException - If the AS/400 server cannot be started.
java.net.UnknownHostException - If the AS/400 system cannot be located.
See Also:
ProgramCall.isStayOnThread()

writeMessage

public static void writeMessage(AS400 system,
                                java.lang.String messageID,
                                int messageType,
                                java.lang.String messageFile,
                                byte[] substitutionData,
                                boolean onThread)
                         throws AS400SecurityException,
                                ErrorCompletingRequestException,
                                java.lang.InterruptedException,
                                java.io.IOException,
                                ObjectDoesNotExistException,
                                AS400Exception
Writes a program message to the job log for the job in which the program is running. The message is sent to the Remote Command Host Server (QZRCSRVS) unless true is specified for the onThread parameter and is invoked while running on the iSeries server.

Parameters:
system - The system. The system cannot be null.
messageID - The message ID. The message ID cannot be null.
messageType - The message type. Possible values are:
  • AS400Message.COMPLETION
  • AS400Message.DIAGNOSTIC
  • AS400Message.INFORMATIONAL
  • AS400Message.ESCAPE
The message type must be AS400Message.INFORMATIONAL for an immediate message.
messageFile - The integrated file system path name of the message file. If null is specified, the message file used is /QSYS.LIB/QCPFMSG.MSGF.
substitutionData - The substitution data. The substitution data can be from 0-32767 bytes for a conventional message and from 1-6000 bytes for an immediate message. If null is specified, no substitution data is used.
onThread - Whether or not to stay on thread when calling the API to write the message to the job log. true to write the message to the current job's job log, false to write the message to the Remote Command Host Server job's job log. Note that this parameter is meaningless unless this Java program is running on the iSeries server and the system object is using native optimizations.
Throws:
AS400Exception - If the AS/400 system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
ErrorCompletingRequestException - If an error occurs before the request is completed.
java.lang.InterruptedException - If this thread is interrupted.
java.io.IOException - If an error occurs while communicating with the AS/400.
ObjectDoesNotExistException - If the AS/400 object does not exist.
ServerStartupException - If the AS/400 server cannot be started.
java.net.UnknownHostException - If the AS/400 system cannot be located.
See Also:
ProgramCall.isStayOnThread()