-/*\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 java.util.List;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.core.connection.UdpMessageListenerWrapper;\r
-import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.buffer.PooledByteBufAllocator;\r
-import io.netty.channel.ChannelHandlerContext;\r
-import io.netty.channel.socket.DatagramPacket;\r
-import io.netty.handler.codec.MessageToMessageEncoder;\r
-import io.netty.util.concurrent.Future;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class OFDatagramPacketEncoder extends MessageToMessageEncoder<UdpMessageListenerWrapper> {\r
-\r
- private static final Logger LOGGER = LoggerFactory.getLogger(OFDatagramPacketEncoder.class);\r
- private SerializationFactory serializationFactory;\r
-\r
- @Override\r
- protected void encode(ChannelHandlerContext ctx,\r
- UdpMessageListenerWrapper wrapper, List<Object> out) throws Exception {\r
- LOGGER.trace("Encoding");\r
- try {\r
- ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();\r
- serializationFactory.messageToBuffer(wrapper.getMsg().getVersion(), buffer, wrapper.getMsg());\r
- out.add(new DatagramPacket(buffer, wrapper.getAddress()));\r
- } catch(Exception e) {\r
- LOGGER.warn("Message serialization failed: {}", e.getMessage());\r
- Future<Void> newFailedFuture = ctx.newFailedFuture(e);\r
- wrapper.getListener().operationComplete(newFailedFuture);\r
- return;\r
- }\r
- }\r
-\r
- /**\r
- * @param serializationFactory\r
- */\r
- public void setSerializationFactory(SerializationFactory serializationFactory) {\r
- this.serializationFactory = serializationFactory;\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 java.util.List;
+
+import org.opendaylight.openflowjava.protocol.impl.core.connection.UdpMessageListenerWrapper;
+import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.PooledByteBufAllocator;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.socket.DatagramPacket;
+import io.netty.handler.codec.MessageToMessageEncoder;
+import io.netty.util.concurrent.Future;
+
+/**
+ * @author michal.polkorab
+ *
+ */
+public class OFDatagramPacketEncoder extends MessageToMessageEncoder<UdpMessageListenerWrapper> {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(OFDatagramPacketEncoder.class);
+ private SerializationFactory serializationFactory;
+
+ @Override
+ protected void encode(ChannelHandlerContext ctx,
+ UdpMessageListenerWrapper wrapper, List<Object> out) throws Exception {
+ LOGGER.trace("Encoding");
+ try {
+ ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
+ serializationFactory.messageToBuffer(wrapper.getMsg().getVersion(), buffer, wrapper.getMsg());
+ out.add(new DatagramPacket(buffer, wrapper.getAddress()));
+ } catch(Exception e) {
+ LOGGER.warn("Message serialization failed: {}", e.getMessage());
+ Future<Void> newFailedFuture = ctx.newFailedFuture(e);
+ wrapper.getListener().operationComplete(newFailedFuture);
+ return;
+ }
+ }
+
+ /**
+ * @param serializationFactory
+ */
+ public void setSerializationFactory(SerializationFactory serializationFactory) {
+ this.serializationFactory = serializationFactory;
+ }
}
\ No newline at end of file