This project is read-only.

DVD Library Example

The following example demonstrates how Jetfire can be used to create a DVD library using the 'state' first class construct. There is just one Jetfire workflow or class, called 'DVD' required for the solution. DVDs are added to the library by instantiating (new) the DVD workflow class. Individual DVDs can be borrowed and returned using the 'Borrow' and 'Return' methods. The status of each individual DVD is determined by the state, 'CheckedIn' or 'Borrowed'.

The DVD workflow objects are automatically stored in the Jetfire Server Nexus. Any changes to the workflow objects are also automatically saved. Exactly where the objects (and workflow classes) are stored is determined by the Jetfire Nexus Server storage module. The default module stores nexus objects (and classes) in files.

When a DVD workflow is in the 'CheckedIn' state only the 'Borrow' command is public. When the DVD is in the 'Borrowed' state the 'Borrow' command is private. It is the responsibility of the application software to present these commands to the user.

// This code can be selected, copied (cntrl c) and pasted (cntrl v) into the Jetfire dashboard.
//  This is Jetfire script code.  Yes it does look a lot like C#.
namespace DVDLib
   // This workflow demonstrates using the 'states' modifier for methods.
   workflow DVD
        // This is a state name CheckedIn- it looks like a constructor
        // Instances of this workflow class with be in one of the defined states.
              // place code here to be executed with the workflow enters the "CheckedIn" state.
        //  constructor - this is not a state.  
        //  It is a constructor because its name ('DVD') is the same as the workflow name.
        public DVD()
             enterstate CheckedIn();
        // This is a method.  
        // The 'Borrow' method is only public when this workflow state is 'Borrowed'.
        // When this workflow is not in the 'Borrowed'  state the 'Borrow' method is private.
        public void Borrow()
             enterstate Borrowed();
        public void Return()
             enterstate CheckedIn();
        string title = "no title";
        // gets and sets the 'Title' of this DVD instance.
        public string Title{
            get{return this.title;}
            set{this.title = value;}

Enhancing the DVD Workflow Class

In the example only the 'Title' of the DVD is stored. Naturally this could be easily extended to include other attributes such as Genre, Actors, description, etc.

Also the number of states could be extended to include states such as a 'Setup' state, that would require information about the DVD to be entered, 'Lost' state (indicates that the DVD can not be located) or 'BorrowedOverdue'.

Naturally there are a lot of enhancements that can be made to the DVD workflow. What is interesting is that you can start with a simple workflow class, create objects, then enhance the workflow class and upgrade your existing objects to use the enhanced workflow. To acomplish this Jetfire automatically includes versioning of all workflow classes.

Last edited Mar 23, 2008 at 1:59 AM by JohnHansen, version 8


No comments yet.