-/*\r
- * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-\r
-package org.opendaylight.openflowjava.protocol.impl.core;\r
-\r
-import io.netty.channel.ChannelHandlerContext;\r
-import io.netty.channel.SimpleChannelInboundHandler;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageConsumer;\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory;\r
-import org.opendaylight.openflowjava.util.ByteBufUtils;\r
-import org.opendaylight.yangtools.yang.binding.DataObject;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class OFDatagramPacketDecoder extends SimpleChannelInboundHandler<VersionMessageUdpWrapper>{\r
-\r
- private static final Logger LOGGER = LoggerFactory.getLogger(OFDatagramPacketDecoder.class);\r
- private DeserializationFactory deserializationFactory;\r
-\r
- @Override\r
- public void channelRead0(ChannelHandlerContext ctx, VersionMessageUdpWrapper msg)\r
- throws Exception {\r
- if (LOGGER.isDebugEnabled()) {\r
- LOGGER.debug("UdpVersionMessageWrapper received");\r
- LOGGER.debug("<< " + ByteBufUtils.byteBufToHexString(msg.getMessageBuffer()));\r
- }\r
- DataObject dataObject = null;\r
- try {\r
- dataObject = deserializationFactory.deserialize(msg.getMessageBuffer(),msg.getVersion());\r
- if (dataObject == null) {\r
- LOGGER.warn("Translated POJO is null");\r
- } else {\r
- MessageConsumer consumer = UdpConnectionMap.getMessageConsumer(msg.getAddress());\r
- consumer.consume(dataObject);\r
- }\r
- } catch(Exception e) {\r
- LOGGER.warn("Message deserialization failed");\r
- LOGGER.warn(e.getMessage(), e);\r
- // TODO: delegate exception to allow easier deserialization\r
- // debugging / deserialization problem awareness\r
- } finally {\r
- msg.getMessageBuffer().release();\r
- }\r
- }\r
-\r
- /**\r
- * @param deserializationFactory\r
- */\r
- public void setDeserializationFactory(DeserializationFactory deserializationFactory) {\r
- this.deserializationFactory = deserializationFactory;\r
- }\r
+/*
+ * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.protocol.impl.core;
+
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.SimpleChannelInboundHandler;
+
+import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageConsumer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author michal.polkorab
+ *
+ */
+public class OFDatagramPacketDecoder extends SimpleChannelInboundHandler<VersionMessageUdpWrapper>{
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(OFDatagramPacketDecoder.class);
+ private DeserializationFactory deserializationFactory;
+
+ @Override
+ public void channelRead0(ChannelHandlerContext ctx, VersionMessageUdpWrapper msg)
+ throws Exception {
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug("UdpVersionMessageWrapper received");
+ LOGGER.debug("<< " + ByteBufUtils.byteBufToHexString(msg.getMessageBuffer()));
+ }
+ DataObject dataObject = null;
+ try {
+ dataObject = deserializationFactory.deserialize(msg.getMessageBuffer(),msg.getVersion());
+ if (dataObject == null) {
+ LOGGER.warn("Translated POJO is null");
+ } else {
+ MessageConsumer consumer = UdpConnectionMap.getMessageConsumer(msg.getAddress());
+ consumer.consume(dataObject);
+ }
+ } catch(Exception e) {
+ LOGGER.warn("Message deserialization failed");
+ LOGGER.warn(e.getMessage(), e);
+ // TODO: delegate exception to allow easier deserialization
+ // debugging / deserialization problem awareness
+ } finally {
+ msg.getMessageBuffer().release();
+ }
+ }
+
+ /**
+ * @param deserializationFactory
+ */
+ public void setDeserializationFactory(DeserializationFactory deserializationFactory) {
+ this.deserializationFactory = deserializationFactory;
+ }
}
\ No newline at end of file