Extensibility support (serialization part)
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / serialization / factories / GetFeaturesInputMessageFactory.java
index d1f82df2c01271413881bfca4c96fb4422bceccf..b04997d2d88290c329b4683daf9da0b281993d99 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.GetFeaturesInput;
 
 /**
@@ -22,38 +23,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 public class GetFeaturesInputMessageFactory implements OFSerializer<GetFeaturesInput>{
 
     /** Code type of FeaturesRequest message */
-    public static final byte MESSAGE_TYPE = 5;
-    private static final int MESSAGE_LENGTH = 8;
-    private static GetFeaturesInputMessageFactory instance;
-    
-    private GetFeaturesInputMessageFactory() {
-        // do nothing, just singleton
-    }
-    
-    /**
-     * @return singleton factory
-     */
-    public static synchronized GetFeaturesInputMessageFactory getInstance() {
-        if (instance == null) {
-            instance = new GetFeaturesInputMessageFactory();
-        }
-        return instance;
-    }
-
-    @Override
-    public void messageToBuffer(short version, ByteBuf out,
-            GetFeaturesInput message) {
-        ByteBufUtils.writeOFHeader(instance, message, out);
-    }
-
-    @Override
-    public int computeLength(GetFeaturesInput message) {
-        return MESSAGE_LENGTH;
-    }
+    private static final byte MESSAGE_TYPE = 5;
 
     @Override
-    public byte getMessageType() {
-        return MESSAGE_TYPE;
+    public void serialize(GetFeaturesInput message, ByteBuf outBuffer) {
+        ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.OFHEADER_SIZE);
     }
 
 }