51ab4b820acc0c3dfa55012a1e79bcfd9a925e4b
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / core / connection / MessageListenerWrapper.java
1 /*\r
2  * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 \r
9 package org.opendaylight.openflowjava.protocol.impl.core.connection;\r
10 \r
11 import io.netty.util.concurrent.Future;\r
12 import io.netty.util.concurrent.GenericFutureListener;\r
13 \r
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;\r
15 \r
16 /**\r
17  * Wraps outgoing message and includes listener attached to this message. This object\r
18  * is sent to OFEncoder. When OFEncoder fails to serialize the message,\r
19  * listener is filled with exception. The exception is then delegated to upper ODL layers. \r
20  * @author michal.polkorab\r
21  */\r
22 public class MessageListenerWrapper {\r
23 \r
24     private OfHeader msg;\r
25     private GenericFutureListener<Future<Void>> listener;\r
26 \r
27     /**\r
28      * @param msg outgoing message\r
29      * @param listener listener attached to channel.write(msg) Future\r
30      */\r
31     public MessageListenerWrapper(Object msg, GenericFutureListener<Future<Void>> listener) {\r
32         this.msg = (OfHeader) msg;\r
33         this.listener = listener;\r
34     }\r
35 \r
36     /**\r
37      * @return outgoing message (downstream)\r
38      */\r
39     public OfHeader getMsg() {\r
40         return msg;\r
41     }\r
42 \r
43     \r
44     /**\r
45      * @return listener listening on message sending success / failure\r
46      */\r
47     public GenericFutureListener<Future<Void>> getListener() {\r
48         return listener;\r
49     }\r
50 }