X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflow-protocol-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowjava%2Fprotocol%2Fimpl%2Fserialization%2Ffactories%2FSetAsyncInputMessageFactory.java;h=65cb07e33ff880fce4edf468555dfa7102f10424;hb=07de1ed897da9d7dc70c6d550f38c59339ed751e;hp=c647aaf708b53b605a9312d3e10b8eb59f498be6;hpb=0d942e8fb70b2c21f97eea3ed8904336ab5c54a4;p=openflowjava.git diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactory.java index c647aaf7..65cb07e3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactory.java @@ -14,8 +14,9 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason; @@ -31,44 +32,17 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 */ public class SetAsyncInputMessageFactory implements OFSerializer { private static final byte MESSAGE_TYPE = 28; - private static final int MESSAGE_LENGTH = 32; - private static SetAsyncInputMessageFactory instance; - - - private SetAsyncInputMessageFactory() { - // singleton - } - - /** - * @return singleton factory - */ - public static synchronized SetAsyncInputMessageFactory getInstance() { - if (instance == null) { - instance = new SetAsyncInputMessageFactory(); - } - return instance; - } - - @Override - public void messageToBuffer(short version, ByteBuf out, - SetAsyncInput message) { - ByteBufUtils.writeOFHeader(instance, message, out); - encodePacketInMask(message.getPacketInMask(), out); - encodePortStatusMask(message.getPortStatusMask(), out); - encodeFlowRemovedMask(message.getFlowRemovedMask(), out); - } @Override - public int computeLength(SetAsyncInput message) { - return MESSAGE_LENGTH; + public void serialize(SetAsyncInput message, ByteBuf outBuffer) { + ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); + serializePacketInMask(message.getPacketInMask(), outBuffer); + serializePortStatusMask(message.getPortStatusMask(), outBuffer); + serializerFlowRemovedMask(message.getFlowRemovedMask(), outBuffer); + ByteBufUtils.updateOFHeaderLength(outBuffer); } - @Override - public byte getMessageType() { - return MESSAGE_TYPE; - } - - private static void encodePacketInMask(List packetInMask, ByteBuf outBuffer) { + private static void serializePacketInMask(List packetInMask, ByteBuf outBuffer) { if (packetInMask != null) { for (PacketInMask currentPacketMask : packetInMask) { List mask = currentPacketMask.getMask(); @@ -88,8 +62,8 @@ public class SetAsyncInputMessageFactory implements OFSerializer } } } - - private static void encodePortStatusMask(List portStatusMask, ByteBuf outBuffer) { + + private static void serializePortStatusMask(List portStatusMask, ByteBuf outBuffer) { if (portStatusMask != null) { for (PortStatusMask currentPortStatusMask : portStatusMask) { List mask = currentPortStatusMask.getMask(); @@ -109,8 +83,8 @@ public class SetAsyncInputMessageFactory implements OFSerializer } } } - - private static void encodeFlowRemovedMask(List flowRemovedMask, ByteBuf outBuffer) { + + private static void serializerFlowRemovedMask(List flowRemovedMask, ByteBuf outBuffer) { if (flowRemovedMask != null) { for (FlowRemovedMask currentFlowRemovedMask : flowRemovedMask) { List mask = currentFlowRemovedMask.getMask(); @@ -132,5 +106,5 @@ public class SetAsyncInputMessageFactory implements OFSerializer } } } - + } \ No newline at end of file