DevideManagerImpl
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / connection / ConnectionContextImpl.java
1 /**
2  * Copyright (c) 2015 Cisco Systems, 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 package org.opendaylight.openflowplugin.impl.connection;
9
10 import com.google.common.util.concurrent.ListenableFuture;
11 import com.google.common.util.concurrent.SettableFuture;
12 import java.util.Collection;
13 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
14 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
15 import org.opendaylight.openflowplugin.api.openflow.connection.MultiMsgCollector;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
19
20 /**
21  *
22  */
23 public class ConnectionContextImpl implements ConnectionContext {
24
25     private final ConnectionAdapter connectionAdapter;
26     private CONNECTION_STATE connectionState;
27     private FeaturesReply featuresReply;
28     private final MultiMsgCollector multipartCollector;
29
30     /**
31      * @param connectionAdapter
32      */
33     public ConnectionContextImpl(final ConnectionAdapter connectionAdapter) {
34         this.connectionAdapter = connectionAdapter;
35         multipartCollector = new MultiMsgCollectorImpl();
36     }
37
38     @Override
39     public ConnectionAdapter getConnectionAdapter() {
40         return connectionAdapter;
41     }
42
43     @Override
44     public CONNECTION_STATE getConnectionState() {
45         return connectionState;
46     }
47
48     @Override
49     public NodeId getNodeId() {
50         // TODO Auto-generated method stub
51         return null;
52     }
53
54     @Override
55     public void setConnectionState(final CONNECTION_STATE connectionState) {
56         this.connectionState = connectionState;
57     }
58
59     @Override
60     public FeaturesReply getFeatures() {
61         return featuresReply;
62     }
63
64     @Override
65     public void setFeatures(final FeaturesReply featuresReply) {
66         this.featuresReply = featuresReply;
67
68     }
69
70     @Override
71     public ListenableFuture<Collection<MultipartReply>> registerMultipartMsg(final long xid) {
72         return multipartCollector.registerMultipartMsg(xid);
73     }
74
75     @Override
76     public void addMultipartMsg(final MultipartReply reply) {
77         multipartCollector.addMultipartMsg(reply);
78     }
79
80     @Override
81     public void registerMultipartFutureMsg(final long xid, final SettableFuture<Collection<MultipartReply>> future) {
82         multipartCollector.registerMultipartFutureMsg(xid, future);
83     }
84 }