|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.as400.access.CommandCall
The CommandCall class represents an iSeries server command object. This class allows the user to call an iSeries server CL command. Results of the command are returned in a message list.
The following example demonstrates the use of CommandCall:
// Work with commands on server named "Hal." AS400 system = new AS400("Hal"); CommandCall command = new CommandCall(system); try { // Run the command "CRTLIB FRED." if (command.run("CRTLIB FRED") != true) { // Note that there was an error. System.out.println("Command failed!"); } // Show the messages (returned whether or not there was an error.) AS400Message[] messagelist = command.getMessageList(); for (int i = 0; i < messagelist.length; ++i) { // Show each message. System.out.println(messagelist[i].getText()); } } catch (Exception e) { System.out.println("Command " + command.getCommand() + " issued an exception!"); e.printStackTrace(); } // Done with the server. system.disconnectService(AS400.COMMAND);
NOTE: When getting the message list from commands, users no longer have to create a MessageFile to obtain the message help text. The load() method can be used to retrieve additional message information. Then the getHelp() method can be called directly on the AS400Message object returned from getMessageList(). Here is an example:
if (command.run("myCmd") != true) { // Show messages. AS400Message[] messageList = command.getMessageList(); for (int i = 0; i < messageList.length; ++i) { // Show each message. System.out.println(messageList[i].getText()); // Load additional message information. messageList[i].load(); //Show help text. System.out.println(messageList[i].getHelp()); } }
Constructor Summary | |
CommandCall()
Constructs a CommandCall object. |
|
CommandCall(AS400 system)
Constructs a CommandCall object. |
|
CommandCall(AS400 system,
java.lang.String command)
Constructs a CommandCall object. |
Method Summary | |
void |
addActionCompletedListener(ActionCompletedListener listener)
Adds an ActionCompletedListener. |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener. |
void |
addVetoableChangeListener(java.beans.VetoableChangeListener listener)
Adds a VetoableChangeListener. |
java.lang.String |
getCommand()
Returns the command to run. |
RJob |
getJob()
Returns an RJob object which represents the server job in which the command will be run. |
AS400Message[] |
getMessageList()
Returns the list of messages returned from running the command. |
AS400Message |
getMessageList(int index)
Returns a message returned from running the command. |
Job |
getServerJob()
Returns a Job object which represents the server job in which the command will be run. |
AS400 |
getSystem()
Returns the server on which the command is to be run. |
java.lang.Thread |
getSystemThread()
Returns the thread on which the command would be run, if it were to be called on-thread. |
boolean |
isStayOnThread()
Indicates whether or not the command will actually get run on the current thread. |
boolean |
isThreadSafe()
Indicates whether or not the command will be assumed thread-safe, according to the settings specified by setThreadSafe() or the com.ibm.as400.access.CommandCall.threadSafe property. |
void |
removeActionCompletedListener(ActionCompletedListener listener)
Removes the ActionCompletedListener. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes the PropertyChangeListener. |
void |
removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
Removes the VetoableChangeListener. |
boolean |
run()
Runs the command on the server. |
boolean |
run(byte[] command)
Runs the command on the server. |
boolean |
run(java.lang.String command)
Sets the command and runs it on the server. |
void |
setCommand(java.lang.String command)
Sets the command to run. |
void |
setSystem(AS400 system)
Sets the server to run the command. |
void |
setThreadSafe(boolean threadSafe)
Specifies whether or not the command should be assumed thread-safe. |
java.lang.String |
toString()
Returns the string representation of this command call object. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public CommandCall()
public CommandCall(AS400 system)
system
- The server on which to run the command.public CommandCall(AS400 system, java.lang.String command)
system
- The server on which to run the command.command
- The command to run on the server. If the command is not library qualified, the library list will be used to find the command.Method Detail |
public void addActionCompletedListener(ActionCompletedListener listener)
listener
- The ActionCompletedListener.public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- The PropertyChangeListener.public void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
listener
- The VetoableChangeListener.public java.lang.String getCommand()
public RJob getJob() throws AS400SecurityException, ErrorCompletingRequestException, java.io.IOException, java.lang.InterruptedException
AS400.disconnectService()
or AS400.disconnectAllServices()
.
Note: This method is not supported in the Toolbox proxy environment.
AS400SecurityException
- If a security or authority error occurs.ErrorCompletingRequestException
- If an error occurs before the request is completed.java.io.IOException
- If an error occurs while communicating with the server.java.lang.InterruptedException
- If this thread is interrupted.getServerJob()
public AS400Message[] getMessageList()
public AS400Message getMessageList(int index)
index
- The index into the list of messages returned by the command. It must be greater than or equal to zero and less than the number of messages in the list.public Job getServerJob() throws AS400SecurityException, ErrorCompletingRequestException, java.io.IOException, java.lang.InterruptedException
AS400.disconnectService()
or AS400.disconnectAllServices()
.
Note: This method is not supported in the Toolbox proxy environment.
AS400SecurityException
- If a security or authority error occurs.ErrorCompletingRequestException
- If an error occurs before the request is completed.java.io.IOException
- If an error occurs while communicating with the server.java.lang.InterruptedException
- If this thread is interrupted.getJob()
public AS400 getSystem()
public java.lang.Thread getSystemThread() throws AS400SecurityException, java.io.IOException
AS400SecurityException
- If a security or authority error occurs.java.io.IOException
- If an error occurs while communicating with the server.public boolean isStayOnThread() throws AS400SecurityException, ErrorCompletingRequestException, java.io.IOException, java.lang.InterruptedException
AS400SecurityException
- If a security or authority error occurs.ErrorCompletingRequestException
- If an error occurs before the request is completed.java.io.IOException
- If an error occurs while communicating with the server.java.lang.InterruptedException
- If this thread is interrupted.public boolean isThreadSafe() throws AS400SecurityException, ErrorCompletingRequestException, java.io.IOException, java.lang.InterruptedException
setThreadSafe()
or the com.ibm.as400.access.CommandCall.threadSafe
property.
AS400SecurityException
- If a security or authority error occurs.ErrorCompletingRequestException
- If an error occurs before the request is completed.java.io.IOException
- If an error occurs while communicating with the server.java.lang.InterruptedException
- If this thread is interrupted.public void removeActionCompletedListener(ActionCompletedListener listener)
listener
- The ActionCompletedListener.public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- The PropertyChangeListener.public void removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
listener
- The VetoableChangeListener.public boolean run() throws AS400SecurityException, ErrorCompletingRequestException, java.io.IOException, java.lang.InterruptedException
AS400SecurityException
- If a security or authority error occurs.ErrorCompletingRequestException
- If an error occurs before the request is completed.java.io.IOException
- If an error occurs while communicating with the server.java.lang.InterruptedException
- If this thread is interrupted.public boolean run(java.lang.String command) throws AS400SecurityException, ErrorCompletingRequestException, java.io.IOException, java.lang.InterruptedException, java.beans.PropertyVetoException
command
- The command to run. If the command is not library qualified, the library list will be used to find the command.AS400SecurityException
- If a security or authority error occurs.ErrorCompletingRequestException
- If an error occurs before the request is completed.java.io.IOException
- If an error occurs while communicating with the server.java.lang.InterruptedException
- If this thread is interrupted.java.beans.PropertyVetoException
- If the change is vetoed.public boolean run(byte[] command) throws AS400SecurityException, ErrorCompletingRequestException, java.io.IOException, java.lang.InterruptedException, java.beans.PropertyVetoException
Unlike the run method that takes a string, this method will not look up the thread safety of the command. If this command is to be run on-thread when running on the server's JVM, setThreadSafe(true) must be called by the application.
command
- The command to run.AS400SecurityException
- If a security or authority error occurs.ErrorCompletingRequestException
- If an error occurs before the request is completed.java.io.IOException
- If an error occurs while communicating with the server.java.lang.InterruptedException
- If this thread is interrupted.java.beans.PropertyVetoException
- If the change is vetoed.public void setCommand(java.lang.String command) throws java.beans.PropertyVetoException
command
- The command to run on the server. If the command is not library qualified, the library list will be used to find the command.java.beans.PropertyVetoException
- If the change is vetoed.public void setSystem(AS400 system) throws java.beans.PropertyVetoException
system
- The server on which to run the command.java.beans.PropertyVetoException
- If the change is vetoed.public void setThreadSafe(boolean threadSafe)
threadSafe
- true if the command should be assumed to be thread-safe; false otherwise.public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |