@Test public void testGetNonExistentService() { assertNull(ServiceLocator.getService("fantastic/unicorn/service")); assertNull(ServiceLocator.getService("another/fantastic/unicorn/service")); }
public static Service getService(String serviceJndiName) { Service serviceObj = serviceCache.getService(serviceJndiName); if (serviceObj != null) { return serviceObj; } else { InitContext ctx = new InitContext(); serviceObj = (Service) ctx.lookup(serviceJndiName); if (serviceObj != null) { serviceCache.addService(serviceObj); } return serviceObj; } }
ServiceLocator { public static Service getService(String serviceJndiName) { Service serviceObj = serviceCache.getService(serviceJndiName); if (serviceObj != null) { return serviceObj; } else { InitContext ctx = new InitContext(); serviceObj = (Service) ctx.lookup(serviceJndiName); if (serviceObj != null) { serviceCache.addService(serviceObj); } return serviceObj; } } }
ServiceLocator { public static Service getService(String serviceJndiName) { Service serviceObj = serviceCache.getService(serviceJndiName); if (serviceObj != null) { return serviceObj; } else { InitContext ctx = new InitContext(); serviceObj = (Service) ctx.lookup(serviceJndiName); if (serviceObj != null) { serviceCache.addService(serviceObj); } return serviceObj; } } private  ServiceLocator(); }
ServiceLocator { public static Service getService(String serviceJndiName) { Service serviceObj = serviceCache.getService(serviceJndiName); if (serviceObj != null) { return serviceObj; } else { InitContext ctx = new InitContext(); serviceObj = (Service) ctx.lookup(serviceJndiName); if (serviceObj != null) { serviceCache.addService(serviceObj); } return serviceObj; } } private  ServiceLocator(); static Service getService(String serviceJndiName); }
ServiceLocator { public static Service getService(String serviceJndiName) { Service serviceObj = serviceCache.getService(serviceJndiName); if (serviceObj != null) { return serviceObj; } else { InitContext ctx = new InitContext(); serviceObj = (Service) ctx.lookup(serviceJndiName); if (serviceObj != null) { serviceCache.addService(serviceObj); } return serviceObj; } } private  ServiceLocator(); static Service getService(String serviceJndiName);  }