Posts

Showing posts from November, 2013

Self Monitoring Processor Design for a State Machine Implementation

Self Monitoring Processor Design for a FSM

Using the Runnable and Callable interface as well as the Java 6 ThreadPool classes to create a class design that not only executes a task, but can monitor the execution progress periodically Here is how the interface looks like. Note that each processor has an associated ‘State’ and each state has a status - like ex scheduled, started, awaiting_async, success , fail ,timeout etc. This is because the IProcessor class is also used to implement a state machine.I won't be going through this part in more detail here.
public interface IProcessor extends Runnable, Callable { ProcessingStatus getCurrentStatus(); ProcessingState getCurrentState(); ProcessingStatus execute(); Future getTask(); void setScheduledFutureHandle(ScheduledFuture handle); Now we define an Abstract class that does the basic work
public abstract class Processor implements IProcessor, Comparable { @Override //Method which does the actual work public P…