Enable checkstyle enforcement in openflowplugin-parent
[openflowplugin.git] / openflowjava / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / core / connection / MessageListenerWrapper.java
1 /*
2  * Copyright (c) 2014 Pantheon Technologies s.r.o. 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.openflowjava.protocol.impl.core.connection;
10
11 import io.netty.util.concurrent.Future;
12 import io.netty.util.concurrent.GenericFutureListener;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
14
15 /**
16  * Wraps outgoing message and includes listener attached to this message. This object
17  * is sent to OFEncoder. When OFEncoder fails to serialize the message,
18  * listener is filled with exception. The exception is then delegated to upper ODL layers.
19  * @author michal.polkorab
20  */
21 public class MessageListenerWrapper {
22
23     private final OfHeader msg;
24     private final GenericFutureListener<Future<Void>> listener;
25
26     /**
27      * Constructor.
28      *
29      * @param msg outgoing message
30      * @param listener listener attached to channel.write(msg) Future
31      */
32     public MessageListenerWrapper(Object msg, GenericFutureListener<Future<Void>> listener) {
33         this.msg = (OfHeader) msg;
34         this.listener = listener;
35     }
36
37     /**
38      * Returns the outgoing message.
39      *
40      * @return outgoing message (downstream)
41      */
42     public OfHeader getMsg() {
43         return msg;
44     }
45
46
47     /**
48      * Returns the listener listening on message sending success / failure.
49      *
50      * @return listener listening on message sending success / failure
51      */
52     public GenericFutureListener<Future<Void>> getListener() {
53         return listener;
54     }
55 }