Extensibility support (serialization part)
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / serialization / factories / OF10HelloInputMessageFactory.java
index 68f1a2d4ed11f53a0eaa22bbe879e8632c6ffb8e..47f84b54b937533eba3abbf2184f54504566a9e1 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.HelloInput;
 
 /**
@@ -21,35 +22,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 public class OF10HelloInputMessageFactory implements OFSerializer<HelloInput> {
 
     private static final byte MESSAGE_TYPE = 0;
-    private static int MESSAGE_LENGTH = 8;
-    private static OF10HelloInputMessageFactory instance;
-    
-    private OF10HelloInputMessageFactory() {
-        // do nothing, just singleton
-    }
-    
-    /**
-     * @return singleton factory
-     */
-    public static synchronized OF10HelloInputMessageFactory getInstance() {
-        if (instance == null) {
-            instance = new OF10HelloInputMessageFactory();
-        }
-        return instance;
-    }
 
     @Override
-    public void messageToBuffer(short version, ByteBuf out, HelloInput message) {
-        ByteBufUtils.writeOFHeader(instance, message, out);
+    public void serialize(HelloInput message, ByteBuf outBuffer) {
+        ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.OFHEADER_SIZE);
     }
 
-    @Override
-    public int computeLength(HelloInput message) {
-        return MESSAGE_LENGTH;
-    }
-
-    @Override
-    public byte getMessageType() {
-        return MESSAGE_TYPE;
-    }
 }