Move protocol framework from BGPCEP project
[controller.git] / opendaylight / commons / protocol-framework / src / main / java / org / opendaylight / protocol / framework / ProtocolMessageFactory.java
1 /*
2  * Copyright (c) 2013 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.protocol.framework;
9
10
11 /**
12  * Interface for factory for parsing and serializing protocol specific messages. Needs to be implemented by a protocol
13  * specific message factory. The methods put/parse should delegate parsing to specific message parsers, e.g.
14  * OpenMessageParser etc.
15  *
16  * @param <T> type of messages created by this factory
17  *
18  * @deprecated Interact with Netty 4.0 directly, by subclassing {@link io.netty.handler.codec.ByteToMessageCodec} or
19  * similar.
20  */
21 @Deprecated
22 public interface ProtocolMessageFactory<T> {
23
24     /**
25      * Parses message from byte array. Requires specific protocol message header object to parse the header.
26      *
27      * @param bytes byte array from which the message will be parsed
28      * @return List of specific protocol messages
29      * @throws DeserializerException if some parsing error occurs
30      * @throws DocumentedException if some documented error occurs
31      */
32     T parse(byte[] bytes) throws DeserializerException, DocumentedException;
33
34     /**
35      * Serializes protocol specific message to byte array.
36      *
37      * @param msg message to be serialized.
38      * @return byte array resulting message
39      */
40     byte[] put(T msg);
41 }