com.norconex.jef.exec
Class SystemCommandJob

java.lang.Object
  extended by com.norconex.jef.exec.SystemCommandJob
All Implemented Interfaces:
IJob

public class SystemCommandJob
extends Object
implements IJob

JEF job for executing an arbitrary number of commands. The job progress is relative to the number of commands to be processed. This is ideal for submitting a batch of small commands where execution time is not long enough to track individual command progresses. For long-running commands, you may want to create a custom job where you can keep track of the command progress and translate that somehow into a job progress (whenever possible).

Since:
1.1
Author:
Pascal Essiembre

Constructor Summary
SystemCommandJob(String id, String desc, String command)
          Creates a JEF job for executing a system command.
SystemCommandJob(String id, String desc, String[] commands)
          Creates a JEF job for executing system commands.
SystemCommandJob(String id, String desc, SystemCommand command)
          Creates a JEF job for executing a system command.
SystemCommandJob(String id, String desc, SystemCommand[] commands)
          Creates a JEF job for executing system commands.
 
Method Summary
 IJobContext createJobContext()
          Contextual information about the job to run.
 void execute(JobProgress progress, JobSuite suite)
          Executes this job.
 String getId()
          Gets the job unique identifier.
 void stop(IJobStatus progress, JobSuite suite)
          Default implementation of this method will check if the SystemCommand it runs is currently holding to a Process process instance and destroys them.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SystemCommandJob

public SystemCommandJob(String id,
                        String desc,
                        String[] commands)
Creates a JEF job for executing system commands. This is a convenience constructor for taking multiple systems commands as string, every commands supplied are converted to SystemCommand instances internally.

Parameters:
id - job id
desc - job description
commands - array of individual commands to be executed
See Also:
SystemCommandJob(String, String, SystemCommand[])

SystemCommandJob

public SystemCommandJob(String id,
                        String desc,
                        String command)
Creates a JEF job for executing a system command. This is a convenience constructor for taking a command as a string, the command supplied is converted to a SystemCommand instance internally.

Parameters:
id - job id
desc - job description
command - commands to be executed

SystemCommandJob

public SystemCommandJob(String id,
                        String desc,
                        SystemCommand[] commands)
Creates a JEF job for executing system commands.

Parameters:
id - job id
desc - job description
commands - commands to be executed

SystemCommandJob

public SystemCommandJob(String id,
                        String desc,
                        SystemCommand command)
Creates a JEF job for executing a system command.

Parameters:
id - job id
desc - job description
command - commands to be executed
Method Detail

getId

public String getId()
Description copied from interface: IJob
Gets the job unique identifier.

Specified by:
getId in interface IJob
Returns:
job unique identifier

createJobContext

public IJobContext createJobContext()
Description copied from interface: IJob
Contextual information about the job to run. Cannot be null.

Specified by:
createJobContext in interface IJob
Returns:
job context

execute

public void execute(JobProgress progress,
                    JobSuite suite)
Description copied from interface: IJob
Executes this job. Implementors are responsible for updating execution progress on the given JobProgress.

Specified by:
execute in interface IJob
Parameters:
progress - current job progress
suite - job suite this job is part of

stop

public void stop(IJobStatus progress,
                 JobSuite suite)
Default implementation of this method will check if the SystemCommand it runs is currently holding to a Process process instance and destroys them. If no such instance is found, and even if one is found, there are no guarantees what will happen. Implementors having better ways to stop the invoked command should overwrite this method.

Specified by:
stop in interface IJob
Parameters:
progress - current job progress
suite - job suite this job is part of
Since:
2.0


Copyright © 2007-2013 Norconex Inc.. All Rights Reserved.