Bug 2245 - Synchronized classes and data structures replaced by unsynchronized.
[openflowjava.git] / openflow-protocol-api / src / main / java / org / opendaylight / openflowjava / protocol / api / extensibility / SerializerRegistry.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 package org.opendaylight.openflowjava.protocol.api.extensibility;
9
10
11
12
13 /**
14  * Stores and handles serializers <br/>
15  * K - {@link MessageTypeKey} parameter type,<br/>
16  * S - returned serializer type
17  * @author michal.polkorab
18  *
19  */
20 public interface SerializerRegistry {
21
22     /**
23      * Serializer registry provisioning
24      */
25     public void init();
26
27     /**
28      * @param msgTypeKey lookup key
29      * @return serializer or NullPointerException if no serializer was found
30      */
31     <K, S extends OFGeneralSerializer> S getSerializer(MessageTypeKey<K> msgTypeKey);
32
33     /**
34      * Registers serializer
35      * Throws IllegalStateException when there is
36      * a serializer already registered under given key.
37      *
38      * If the serializer implements {@link SerializerRegistryInjector} interface,
39      * the serializer is injected with SerializerRegistry instance.
40      *
41      * @param key used for serializer lookup
42      * @param serializer serializer implementation
43      */
44     <K> void registerSerializer(MessageTypeKey<K> key,
45             OFGeneralSerializer serializer);
46
47     /**
48      * Unregisters serializer
49      * @param key used for serializer lookup
50      * @param serializer serializer implementation
51      * @return true if serializer was removed,
52      *  false if no serializer was found under specified key
53      */
54     <K> boolean unregisterSerializer(MessageTypeKey<K> key);
55 }