Uploaded image for project: 'controller'
  1. controller
  2. CONTROLLER-365

Enhancements to the toaster md-sal exampl

    XMLWordPrintable

Details

    • Improvement
    • Status: Resolved
    • Resolution: Done
    • Helium
    • None
    • mdsal
    • None
    • Operating System: Linux
      Platform: PC

    Description

      While documenting the toaster example on wiki, Devin Avery and I would like to propose some enhancements to the example, specifically the toaster consumer part.

      Currently, the ToasterConsumer is a hand-coded interface providing a createToast method and the implementation merely passes through to ToasterService.makeToast. We were a little confused initially as to the intent of having another interface to make toast that essentially is a wrapper for the ToasterService. We surmise that the purpose of the ToasterConsumer is to demonstrate how to programmatically access the ToasterService. This is fine however essentially re-defining the same interface isn't very compelling and may be a little confusing.

      We'd like to propose changing the ToasterConsumer to a KitchenService interface with the ability to make breakfast:

      boolean makeBreakfast( EggsType eggs, Class<? extends ToastType> toast, int toastDoneness );

      This defines a higher-level service for making a full breakfast, including toast and eggs. This nicely demonstrates “service chaining”, a consumer of one or more services being a provider of another service. This example would only actually implement and call into the 'toast' service but one can see that it could be extended to also implement and call into an 'eggs' service and also add 'coffee' service etc.

      In addition, we'd like to propose replacing the 'toastDone' notification with ³toasterOutOfStock² and 'toasterRestocked' notifications. The KitchenService would listen for these notifications and set/clear an internal 'toasterOutOfStock' flag. In the makeBreakfast method, if toasterOutOfStock is true, fail the call, ie return false.

      In the toaster provider:

      • Add an amountOfBreadInStock field to the OpenDayLightToaster
      • Define toasterOutOfStock and toasterRestocked notifications. toasterRestocked would have an amountOfBread param
      • In makeToast, if toastsDone == amountOfBreadInStock, send the toasterOutOfStock notification and fail the call.
      • Add a JMX RPC, restockToaster with an amountOfBread param to the provider.
      • On restockToaster call, clear toastsDone, set amountOfBreadInStock, and send the toasterReStocked notification

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            tpantelis Tom Pantelis
            tpantelis Tom Pantelis
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: