Remove trailing whitespace
[openflowjava.git] / simple-client / src / main / java / org / opendaylight / openflowjava / protocol / impl / clients / SimpleClientHandler.java
index e9453b58437ada987f4763909aee3742c7881f81..01e114bf15aabbbd5281e1131a121c464af9b6c6 100644 (file)
@@ -1,68 +1,75 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-\r
-package org.opendaylight.openflowjava.protocol.impl.clients;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-import io.netty.channel.ChannelHandlerContext;\r
-import io.netty.channel.ChannelInboundHandlerAdapter;\r
-\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-import com.google.common.util.concurrent.SettableFuture;\r
-\r
-/**\r
- *\r
- * @author michal.polkorab\r
- */\r
-public class SimpleClientHandler extends ChannelInboundHandlerAdapter {\r
-\r
-    protected static final Logger LOGGER = LoggerFactory.getLogger(SimpleClientHandler.class);\r
-    private static final int LENGTH_INDEX_IN_HEADER = 2;\r
-    private SettableFuture<Boolean> isOnlineFuture;\r
-    protected ScenarioHandler scenarioHandler;\r
-\r
-    /**\r
-     * @param isOnlineFuture future notifier of connected channel\r
-     * @param scenarioHandler handler of scenario events\r
-     */\r
-    public SimpleClientHandler(SettableFuture<Boolean> isOnlineFuture, ScenarioHandler scenarioHandler) {\r
-        this.isOnlineFuture = isOnlineFuture;\r
-        this.scenarioHandler = scenarioHandler;\r
-    }\r
-\r
-    @Override\r
-    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {\r
-        ByteBuf bb = (ByteBuf) msg;\r
-        if (LOGGER.isDebugEnabled()) {\r
-            LOGGER.debug("<< " + ByteBufUtils.byteBufToHexString(bb));\r
-        }\r
-        int length = bb.getUnsignedShort(LENGTH_INDEX_IN_HEADER);\r
-        LOGGER.info("SimpleClientHandler - start of read");\r
-        byte[] message = new byte[length];\r
-        bb.readBytes(message);\r
-        scenarioHandler.addOfMsg(message);\r
-        LOGGER.info("end of read");\r
-    }\r
-\r
-    @Override\r
-    public void channelActive(ChannelHandlerContext ctx) throws Exception {\r
-        LOGGER.info("Client is active");\r
-        if (isOnlineFuture != null) {\r
-            isOnlineFuture.set(true);\r
-            isOnlineFuture = null;\r
-        }\r
-        scenarioHandler.setCtx(ctx);\r
-        scenarioHandler.start();\r
-        \r
-    }\r
-\r
-    /**\r
-     * @param scenarioHandler handler of scenario events\r
-     */\r
-    public void setScenario(ScenarioHandler scenarioHandler) {\r
-        this.scenarioHandler = scenarioHandler;\r
-    }\r
-\r
-}\r
+/*
+ * Copyright (c) 2013 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.clients;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandlerAdapter;
+
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.util.concurrent.SettableFuture;
+
+/**
+ *
+ * @author michal.polkorab
+ */
+public class SimpleClientHandler extends ChannelInboundHandlerAdapter {
+
+    protected static final Logger LOGGER = LoggerFactory.getLogger(SimpleClientHandler.class);
+    private static final int LENGTH_INDEX_IN_HEADER = 2;
+    private SettableFuture<Boolean> isOnlineFuture;
+    protected ScenarioHandler scenarioHandler;
+
+    /**
+     * @param isOnlineFuture future notifier of connected channel
+     * @param scenarioHandler handler of scenario events
+     */
+    public SimpleClientHandler(SettableFuture<Boolean> isOnlineFuture, ScenarioHandler scenarioHandler) {
+        this.isOnlineFuture = isOnlineFuture;
+        this.scenarioHandler = scenarioHandler;
+    }
+
+    @Override
+    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+        ByteBuf bb = (ByteBuf) msg;
+        if (LOGGER.isDebugEnabled()) {
+            LOGGER.debug("<< " + ByteBufUtils.byteBufToHexString(bb));
+        }
+        int length = bb.getUnsignedShort(bb.readerIndex() + LENGTH_INDEX_IN_HEADER);
+        LOGGER.trace("SimpleClientHandler - start of read");
+        byte[] message = new byte[length];
+        bb.readBytes(message);
+        scenarioHandler.addOfMsg(message);
+        LOGGER.trace("end of read");
+    }
+
+    @Override
+    public void channelActive(ChannelHandlerContext ctx) throws Exception {
+        LOGGER.debug("Client is active");
+        if (isOnlineFuture != null) {
+            isOnlineFuture.set(true);
+            isOnlineFuture = null;
+        }
+        scenarioHandler.setCtx(ctx);
+        scenarioHandler.start();
+
+    }
+
+    /**
+     * @param scenarioHandler handler of scenario events
+     */
+    public void setScenario(ScenarioHandler scenarioHandler) {
+        this.scenarioHandler = scenarioHandler;
+    }
+
+}