Extensibility support (serialization part)
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / serialization / factories / OF10BarrierInputMessageFactory.java
index e37adc61c001daee8a99d5546f0ecd3f539f8788..3a3e7eae1ca748dd37afa12a36aaac0edb49206b 100644 (file)
@@ -10,8 +10,9 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
 
 import io.netty.buffer.ByteBuf;
 
-import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
 import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
 
 /**
@@ -21,36 +22,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 public class OF10BarrierInputMessageFactory implements OFSerializer<BarrierInput> {
 
     private static final byte MESSAGE_TYPE = 18;
-    private static final int MESSAGE_LENGTH = 8;
 
-    private static OF10BarrierInputMessageFactory instance;
-    
-    private OF10BarrierInputMessageFactory() {
-        // do nothing, just singleton
-    }
-    
-    /**
-     * @return singleton factory
-     */
-    public static synchronized OF10BarrierInputMessageFactory getInstance() {
-        if (instance == null) {
-            instance = new OF10BarrierInputMessageFactory();
-        }
-        return instance;
-    }
-    
     @Override
-    public void messageToBuffer(short version, ByteBuf out, BarrierInput message) {
-        ByteBufUtils.writeOFHeader(instance, message, out);
+    public void serialize(BarrierInput message, ByteBuf outBuffer) {
+        ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.OFHEADER_SIZE);
     }
 
-    @Override
-    public int computeLength(BarrierInput message) {
-        return MESSAGE_LENGTH;
-    }
-
-    @Override
-    public byte getMessageType() {
-        return MESSAGE_TYPE;
-    }
 }