#502 Replaced usages of System.out with logger.
This commit is contained in:
@ -22,6 +22,9 @@
|
||||
*/
|
||||
package com.iluwatar.servicelocator;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* For JNDI lookup of services from the web.xml. Will match name of the service name that is being
|
||||
* requested and return a newly created service object with the name
|
||||
@ -30,6 +33,8 @@ package com.iluwatar.servicelocator;
|
||||
*/
|
||||
public class InitContext {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(InitContext.class);
|
||||
|
||||
/**
|
||||
* Perform the lookup based on the service name. The returned object will need to be casted into a
|
||||
* {@link Service}
|
||||
@ -39,10 +44,10 @@ public class InitContext {
|
||||
*/
|
||||
public Object lookup(String serviceName) {
|
||||
if (serviceName.equals("jndi/serviceA")) {
|
||||
System.out.println("Looking up service A and creating new service for A");
|
||||
LOGGER.info("Looking up service A and creating new service for A");
|
||||
return new ServiceImpl("jndi/serviceA");
|
||||
} else if (serviceName.equals("jndi/serviceB")) {
|
||||
System.out.println("Looking up service B and creating new service for B");
|
||||
LOGGER.info("Looking up service B and creating new service for B");
|
||||
return new ServiceImpl("jndi/serviceB");
|
||||
} else {
|
||||
return null;
|
||||
|
@ -22,6 +22,9 @@
|
||||
*/
|
||||
package com.iluwatar.servicelocator;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -35,6 +38,8 @@ import java.util.Map;
|
||||
*/
|
||||
public class ServiceCache {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ServiceCache.class);
|
||||
|
||||
private final Map<String, Service> serviceCache;
|
||||
|
||||
public ServiceCache() {
|
||||
@ -52,8 +57,8 @@ public class ServiceCache {
|
||||
for (String serviceJndiName : serviceCache.keySet()) {
|
||||
if (serviceJndiName.equals(serviceName)) {
|
||||
cachedService = serviceCache.get(serviceJndiName);
|
||||
System.out.println("(cache call) Fetched service " + cachedService.getName() + "("
|
||||
+ cachedService.getId() + ") from cache... !");
|
||||
LOGGER.info("(cache call) Fetched service {}({}) from cache... !",
|
||||
cachedService.getName(), cachedService.getId());
|
||||
}
|
||||
}
|
||||
return cachedService;
|
||||
|
@ -22,6 +22,9 @@
|
||||
*/
|
||||
package com.iluwatar.servicelocator;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* This is a single service implementation of a sample service. This is the actual service that will
|
||||
* process the request. The reference for this service is to be looked upon in the JNDI server that
|
||||
@ -31,6 +34,8 @@ package com.iluwatar.servicelocator;
|
||||
*/
|
||||
public class ServiceImpl implements Service {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ServiceImpl.class);
|
||||
|
||||
private final String serviceName;
|
||||
private final int id;
|
||||
|
||||
@ -57,6 +62,6 @@ public class ServiceImpl implements Service {
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
System.out.println("Service " + getName() + " is now executing with id " + getId());
|
||||
LOGGER.info("Service {} is now executing with id {}", getName(), getId());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user