Sonar issues fix
[bgpcep.git] / pcep / impl / src / main / java / org / opendaylight / protocol / pcep / impl / PCEPHandlerFactory.java
index 2485cc3a503d988c63720e5a9ef1f070b08c4fa2..475b7227aa11b8611577944e2af8319aaae86386 100644 (file)
@@ -7,32 +7,30 @@
  */
 package org.opendaylight.protocol.pcep.impl;
 
+import com.google.common.base.Preconditions;
+
 import io.netty.channel.ChannelHandler;
+import io.netty.channel.ChannelOutboundHandler;
 
-import org.opendaylight.protocol.framework.ProtocolHandlerFactory;
-import org.opendaylight.protocol.framework.ProtocolMessageDecoder;
-import org.opendaylight.protocol.framework.ProtocolMessageEncoder;
-import org.opendaylight.protocol.pcep.spi.MessageHandlerRegistry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
+import org.opendaylight.protocol.pcep.spi.MessageRegistry;
 
 /**
  * PCEP specific factory for protocol inbound/outbound handlers.
  */
-public class PCEPHandlerFactory extends ProtocolHandlerFactory<Message> {
-       private final ProtocolMessageEncoder<Message> encoder;
+public final class PCEPHandlerFactory {
+    private final MessageRegistry registry;
+    private final ChannelOutboundHandler encoder;
 
-       public PCEPHandlerFactory(final MessageHandlerRegistry registry) {
-               super(new PCEPMessageFactory(registry));
-               this.encoder = new ProtocolMessageEncoder<Message>(this.msgFactory);
-       }
+    public PCEPHandlerFactory(final MessageRegistry registry) {
+        this.registry = Preconditions.checkNotNull(registry);
+        this.encoder = new PCEPMessageToByteEncoder(registry);
+    }
 
-       @Override
-       public ChannelHandler[] getEncoders() {
-               return new ChannelHandler[] { this.encoder };
-       }
+    public ChannelHandler[] getEncoders() {
+        return new ChannelHandler[] { this.encoder };
+    }
 
-       @Override
-       public ChannelHandler[] getDecoders() {
-               return new ChannelHandler[] { new PCEPMessageHeaderDecoder(), new ProtocolMessageDecoder<Message>(this.msgFactory) };
-       }
+    public ChannelHandler[] getDecoders() {
+        return new ChannelHandler[] { new PCEPMessageHeaderDecoder(), new PCEPByteToMessageDecoder(registry), };
+    }
 }