Initial commit for ServiceHandler
[transportpce.git] / servicehandler / src / main / java / org / opendaylight / transportpce / servicehandler / LoggingFuturesCallBack.java
1 /*
2  * Copyright © 2017 Orange, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.transportpce.servicehandler;
10
11 import com.google.common.util.concurrent.FutureCallback;
12 import org.slf4j.Logger;
13
14 /*
15  * Class to log future logging from datastore actions (write & modify & delete..).
16  * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange
17  */
18
19 public class LoggingFuturesCallBack<V> implements FutureCallback<V> {
20
21     private Logger log;
22     private String message;
23
24     public LoggingFuturesCallBack(String message, Logger log) {
25         this.message = message;
26         this.log = log;
27     }
28
29     @Override
30     public void onFailure(Throwable ex) {
31         log.warn(message, ex);
32
33     }
34
35     @Override
36     public void onSuccess(V arg0) {
37         log.info("Success! {} ", arg0);
38
39     }
40
41 }