Remove trailing whitespace
[openflowjava.git] / simple-client / src / main / java / org / opendaylight / openflowjava / protocol / impl / clients / UdpSimpleClientInitializer.java
1 /*
2  * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.
3  *
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
7  */
8
9
10 package org.opendaylight.openflowjava.protocol.impl.clients;
11
12 import io.netty.channel.ChannelInitializer;
13 import io.netty.channel.ChannelPipeline;
14 import io.netty.channel.socket.nio.NioDatagramChannel;
15
16 import com.google.common.util.concurrent.SettableFuture;
17
18 /** Initializes udp pipeline
19  *
20  * @author michal.polkorab
21  */
22 public class UdpSimpleClientInitializer extends ChannelInitializer<NioDatagramChannel> {
23
24     private SettableFuture<Boolean> isOnlineFuture;
25     private ScenarioHandler scenarioHandler;
26
27     /**
28      * @param isOnlineFuture future notifier of connected channel
29      */
30     public UdpSimpleClientInitializer(SettableFuture<Boolean> isOnlineFuture) {
31         this.isOnlineFuture = isOnlineFuture;
32     }
33
34     @Override
35     public void initChannel(NioDatagramChannel ch) throws Exception {
36         ChannelPipeline pipeline = ch.pipeline();
37         SimpleClientHandler simpleClientHandler = new SimpleClientHandler(isOnlineFuture, scenarioHandler);
38         simpleClientHandler.setScenario(scenarioHandler);
39         pipeline.addLast("framer", new UdpSimpleClientFramer());
40         pipeline.addLast("handler", simpleClientHandler);
41         isOnlineFuture = null;
42     }
43
44     /**
45      * @param scenarioHandler handler of scenario events
46      */
47     public void setScenario(ScenarioHandler scenarioHandler) {
48         this.scenarioHandler = scenarioHandler;
49     }
50 }