Merge "Refactoring: shortening of match methods"
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / services / PacketProcessingServiceImpl.java
index bd034c9da24510b064a9d8d021b1866d1a1c39cc..85e198ef24c6fd8c53ce1ec88e882451927be904 100644 (file)
@@ -7,29 +7,29 @@
  */
 package org.opendaylight.openflowplugin.impl.services;
 
-import java.math.BigInteger;
 import java.util.concurrent.Future;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.PacketOutConvertor;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.ConnectionCookie;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 
-public class PacketProcessingServiceImpl extends CommonService implements PacketProcessingService {
+public final class PacketProcessingServiceImpl extends AbstractVoidService<TransmitPacketInput> implements PacketProcessingService {
+
+    public PacketProcessingServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+        super(requestContextStack, deviceContext);
+    }
 
     @Override
-    //TODO this implementation is incorrect. Handling of exceptional states as in ServiceCallProcessingUtil.handleServiceCall() is missing
     public Future<RpcResult<Void>> transmitPacket(final TransmitPacketInput input) {
-        final PacketOutInput message = PacketOutConvertor.toPacketOutInput(input, version, deviceContext.getNextXid()
-                .getValue(), datapathId);
-
-        BigInteger connectionID = PRIMARY_CONNECTION;
-        final ConnectionCookie connectionCookie = input.getConnectionCookie();
-        if (connectionCookie != null && connectionCookie.getValue() != null) {
-            connectionID = BigInteger.valueOf(connectionCookie.getValue());
-        }
+        return handleServiceCall(input);
+    }
 
-        return provideConnectionAdapter(connectionID).packetOut(message);
+    @Override
+    protected OfHeader buildRequest(final Xid xid, final TransmitPacketInput input) {
+        return PacketOutConvertor.toPacketOutInput(input, getVersion(), xid.getValue(), getDatapathId());
     }
 }