variable name changes
This commit is contained in:
parent
81b9a8971e
commit
e269f7e599
|
@ -5,11 +5,11 @@ package com.baeldung.designpatterns.service.locator;
|
|||
*/
|
||||
public class InitialContext {
|
||||
|
||||
public Object lookup(String jndiName) {
|
||||
public Object lookup(String serviceName) {
|
||||
|
||||
if (jndiName.equalsIgnoreCase("EmailService")) {
|
||||
if (serviceName.equalsIgnoreCase("EmailService")) {
|
||||
return new EmailService();
|
||||
} else if (jndiName.equalsIgnoreCase("SMSService")) {
|
||||
} else if (serviceName.equalsIgnoreCase("SMSService")) {
|
||||
return new SMSService();
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -11,16 +11,16 @@ public class ServiceLocator {
|
|||
cache = new Cache();
|
||||
}
|
||||
|
||||
public static MessagingService getService(String jndiName){
|
||||
public static MessagingService getService(String serviceName){
|
||||
|
||||
MessagingService service = cache.getService(jndiName);
|
||||
MessagingService service = cache.getService(serviceName);
|
||||
|
||||
if(service != null){
|
||||
return service;
|
||||
}
|
||||
|
||||
InitialContext context = new InitialContext();
|
||||
MessagingService service1 = (MessagingService)context.lookup(jndiName);
|
||||
MessagingService service1 = (MessagingService)context.lookup(serviceName);
|
||||
cache.addService(service1);
|
||||
return service1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue