2 * Copyright (c) 2013 Cisco Systems, Inc. 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
9 package org.opendaylight.controller.netconf.util;
11 import io.netty.channel.socket.SocketChannel;
12 import io.netty.util.concurrent.Promise;
14 import org.opendaylight.controller.netconf.api.NetconfSession;
15 import org.opendaylight.controller.netconf.util.handler.FramingMechanismHandlerFactory;
16 import org.opendaylight.controller.netconf.util.handler.NetconfMessageAggregator;
17 import org.opendaylight.controller.netconf.util.handler.NetconfMessageToXMLEncoder;
18 import org.opendaylight.controller.netconf.util.handler.NetconfXMLToMessageDecoder;
19 import org.opendaylight.controller.netconf.util.messages.FramingMechanism;
21 public abstract class AbstractChannelInitializer {
23 public void initialize(SocketChannel ch, Promise<? extends NetconfSession> promise){
24 ch.pipeline().addLast("aggregator", new NetconfMessageAggregator(FramingMechanism.EOM));
25 ch.pipeline().addLast(new NetconfXMLToMessageDecoder());
26 initializeAfterDecoder(ch, promise);
27 ch.pipeline().addLast("frameEncoder", FramingMechanismHandlerFactory.createHandler(FramingMechanism.EOM));
28 ch.pipeline().addLast(new NetconfMessageToXMLEncoder());
31 protected abstract void initializeAfterDecoder(SocketChannel ch, Promise<? extends NetconfSession> promise);