BUG-54 : switched channel pipeline to be protocol specific.
[bgpcep.git] / bgp / rib-impl / src / main / java / org / opendaylight / protocol / bgp / rib / impl / BGPHandlerFactory.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 package org.opendaylight.protocol.bgp.rib.impl;
9
10 import io.netty.channel.ChannelHandler;
11
12 import org.opendaylight.protocol.bgp.parser.BGPMessage;
13 import org.opendaylight.protocol.bgp.parser.BGPMessageFactory;
14 import org.opendaylight.protocol.framework.ProtocolHandlerFactory;
15 import org.opendaylight.protocol.framework.ProtocolMessageDecoder;
16 import org.opendaylight.protocol.framework.ProtocolMessageEncoder;
17
18 /**
19  * BGP specific factory for protocol inbound/outbound handlers.
20  */
21 public class BGPHandlerFactory extends ProtocolHandlerFactory<BGPMessage> {
22         private final ProtocolMessageEncoder<BGPMessage> encoder;
23
24         public BGPHandlerFactory(final BGPMessageFactory msgFactory) {
25                 super(msgFactory);
26                 this.encoder = new ProtocolMessageEncoder<BGPMessage>(this.msgFactory);
27         }
28
29         @Override
30         public ChannelHandler[] getEncoders() {
31                 return new ChannelHandler[] { this.encoder };
32         }
33
34         @Override
35         public ChannelHandler[] getDecoders() {
36                 return new ChannelHandler[] { new BGPMessageHeaderDecoder(), new ProtocolMessageDecoder<BGPMessage>(this.msgFactory) };
37         }
38 }