SOURCECODE

How to... incorporate a SaleProcess


Description:
SalesProcesses are the implementation of a deterministic finite automat. It shall be deemed to be a vectored graph with nodes called Gates and edges called Transitions. Make sure that user interaction only takes place in Gates while Transitions should be rather short without any user interaction. The reason is that a Process could only be suspended at a Gate and so the Shop is only able to persistify the Process at a Gate.
Often the display of a Gate is to be influenced by the user interaction before. In this case, Gates should be prepared with a Transition leading to this Gate.
(See also: HowTo..define a Gate, HowTo..define a UIGate, HowTo..define a Transition )
SaleProcesses could be startet in the Shop itself, but in most cases Processes take place in a SalesPointFrame and are startet from the SalesPoint.

ToDo's:
  1. Incorporate a subclass of SaleProcess.
    (If you need a tiny Process you donīt need a subclass. Implement the SaleProcess in the doAction(SaleProcess p, SalesPoint sp) method of the sale.Action class.)
  2. Add constructor (it is usefull to set the Processes name equal to itīs class name).
  3. Implement protected void setupMachine() to prepare the Gates and Transitions.
  4. Implement protected Gate getInitialGate() to invoke setupMachine() and to set the starting Gate of the Process.
  5. Implement public Gate getLogGate() to define logging
    or
  6. Implement public void log(log.Loggable la) to define logging
    otherwise Process will cause an exception when quitted.


Uses:
SaleProcess  Gate  UIGate  Transition  GateChangeTransition  



SourceCode

// mainly imports
   import sale.SaleProcess;
   import sale.Gate;

 1
// Main Class
   public class RentProcess extends SaleProcess
   {

    2
   // Constructor
      public RentProcess()
      {
         super("RentProcess");
      }

    3
   // Main Method
      protected void setupMachine()
      {

         // Code to prepare the Gates and Transitions
         // ...

      }

    4
   // Method to set InitialGate and to setup the Process
      protected Gate getInitialGate()
      {
         setupMachine();

         return startGate;
      }

    5
   // Method has to return StopGate in order to prevent logging
      public Gate getLogGate()
      {
         return getStopGate();
      }

    6
   // Method will have to be overwritten, if getLogGate doesnīt return StopGate
   // Otherwise applikation will cause exception
      public void log(log.Loggable la)
      throws log.LogNoOutputStreamException,java.io.IOException
      {
      }
   }