Generate or Create USP Application Objects

Recall that USP Application Objects comprise the top four layers of the USP architecture, namely the Application Coordinator, the User Interface, the Use Case Controllers and the States.


Two of the five class types that are not generated in USP are User Interface and Domain Objects. The remaining three may be generated or written by hand:

 

*  Application Coordinator

*  Use Case Controllers

*  States

 

Let’s look at some generated USP code for each of these.

 

Application Coordinator

 

Here is a UML model of the IApplicationCoordinator interface:

Here is a sample implementation of the IApplicationCoordinator interface:

final public class ApplicationCoordinator extends AApplicationController
{
   /**
    * sInstance The only instance
    * @see ISingelton interface
    */
   static private ApplicationCoordinator sInstance;
   /***********************************************************************
    *
    * getInstance - Satisfaction of the ISingelton interface idiom.
    *
    * @return The singleton instance of ApplicationCoordinator
    */
   static public ApplicationCoordinator getInstance()
   {
      if( sInstance == null )
      {
         sInstance = new ApplicationCoordinator();
      }
      return sInstance;
   }
   /**********************************************************************
    *
    * main
    *
    */
   static public void main( String[] args )
   {
      ApplicationCoordinator aMainApp = ApplicationCoordinator.getInstance();
   }
   //////////////////////// PRIVATE INTERFACE ////////////////////////
   /***************************************************************************
    *
    * init - common initialization from all the ctors
    *
    * @author Spencer Roberts
    *
    */
    private void init()
    {
       /* Add all use case controllers to the cache */
       StartupUCController
          aStartupUCController = StartupUCController.getInstance( this );
       mUseCaseControllers.put(
          StartupUCController.NAME, aStartupUCController );
       /**
        * Initialize first because the LoginUCController uses it!
        */
        ManageResourcesUCController aManageResourcesUCController
           = ManageResourcesUCController.getInstance();
        mUseCaseControllers.put(
           ManageResourcesUCController.NAME,
           aManageResourcesUCController );
        mUseCaseControllers.put(
           LoginUCController.NAME,
           LoginUCController.getInstance( this, aManageResourcesUCController )
        );
        /**
         * Try to plop up the main screen
         */
         aStartupUCController.entryPoint();
     }
    /***********************************************************************
     *
     * Private ctor - Made private to enforce ISingelton interface.
     */
     private ApplicationCoordinator()
     {
        super();
        this.init();
     }
}


We can see that the Application Coordinator hangs on to a named list of Use Case Controller instances, which it initializes in it's constructor. An Application Coordinator caches the application's Use Case Controllers. This is one possible implementation.

Use Case Controller

 

There is one Use Case Controller per Use Case. The main method all Use Case Controllers must implement (and then invoke in their ctors) is the method registerAllStateTransitions(). Here, all State objects are initialized, much in the same way the Application Coordinator controlled the lifetime of the Use Case Controllers. Here is a UML model of the IApplicationCoordinator interface:

State

 

States are implemented using the State and Command patterns, which allow them to be polymorphically invoked by Use Case Controllers.

USP guarantees that only valid states are executed along allowable state transitions. The state of the application is the sum of all the concurrent Use Case States. Reliability is enhanced when unintended code execution is not possible.

 

Copyright Titus Corporation 2001-2002. All Rights Reserved.

 

Back