// Path: src/main/java/cz/tomasdvorak/eet/client/utils/DateUtils.java
// public final class DateUtils {
// 
//     private static final XmlDateAdapter DATE_ADAPTER = new XmlDateAdapter();
// 
//     private DateUtils() {
//         // utils class, no instance allowed
//     }
// 
//     public static Date parse(final String date) {
//         try {
//             return DATE_ADAPTER.unmarshal(date);
//         } catch (final ParseException e) {
//             throw new InvalidFormatException(e);
//         }
//     }
// 
//     public static String format(final Date date) {
//         return DATE_ADAPTER.marshal(date);
//     }
// }


import cz.tomasdvorak.eet.client.utils.DateUtils;
import cz.tomasdvorak.eet.client.utils.StringJoiner;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.interceptor.LoggingMessage;
import org.apache.cxf.message.Message;
import org.apache.cxf.phase.AbstractPhaseInterceptor;
import org.apache.cxf.phase.Phase;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.Date;
package cz.tomasdvorak.eet.client.timing;



/**
 * Interceptor for logging the request-responce cycle duration to a CSV log.
 */
public class TimingReceiveInterceptor extends AbstractPhaseInterceptor<Message> {

    public static final TimingReceiveInterceptor INSTANCE = new TimingReceiveInterceptor();

    private static final Logger logger = LoggerFactory.getLogger(TimingReceiveInterceptor.class);

    private TimingReceiveInterceptor() {
        super(Phase.RECEIVE);
    }

    @Override
    public void handleMessage(final Message msg) throws Fault {
        final Long startTime = (Long) msg.getExchange().remove(TimingSendInterceptor.KEY);
        if (startTime != null) {
            final long executionTime = System.currentTimeMillis() - startTime;
            logger.info(formatLogEntry(msg, executionTime));
        }
    }

    private String formatLogEntry(final Message msg, final long executionTime) {
        return StringJoiner.join(";", Arrays.asList(
// Path: src/main/java/cz/tomasdvorak/eet/client/utils/DateUtils.java
// public final class DateUtils {
// 
//     private static final XmlDateAdapter DATE_ADAPTER = new XmlDateAdapter();
// 
//     private DateUtils() {
//         // utils class, no instance allowed
//     }
// 
//     public static Date parse(final String date) {
//         try {
//             return DATE_ADAPTER.unmarshal(date);
//         } catch (final ParseException e) {
//             throw new InvalidFormatException(e);
//         }
//     }
// 
//     public static String format(final Date date) {
//         return DATE_ADAPTER.marshal(date);
//     }
// }


// Path: src/main/java/cz/tomasdvorak/eet/client/timing/TimingReceiveInterceptor.java
import cz.tomasdvorak.eet.client.utils.DateUtils;
import cz.tomasdvorak.eet.client.utils.StringJoiner;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.interceptor.LoggingMessage;
import org.apache.cxf.message.Message;
import org.apache.cxf.phase.AbstractPhaseInterceptor;
import org.apache.cxf.phase.Phase;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.Date;

package cz.tomasdvorak.eet.client.timing;



/**
 * Interceptor for logging the request-responce cycle duration to a CSV log.
 */
public class TimingReceiveInterceptor extends AbstractPhaseInterceptor<Message> {

    public static final TimingReceiveInterceptor INSTANCE = new TimingReceiveInterceptor();

    private static final Logger logger = LoggerFactory.getLogger(TimingReceiveInterceptor.class);

    private TimingReceiveInterceptor() {
        super(Phase.RECEIVE);
    }

    @Override
    public void handleMessage(final Message msg) throws Fault {
        final Long startTime = (Long) msg.getExchange().remove(TimingSendInterceptor.KEY);
        if (startTime != null) {
            final long executionTime = System.currentTimeMillis() - startTime;
            logger.info(formatLogEntry(msg, executionTime));
        }
    }

    private String formatLogEntry(final Message msg, final long executionTime) {
        return StringJoiner.join(";", Arrays.asList(
                "" + DateUtils.format(new Date()),