public abstract class JobAdapter extends java.rmi.server.UnicastRemoteObject implements Job
Constructor and Description |
---|
JobAdapter(PositionInformation positionInformation)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addJobListener(JobListener listener)
Adds a listener which should e.g.
|
void |
addMessageListener(MessageListener writer)
Adds a message listener to which (non-error) status information is send.
|
protected void |
assertRunning()
Convenient method to throw an exception if a parameter of a job should be changed, but the job is currently executed.
|
void |
executeJob(ExecutionInformation executionInformation,
Microscope microscope,
MeasurementContext measurementContext)
The standard implementation of this function automatically takes care for evaluation counting and the notification of listeners.
|
abstract java.lang.String |
getDefaultName()
Should return a default name for the job type which gets returned by getJobName() if no job name was set explicitly by setJobName.
|
java.lang.String |
getName()
Returns a name of the component meant for human interpretation.
|
PositionInformation |
getPositionInformation()
Returns the component's position information, e.g.
|
java.util.UUID |
getUUID()
Returns a unique ID of the component.
|
void |
initializeJob(Microscope microscope,
MeasurementContext measurementContext)
When overwriting this function, the base implementation should be called at the beginning, i.e.
|
boolean |
isRunning()
Returns true if the measurement the job belongs to is currently executed.
|
void |
removeJobListener(JobListener listener)
Removes a previously added listener.
|
void |
removeMessageListener(MessageListener writer)
Removes a previously added listener.
|
abstract void |
runJob(ExecutionInformation executionInformation,
Microscope microscope,
MeasurementContext measurementContext)
Convenient function which gets called by executeJob().
|
protected void |
sendErrorMessage(java.lang.String message,
java.lang.Throwable error) |
protected void |
sendMessage(java.lang.String message)
Sends the given message to all output writers.
|
void |
setName(java.lang.String jobName)
Sets the name of the component meant for human interpretation.
|
void |
uninitializeJob(Microscope microscope,
MeasurementContext measurementContext)
When overwriting this function, the base implementation should be called at the beginning, i.e.
|
clone, exportObject, exportObject, exportObject, unexportObject
public JobAdapter(PositionInformation positionInformation) throws java.rmi.RemoteException
positionInformation
- The logical position where this job is executed. Must not be null.java.rmi.RemoteException
protected void assertRunning() throws MeasurementRunningException
JobRunningException
MeasurementRunningException
public boolean isRunning()
public void executeJob(ExecutionInformation executionInformation, Microscope microscope, MeasurementContext measurementContext) throws JobException, java.lang.InterruptedException, java.rmi.RemoteException
executeJob
in interface Job
executionInformation
- Information about how many times the job has been executed, and if it is executed in a loop.microscope
- Interface to control and get information of the microscope.measurementContext
- the context of the measurement, allowing to transfer data between measurement components and similar.JobException
java.lang.InterruptedException
java.rmi.RemoteException
public abstract void runJob(ExecutionInformation executionInformation, Microscope microscope, MeasurementContext measurementContext) throws JobException, java.lang.InterruptedException, java.rmi.RemoteException
executionInformation
- Information about the number of times, and the loops, in which this job is executed.microscope
- The microscope on which this job should be executed.measurementContext
- the context of the measurement, allowing to transfer data between measurement components and similar.JobException
java.lang.InterruptedException
java.rmi.RemoteException
public PositionInformation getPositionInformation()
Component
getPositionInformation
in interface Component
public void addJobListener(JobListener listener) throws java.rmi.RemoteException
Job
addJobListener
in interface Job
listener
- The listener to add.java.rmi.RemoteException
public void removeJobListener(JobListener listener) throws java.rmi.RemoteException
Job
removeJobListener
in interface Job
listener
- The listener to be removed.java.rmi.RemoteException
public void addMessageListener(MessageListener writer)
Component
addMessageListener
in interface Component
writer
- Listener to which output should be written.public void removeMessageListener(MessageListener writer)
Component
removeMessageListener
in interface Component
writer
- Listener which should be removed.protected void sendMessage(java.lang.String message)
message
- Message to sendjava.rmi.RemoteException
protected void sendErrorMessage(java.lang.String message, java.lang.Throwable error)
public void initializeJob(Microscope microscope, MeasurementContext measurementContext) throws JobException, java.lang.InterruptedException, java.rmi.RemoteException
initializeJob
in interface Job
microscope
- Interface to control and get information of the microscope.measurementContext
- the context of the measurement, allowing to transfer data between measurement components and similar.JobException
java.lang.InterruptedException
java.rmi.RemoteException
public void uninitializeJob(Microscope microscope, MeasurementContext measurementContext) throws JobException, java.lang.InterruptedException, java.rmi.RemoteException
uninitializeJob
in interface Job
microscope
- Interface to control and get information of the microscope.measurementContext
- the context of the measurement, allowing to transfer data between measurement components and similar.JobException
java.lang.InterruptedException
java.rmi.RemoteException
public java.lang.String getName() throws java.rmi.RemoteException
Component
public void setName(java.lang.String jobName) throws java.rmi.RemoteException
Component
public abstract java.lang.String getDefaultName() throws java.rmi.RemoteException
java.rmi.RemoteException
public java.util.UUID getUUID() throws java.rmi.RemoteException
Component
UUID.equals(Object)
and UUID.randomUUID()
.