2 * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.
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
10 package org.opendaylight.openflowjava.protocol.impl.clients;
12 import io.netty.channel.ChannelInitializer;
13 import io.netty.channel.ChannelPipeline;
14 import io.netty.channel.socket.nio.NioDatagramChannel;
16 import com.google.common.util.concurrent.SettableFuture;
18 /** Initializes udp pipeline
20 * @author michal.polkorab
22 public class UdpSimpleClientInitializer extends ChannelInitializer<NioDatagramChannel> {
24 private SettableFuture<Boolean> isOnlineFuture;
25 private ScenarioHandler scenarioHandler;
28 * @param isOnlineFuture future notifier of connected channel
30 public UdpSimpleClientInitializer(SettableFuture<Boolean> isOnlineFuture) {
31 this.isOnlineFuture = isOnlineFuture;
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;
45 * @param scenarioHandler handler of scenario events
47 public void setScenario(ScenarioHandler scenarioHandler) {
48 this.scenarioHandler = scenarioHandler;