|
|
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 2 of 5
Some critical points:
The proposed enhanced Service Locator has a verifier mechanism that checks the cached services' validity by monitoring them during a cycle of a specified frequency. A low-priority thread executing during the verification cycle triggers the validation, identifying and eliminating invalid cached services, and ensuring the services' validity before a client attempts to use them. That way, the consumed validation time happens later, not while a client waits for a service response. The enhanced Service Locator is called Verified Service Locator, and I present its usage, structure, and participants below.
Figure 3 shows how a client uses Verified Service Locator.

Figure 3. Sequence diagram: Verified Service Locator usage
Verified Service Locator differs from Service Locator in the following ways:
ServiceVerifiable interface (explained in the "Participants and Responsibilities" section below).
VerifiedServiceLocator.setVerifier(...) to start the verification mechanism. The parameters are an object of the application-specific class and a verifying frequency
(also detailed in "Participants and Responsibilities"). Listing 1 below shows a sample JSP (JavaServer Page) initializing
VerifiedServiceLocator:
Listing 1. Initialize VerifiedServiceLocator
<%@ page import="enhancedServiceLocator.VerifiedServiceLocator" %>
<%@ page import="enhancedServiceLocator.test.MyAppServiceVerifiable" %>
<%!
public void jspInit()
{
// Sets the VerifiedServiceLocator
// to verify cached services
// every 5 minutes
VerifiedServiceLocator.setVerifier(5, new MyAppServiceVerifiable ());
}
%>
After initialization, Verified Service Locator works as Service Locator does. Listing 2 shows a sample JSP invoking the lookUp() method:
Listing 2. Normal Service Locator usage
<%@ page import="enhancedServiceLocator.VerifiedServiceLocator" %>
<%@ page import="enhancedServiceLocator.test.MyEJBHome" %>
<%@ page import="enhancedServiceLocator.test.MyRemote" %>
<%
VerifiedServiceLocator serviceLocator =
VerifiedServiceLocator.getInstance();
MyEJBHome myEJBHome =
(MyEJBHome) serviceLocator.lookup
(MyEJBHome.class, "myEJBJNDI");
MyRemote myRemote = myEJBHomee.create();
out.println( "output from ejb: "+myRemote.greetings( ) );
%>
Figure 4 shows the relationships among this solution's participants.

Figure 4. Class diagram: Verified Service Locator structure
The class diagram presents the classes VerifiedServiceLocator, ServiceLocatorVerifier, and AlarmClock, plus an app-specific class; the interfaces ServiceVerifiable and WaitingAlarm; and the relationships between them. They form the solution that enhances the Service Locator pattern.