Help: Using a Facade to avoid Deadlocks


Help is available for each task, or you can go straight to the solution source code.

Task 1

Create a Registrar class to handle relationship setting.
Create the new Registrar class, add a single synchronized method to set the relationship between a person and a locker. The code for this method will be very similar to the existing registerLocker method.

Task 2

Modify the LockerSwitcher class to use the Registrar for switches.
Instead of calling registerLocker, change it to call the equivalent method on a Registrar object. The Registrar object should be passed in as an argument to the contructor for the LockerSwitcher class and stored in a local variable.

Task 3

Modify the FacadeTest class to use the Registrar object.
Create a new Registrar along with the Person and Locker objects. Pass a reference to the Registrar as an argument to the LockerSwitcher constructors.

Copyright © 1996-1997 MageLang Institute. All Rights Reserved.