com.ibm.as400.access
Class JobLog

java.lang.Object
  extended bycom.ibm.as400.access.JobLog
All Implemented Interfaces:
Serializable

public class JobLog
extends Object
implements Serializable

Represents a job log on the server. This class 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, Serialized Form

Constructor Summary
JobLog()
          Constructs a JobLog object.
JobLog(AS400 system)
          Constructs a JobLog object.
JobLog(AS400 system, String name, String user, String number)
          Constructs a JobLog object.
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Adds a PropertyChangeListener.
 void addVetoableChangeListener(VetoableChangeListener listener)
          Adds a VetoableChangeListener.
 void close()
          Closes the message list on the server.
 int getLength()
          Returns the number of messages in the job log.
 boolean getListDirection()
          Returns the list direction.
 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.
 String getName()
          Returns the job name.
 String getNumber()
          Returns the job number.
 byte[] getStartingMessageKey()
          Returns the starting message key.
 AS400 getSystem()
          Returns the system object representing the server on which the job log exists.
 String getUser()
          Returns the job user name.
 void load()
          Loads the list of messages on the server.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes the PropertyChangeListener.
 void removeVetoableChangeListener(VetoableChangeListener listener)
          Removes the VetoableChangeListener.
 void setListDirection(boolean listDirection)
          Sets the list direction.
 void setName(String name)
          Sets the job name.
 void setNumber(String number)
          Sets the job number.
 void setStartingMessageKey(byte[] startingMessageKey)
          Sets the message key used to begin searching for messages to list from the corresponding entry in the job log.
 void setSystem(AS400 system)
          Sets the system.
 void setUser(String user)
          Sets the job user name.
static void writeMessage(AS400 system, 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, 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, String messageID, int messageType, String messageFile)
          Writes a program message to the job log for the job in which the program is running.
static void writeMessage(AS400 system, String messageID, int messageType, 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, String messageID, int messageType, 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. The system must be provided later. The job information defaults to the server job in which the program is run.


JobLog

public JobLog(AS400 system)
Constructs a JobLog object. The job information defaults to the server job in which the program is run.

Parameters:
system - The system object representing the server on which the job log exists.

JobLog

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

Parameters:
system - The system object representing the server on which the job log exists.
name - The job name.
user - The job user name.
number - The job number.
Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(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(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 AS400SecurityException,
                  ErrorCompletingRequestException,
                  InterruptedException,
                  IOException,
                  ObjectDoesNotExistException
Closes the message list on the server. This releases any system resources previously in use by this message list.

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

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 Enumeration getMessages()
                        throws AS400SecurityException,
                               ErrorCompletingRequestException,
                               InterruptedException,
                               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:
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the server.
ObjectDoesNotExistException - If the object does not exist on the server.

getMessages

public QueuedMessage[] getMessages(int listOffset,
                                   int number)
                            throws AS400SecurityException,
                                   ErrorCompletingRequestException,
                                   InterruptedException,
                                   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:
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the server.
ObjectDoesNotExistException - If the object does not exist on the server.
See Also:
QueuedMessage

getName

public String getName()
Returns the job name.

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

getNumber

public 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 object representing the server on which the job log exists.

Returns:
The system object representing the server on which the job log exists. If the system has not been set, null is returned.
See Also:
setSystem(com.ibm.as400.access.AS400)

getUser

public String getUser()
Returns the job user name.

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

load

public void load()
          throws AS400SecurityException,
                 ErrorCompletingRequestException,
                 InterruptedException,
                 IOException,
                 ObjectDoesNotExistException
Loads the list of messages on the server. This method informs the server to build a list of messages. This method blocks until the server 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 server.

This method updates the list length.

Throws:
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the server.
ObjectDoesNotExistException - If the object does not exist on the server.
See Also:
getLength()

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Removes the PropertyChangeListener. If the PropertyChangeListener is not on the list, nothing is done.

Parameters:
listener - The listener object.

removeVetoableChangeListener

public void removeVetoableChangeListener(VetoableChangeListener listener)
Removes the VetoableChangeListener. If the VetoableChangeListener is not on the list, nothing is done.

Parameters:
listener - The listener object.

setListDirection

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

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

setName

public void setName(String name)
             throws 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:
PropertyVetoException - If any of the registered listeners vetos the property change.

setNumber

public void setNumber(String number)
               throws 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:
PropertyVetoException - If any of the registered listeners vetos the property change.

setStartingMessageKey

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

Parameters:
startingMessageKey - The key. Specify null to set it back to the default, which will be OLDEST or NEWEST based on the list direction.

setSystem

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

Parameters:
system - The system object representing the server on which the job log exists.
Throws:
PropertyVetoException - If any of the registered listeners vetos the property change.

setUser

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

Parameters:
user - The job user name.
Throws:
PropertyVetoException - If any of the registered listeners vetos the property change.

writeMessage

public static void writeMessage(AS400 system,
                                String messageID,
                                int messageType)
                         throws AS400SecurityException,
                                ErrorCompletingRequestException,
                                InterruptedException,
                                IOException,
                                ObjectDoesNotExistException
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 server.

Parameters:
system - The system object representing the server on which the job log exists. 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:
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the server.
ObjectDoesNotExistException - If the object does not exist on the server.
See Also:
ProgramCall.isStayOnThread()

writeMessage

public static void writeMessage(AS400 system,
                                String messageID,
                                int messageType,
                                byte[] substitutionData)
                         throws AS400SecurityException,
                                ErrorCompletingRequestException,
                                InterruptedException,
                                IOException,
                                ObjectDoesNotExistException
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 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:
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the server.
ObjectDoesNotExistException - If the object does not exist on the server.
See Also:
ProgramCall.isStayOnThread()

writeMessage

public static void writeMessage(AS400 system,
                                String messageID,
                                int messageType,
                                String messageFile)
                         throws AS400SecurityException,
                                ErrorCompletingRequestException,
                                InterruptedException,
                                IOException,
                                ObjectDoesNotExistException
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 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:
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the server.
ObjectDoesNotExistException - If the object does not exist on the server.
See Also:
ProgramCall.isStayOnThread()

writeMessage

public static void writeMessage(AS400 system,
                                String messageID,
                                int messageType,
                                String messageFile,
                                byte[] substitutionData)
                         throws AS400SecurityException,
                                ErrorCompletingRequestException,
                                InterruptedException,
                                IOException,
                                ObjectDoesNotExistException
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 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:
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the server.
ObjectDoesNotExistException - If the object does not exist on the server.
See Also:
ProgramCall.isStayOnThread()

writeMessage

public static void writeMessage(AS400 system,
                                String messageID,
                                int messageType,
                                String messageFile,
                                byte[] substitutionData,
                                boolean onThread)
                         throws AS400SecurityException,
                                ErrorCompletingRequestException,
                                InterruptedException,
                                IOException,
                                ObjectDoesNotExistException
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 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 server and the system object is using native optimizations.
Throws:
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the server.
ObjectDoesNotExistException - If the object does not exist on the server.
See Also:
ProgramCall.isStayOnThread()