Extensibility support (deserialization part)
[openflowjava.git] / openflow-protocol-spi / src / main / java / org / opendaylight / openflowjava / protocol / spi / connection / SwitchConnectionProvider.java
1 /*
2  * Copyright (c) 2013 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
10 package org.opendaylight.openflowjava.protocol.spi.connection;
11
12 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration;
13 import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler;
14 import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey;
15 import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
16 import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
17 import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer;
18 import org.opendaylight.yangtools.yang.binding.DataObject;
19
20 import com.google.common.util.concurrent.ListenableFuture;
21
22 /**
23  * @author mirehak
24  * @author michal.polkorab
25  *
26  */
27 public interface SwitchConnectionProvider extends AutoCloseable {
28
29     /**
30      * @param configuration [protocol, port, address and supported features]
31      */
32     void setConfiguration(ConnectionConfiguration configuration);
33     
34     /**
35      * start listening to switches, but please don't forget to do
36      * {@link #setSwitchConnectionHandler(SwitchConnectionHandler)} first
37      * @return future, triggered to true, when listening channel is up and running
38      */
39     ListenableFuture<Boolean> startup();
40     
41     /**
42      * stop listening to switches
43      * @return future, triggered to true, when all listening channels are down
44      */
45     ListenableFuture<Boolean> shutdown();
46     
47     /**
48      * @param switchConHandler instance being informed when new switch connects
49      */
50     void setSwitchConnectionHandler(SwitchConnectionHandler switchConHandler);
51
52     /**
53      * Registers custom serializer
54      * @param key used for serializer lookup
55      * @param serializer serializer implementation
56      */
57     public  <E extends DataObject> void registerCustomSerializer(MessageTypeKey<E> key,
58             OFSerializer<E> serializer);
59             
60     /**
61      * Registers custom deserializer
62      * @param key used for deserializer lookup
63      * @param deserializer deserializer instance
64      */
65     public void registerDeserializer(MessageCodeKey key, OFGeneralDeserializer deserializer);
66
67 }