BUG-58: refactor to take advantage of netty
[bgpcep.git] / 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 import java.util.List;
11
12 /**
13  * Interface for factory for parsing and serializing protocol specific messages. Needs to be implemented by a protocol
14  * specific message factory. The methods put/parse should delegate parsing to specific message parsers, e.g.
15  * OpenMessageParser etc.
16  *
17  * @param <T> type of messages created by this factory
18  */
19 public interface ProtocolMessageFactory<T extends ProtocolMessage> {
20
21         /**
22          * Parses message from byte array. Requires specific protocol message header object to parse the header.
23          * 
24          * @param bytes byte array from which the message will be parsed
25          * @return List of specific protocol messages
26          * @throws DeserializerException if some parsing error occurs
27          * @throws DocumentedException if some documented error occurs
28          */
29         public List<T> parse(final byte[] bytes) throws DeserializerException, DocumentedException;
30
31         /**
32          * Serializes protocol specific message to byte array.
33          * 
34          * @param msg message to be serialized.
35          * @return byte array resulting message
36          */
37         public byte[] put(final T msg);
38 }