2 * Copyright 2015 Open Networking Laboratory
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.onosproject.ovsdb.controller.impl;
18 import io.netty.buffer.ByteBuf;
19 import io.netty.channel.ChannelHandlerContext;
20 import io.netty.handler.codec.ByteToMessageDecoder;
22 import java.util.List;
24 import org.onosproject.ovsdb.rfc.jsonrpc.JsonReadContext;
25 import org.onosproject.ovsdb.rfc.utils.JsonRpcReaderUtil;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
30 * Decoder for inbound messages.
32 public class MessageDecoder extends ByteToMessageDecoder {
34 private final Logger log = LoggerFactory.getLogger(MessageDecoder.class);
35 private final JsonReadContext context = new JsonReadContext();
38 * Default constructor.
40 public MessageDecoder() {
44 protected void decode(ChannelHandlerContext ctx, ByteBuf buf,
45 List<Object> out) throws Exception {
46 log.debug("Message decoder");
47 JsonRpcReaderUtil.readToJsonNode(buf, out, context);
51 public void exceptionCaught(ChannelHandlerContext context, Throwable cause) {
52 log.error("Exception inside channel handling pipeline.", cause);