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.EchoInput;
/**
public class EchoInputMessageFactory implements OFSerializer<EchoInput> {
/** Code type of EchoRequest message */
- public static final byte MESSAGE_TYPE = 2;
- private static EchoInputMessageFactory instance;
- private static final int MESSAGE_LENGTH = 8;
-
- private EchoInputMessageFactory() {
- // do nothing, just singleton
- }
-
- /**
- * @return singleton factory
- */
- public static synchronized EchoInputMessageFactory getInstance() {
- if (instance == null) {
- instance = new EchoInputMessageFactory();
- }
- return instance;
- }
+ private static final byte MESSAGE_TYPE = 2;
@Override
- public void messageToBuffer(short version, ByteBuf out, EchoInput message) {
- ByteBufUtils.writeOFHeader(instance, message, out);
+ public void serialize(EchoInput message, ByteBuf outBuffer) {
+ ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH);
byte[] data = message.getData();
if (data != null) {
- out.writeBytes(data);
+ outBuffer.writeBytes(data);
}
+ ByteBufUtils.updateOFHeaderLength(outBuffer);
}
- @Override
- public int computeLength(EchoInput message) {
- int length = MESSAGE_LENGTH;
- byte[] data = message.getData();
- if (data != null) {
- length += data.length;
- }
- return length;
- }
-
- @Override
- public byte getMessageType() {
- return MESSAGE_TYPE;
- }
-
}