local variable type inference changes (#1035)

local variable type inference changes for design pattern service locator
This commit is contained in:
GVSharma 2019-10-26 21:08:09 +05:30 committed by Ilkka Seppälä
parent f7a53f2d17
commit 58d8fa1758
2 changed files with 3 additions and 3 deletions

View File

@ -45,7 +45,7 @@ public class App {
* @param args command line args
*/
public static void main(String[] args) {
Service service = ServiceLocator.getService("jndi/serviceA");
var service = ServiceLocator.getService("jndi/serviceA");
service.execute();
service = ServiceLocator.getService("jndi/serviceB");
service.execute();

View File

@ -45,7 +45,7 @@ public final class ServiceLocator {
* @return {@link Service}
*/
public static Service getService(String serviceJndiName) {
Service serviceObj = serviceCache.getService(serviceJndiName);
var serviceObj = serviceCache.getService(serviceJndiName);
if (serviceObj != null) {
return serviceObj;
} else {
@ -53,7 +53,7 @@ public final class ServiceLocator {
* If we are unable to retrive anything from cache, then lookup the service and add it in the
* cache map
*/
InitContext ctx = new InitContext();
var ctx = new InitContext();
serviceObj = (Service) ctx.lookup(serviceJndiName);
if (serviceObj != null) { // Only cache a service if it actually exists
serviceCache.addService(serviceObj);