2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.protocol.framework;
10 import io.netty.buffer.ByteBuf;
11 import io.netty.channel.ChannelHandlerContext;
12 import io.netty.channel.MessageList;
13 import io.netty.handler.codec.ByteToMessageDecoder;
15 final class ProtocolMessageDecoder extends ByteToMessageDecoder {
17 private final ProtocolMessageFactory factory;
19 public ProtocolMessageDecoder(final ProtocolMessageFactory factory) {
20 this.factory = factory;
24 public void decode(final ChannelHandlerContext ctx, final ByteBuf in, final MessageList<Object> out) throws Exception {
25 ProtocolMessage msg = null;
27 msg = this.factory.parse(in.array());
28 } catch (DeserializerException | DocumentedException e) {
29 this.exceptionCaught(ctx, e);
35 public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) throws Exception {