- private final Optional<SSLContext> maybeContext;
- private final NetconfHandlerFactory handlerFactory;
-
- public AbstractChannelInitializer(Optional<SSLContext> maybeContext) {
- this.maybeContext = maybeContext;
- this.handlerFactory = new NetconfHandlerFactory(new NetconfMessageFactory());
- }
-
- public void initialize(SocketChannel ch, Promise<? extends NetconfSession> promise) {
- if (maybeContext.isPresent()) {
- initSsl(ch);
- }
-
- ch.pipeline().addLast("aggregator", new NetconfMessageAggregator(FramingMechanism.EOM));
- ch.pipeline().addLast(handlerFactory.getDecoders());
- initializeAfterDecoder(ch, promise);
- ch.pipeline().addLast("frameEncoder", FramingMechanismHandlerFactory.createHandler(FramingMechanism.EOM));
- ch.pipeline().addLast(handlerFactory.getEncoders());
- }