Unless your Business Delegates use a Service Locator, they will have duplicate code for dealing with the lookup service.
To implement a Service Locator, we’ll take all of the logic for doing the JNDI lookup and move it out of the multiple Business Delegates and into a single Service Locator.
Typically in J2EE applications, there will be a number of components that all use the same JNDI service. While a complex application might use several different registries such as JNDI and UDDI (for web service endpoints), an individual component will typically need access to only one registry. In general, a single Service Locator will support a single, specific registry.
By making the Business Delegate an object that handles only the business methods rather than also handling the registry lookup code, you increase the cohesion for the Business Delegates.
A Service Locator’s pseudo-code
// obtain an InitialContext object // perform remote lookup // handle remote issues // optionally, cache references