X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=openflow-protocol-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowjava%2Fprotocol%2Fimpl%2Fserialization%2Fexperimenter%2FAbstractBundleMessageFactory.java;fp=openflow-protocol-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowjava%2Fprotocol%2Fimpl%2Fserialization%2Fexperimenter%2FAbstractBundleMessageFactory.java;h=0000000000000000000000000000000000000000;hb=ce9898d3e25c7cecae6a21290be1eb3c74061737;hp=3fc2896a49423da534eb39955e484257e615dd51;hpb=4231959d8488d0e5e50199703c5619d50428a962;p=openflowjava.git diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/AbstractBundleMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/AbstractBundleMessageFactory.java deleted file mode 100644 index 3fc2896a..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/AbstractBundleMessageFactory.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2016 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.experimenter; - -import io.netty.buffer.ByteBuf; -import java.util.List; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.openflowjava.util.ExperimenterSerializerKeyFactory; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundleFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundlePropertyType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.BundleProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.bundle.property.bundle.property.entry.BundleExperimenterProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.bundle.property.bundle.property.entry.bundle.experimenter.property.BundleExperimenterPropertyData; -import org.opendaylight.yangtools.yang.binding.DataContainer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Abstract class for common stuff of bundle messages. - */ -public abstract class AbstractBundleMessageFactory implements OFSerializer, - SerializerRegistryInjector { - - private static final Logger LOG = LoggerFactory.getLogger(AbstractBundleMessageFactory.class); - protected SerializerRegistry serializerRegistry; - - @Override - public void serialize(T input, ByteBuf outBuffer) { - // to be extended - } - - @Override - public void injectSerializerRegistry(SerializerRegistry serializerRegistry) { - this.serializerRegistry = serializerRegistry; - } - - protected static void writeBundleFlags(final BundleFlags bundleFlags, final ByteBuf outBuffer) { - int flagsBitMap = ByteBufUtils.fillBitMask(0, bundleFlags.isAtomic(), bundleFlags.isOrdered()); - outBuffer.writeShort(flagsBitMap); - } - - protected void writeBundleProperties(final List properties, final ByteBuf outBuffer) { - for (BundleProperty property : properties) { - BundlePropertyType type = property.getType(); - if (type != null && type.equals(BundlePropertyType.ONFETBPTEXPERIMENTER)) { - int startIndex = outBuffer.writerIndex(); - outBuffer.writeShort(type.getIntValue()); - int lengthIndex = outBuffer.writerIndex(); - outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH); - writeBundleExperimenterProperty(property, outBuffer); - outBuffer.setShort(lengthIndex, outBuffer.writerIndex() - startIndex); - } else { - LOG.warn("lTrying to serialize unknown bundle property (type: {}), skipping", type.getIntValue() ); - } - } - } - - protected void writeBundleExperimenterProperty(final BundleProperty bundleProperty, final ByteBuf outBuffer) { - BundleExperimenterProperty property = (BundleExperimenterProperty) bundleProperty.getBundlePropertyEntry(); - int experimenterId = property.getExperimenter().getValue().intValue(); - int expType = property.getExpType().intValue(); - outBuffer.writeInt(experimenterId); - outBuffer.writeInt(expType); - OFSerializer serializer = serializerRegistry.getSerializer( - ExperimenterSerializerKeyFactory.createBundlePropertySerializerKey(EncodeConstants.OF13_VERSION_ID, - experimenterId, expType)); - serializer.serialize(property.getBundleExperimenterPropertyData(), outBuffer); - } - -}