Extensibility support (serialization part)
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / serialization / factories / GetQueueConfigInputMessageFactory.java
index d5c8d5b19945848af02a3fbb2577f05477f54451..f154125dc18357adf2e72b1ec85a8e488a7571f3 100644 (file)
@@ -1,10 +1,18 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+/*
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
 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.GetQueueConfigInput;
 
 /**
@@ -16,40 +24,13 @@ public class GetQueueConfigInputMessageFactory implements OFSerializer<GetQueueC
 
     private static final byte MESSAGE_TYPE = 22;
     private static final byte PADDING_IN_GET_QUEUE_CONFIG_MESSAGE = 4;
-    private static final int MESSAGE_LENGTH = 16;
-    
-    private static GetQueueConfigInputMessageFactory instance;
-    
-    private GetQueueConfigInputMessageFactory() {
-        // singleton
-    }
-    
-    
-    /**
-     * @return singleton factory
-     */
-    public static synchronized GetQueueConfigInputMessageFactory getInstance(){
-        if(instance == null){
-            instance = new GetQueueConfigInputMessageFactory();
-        }
-        return instance;
-    }
-    
-    @Override
-    public void messageToBuffer(short version, ByteBuf out, GetQueueConfigInput message){
-        ByteBufUtils.writeOFHeader(instance, message, out);
-        out.writeInt(message.getPort().getValue().intValue());
-        ByteBufUtils.padBuffer(PADDING_IN_GET_QUEUE_CONFIG_MESSAGE, out);
-    }
 
     @Override
-    public int computeLength(GetQueueConfigInput message){
-        return MESSAGE_LENGTH;
+    public void serialize(GetQueueConfigInput message, ByteBuf outBuffer) {
+        ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH);
+        outBuffer.writeInt(message.getPort().getValue().intValue());
+        ByteBufUtils.padBuffer(PADDING_IN_GET_QUEUE_CONFIG_MESSAGE, outBuffer);
+        ByteBufUtils.updateOFHeaderLength(outBuffer);
     }
 
-    @Override
-    public byte getMessageType() {
-        return MESSAGE_TYPE;
-    }
 }