package com.nokia.springboot.training.d04.s01.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.concurrent.ListenableFuture;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

@Service
public class ProductService {

    private final AsyncComponent asyncComponent;

    @Autowired
    public ProductService(final AsyncComponent asyncComponent) {
        this.asyncComponent = asyncComponent;
    }

    public void voidAsyncCall() {
        asyncComponent.voidAsyncCall();
    }

    public void getFuture() {
        final Future<String> future = asyncComponent.getFuture();

        try {
            getAndDisplayValue(future);
        } catch (final ExecutionException | InterruptedException e) {
            handleException(e);
        }
    }

    public void getCompletableFuture() {
        final CompletableFuture<String> completableFuture = asyncComponent.getCompletableFuture();

        try {
            getAndDisplayValue(completableFuture);
        } catch (final ExecutionException | InterruptedException e) {
            handleException(e);
        }
    }

    private void getAndDisplayValue(final Future<String> futureValue)
            throws ExecutionException, InterruptedException {

        if (futureValue.isDone()) {
            final String theValue = futureValue.get();
            System.out.println("The " + futureValue.getClass().getSimpleName() + " value is '" + theValue + "'");
        }
    }

    private void handleException(final Exception ex) {
        ex.printStackTrace();
    }
}

@@ -45,24 +45,81 @@
 1.service;%0A%0A
+import org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A
 import org.s
@@ -169,16 +169,16 @@
 owired;%0A
-
 import o
@@ -446,24 +446,113 @@
 tService %7B%0A%0A
+    private static final Logger LOGGER = LoggerFactory.getLogger(ProductService.class);%0A%0A
     private 
@@ -947,24 +947,34 @@
 Value(future
+, %22Future%22
 );%0A        %7D
@@ -1286,16 +1286,37 @@
 leFuture
+, %22CompletableFuture%22
 );%0A     
@@ -1497,16 +1497,40 @@
 ureValue
+, final String className
 )%0A      
@@ -1693,92 +1693,54 @@
     
-System.out.println(%22The %22 + futureValue.getClass().getSimpleName() + %22 value is '%22 +
+LOGGER.info(%22The %7B%7D value is '%7B%7D'%22, className,
  the
@@ -1748,14 +1748,8 @@
 alue
- + %22'%22
 );%0A 

Use a logger instead of System.out, display the class name