Initial framework migration to 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 /**
11  * Interface for factory for parsing and serializing protocol specific messages. Needs to be implemented by a protocol
12  * specific message factory. The methods put/parse should delegate parsing to specific message parsers, e.g.
13  * OpenMessageParser etc.
14  */
15 public interface ProtocolMessageFactory {
16
17         /**
18          * Parses message from byte array. Requires specific protocol message header object to parse the header.
19          * 
20          * @param bytes byte array from which the message will be parsed
21          * @param msgHeader protocol specific message header to parse the header
22          * @return specific protocol message
23          * @throws DeserializerException if some parsing error occurs
24          * @throws DocumentedException if some documented error occurs
25          */
26         public ProtocolMessage parse(final byte[] bytes) throws DeserializerException, DocumentedException;
27
28         /**
29          * Serializes protocol specific message to byte array.
30          * 
31          * @param msg message to be serialized.
32          * @return byte array resulting message
33          */
34         public byte[] put(final ProtocolMessage msg);
35 }