Merge "Remove duplicate dependency declaration"
[controller.git] / opendaylight / netconf / netconf-netty-util / src / main / java / org / opendaylight / controller / netconf / nettyutil / handler / FramingMechanismHandlerFactory.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. 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 package org.opendaylight.controller.netconf.nettyutil.handler;
10
11 import io.netty.buffer.ByteBuf;
12 import io.netty.handler.codec.MessageToByteEncoder;
13 import org.opendaylight.controller.netconf.util.messages.FramingMechanism;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
16
17 public final class FramingMechanismHandlerFactory {
18
19     private static final Logger LOG = LoggerFactory.getLogger(FramingMechanismHandlerFactory.class);
20
21     private FramingMechanismHandlerFactory() {
22         // not called - private constructor for utility class
23     }
24
25     public static MessageToByteEncoder<ByteBuf> createHandler(FramingMechanism framingMechanism) {
26         LOG.debug("{} framing mechanism was selected.", framingMechanism);
27         if (framingMechanism == FramingMechanism.EOM) {
28             return new EOMFramingMechanismEncoder();
29         } else {
30             return new ChunkedFramingMechanismEncoder();
31         }
32     }
33 }