*/
package org.opendaylight.protocol.bgp.rib.impl;
+import com.google.common.base.Preconditions;
+
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelOutboundHandler;
-import org.opendaylight.protocol.bgp.parser.BGPMessageFactory;
-
-import com.google.common.base.Preconditions;
+import org.opendaylight.protocol.bgp.parser.spi.MessageRegistry;
/**
* BGP specific factory for protocol inbound/outbound handlers.
*/
-public class BGPHandlerFactory {
- private final ChannelOutboundHandler encoder;
- private final BGPMessageFactory msgFactory;
+public class BGPHandlerFactory {
+ private final ChannelOutboundHandler encoder;
+ private final MessageRegistry registry;
- public BGPHandlerFactory(final BGPMessageFactory msgFactory) {
- this.msgFactory = Preconditions.checkNotNull(msgFactory);
- this.encoder = new BGPMessageToByteEncoder(msgFactory);
- }
+ public BGPHandlerFactory(final MessageRegistry registry) {
+ this.registry = Preconditions.checkNotNull(registry);
+ this.encoder = new BGPMessageToByteEncoder(registry);
+ }
- public ChannelHandler[] getEncoders() {
- return new ChannelHandler[] {
- this.encoder,
- };
- }
+ public ChannelHandler[] getEncoders() {
+ return new ChannelHandler[] { this.encoder, };
+ }
- public ChannelHandler[] getDecoders() {
- return new ChannelHandler[] {
- new BGPMessageHeaderDecoder(),
- new BGPByteToMessageDecoder(this.msgFactory),
- };
- }
+ public ChannelHandler[] getDecoders() {
+ return new ChannelHandler[] { BGPMessageHeaderDecoder.getBGPMessageHeaderDecoder(), new BGPByteToMessageDecoder(this.registry), };
+ }
}