|
|
Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
Page 5 of 5
AlarmClock
The AlarmClock class acts as an alarm clock for ServiceLocatorVerifier. Internally, it maintains a low priority thread that "rings" according to the frequency period. When your initialization
code invokes VerifiedServiceLocator.setVerifier(...), a ServiceLocatorVerifier is created, triggering the creation of an AlarmClock. The AlarmClock rings to signal ServiceLocatorVerifier that it should check the cached services.
WaitingAlarm
ServiceLocatorVerifier implements the WaitingAlarm interface and has the method alarmRinging(). The AlarmClock invokes alarmRinging() each time it rings.
The Verified Service Locator pattern presented in this article enhances the Service Locator pattern, neutralizing potential problems often caused by cached services. The enhanced solution maintains the original pattern benefits and, through a periodic verification mechanism, detects and removes invalid cached services, preventing inappropriate usage of invalid services. This solution preserves the simplicity of Service Locator, so you receive the pattern's benefits without complicating your code.
Read more about Enterprise Java in JavaWorld's Enterprise Java section.