2 * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.openflowplugin.impl.services.sal;
10 import com.google.common.util.concurrent.ListenableFuture;
11 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
12 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
13 import org.opendaylight.openflowplugin.extension.api.core.extension.ExtensionConverterProvider;
14 import org.opendaylight.openflowplugin.impl.services.multilayer.MultiLayerExperimenterMultipartService;
15 import org.opendaylight.openflowplugin.impl.services.singlelayer.SingleLayerExperimenterMultipartService;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.experimenter.mp.message.service.rev151020.SendExperimenterMpRequest;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.experimenter.mp.message.service.rev151020.SendExperimenterMpRequestInput;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.experimenter.mp.message.service.rev151020.SendExperimenterMpRequestOutput;
19 import org.opendaylight.yangtools.yang.common.RpcResult;
21 public final class SendExperimenterMpRequestImpl implements SendExperimenterMpRequest {
22 private final MultiLayerExperimenterMultipartService multiLayerService;
23 private final SingleLayerExperimenterMultipartService singleLayerService;
25 public SendExperimenterMpRequestImpl(final RequestContextStack requestContextStack,
26 final DeviceContext deviceContext,
27 final ExtensionConverterProvider extensionConverterProvider) {
28 singleLayerService = new SingleLayerExperimenterMultipartService(requestContextStack, deviceContext,
29 extensionConverterProvider);
30 multiLayerService = new MultiLayerExperimenterMultipartService(requestContextStack, deviceContext,
31 extensionConverterProvider);
35 public ListenableFuture<RpcResult<SendExperimenterMpRequestOutput>> invoke(
36 final SendExperimenterMpRequestInput input) {
37 return singleLayerService.canUseSingleLayerSerialization()
38 ? singleLayerService.handleAndReply(input)
39 : multiLayerService.handleAndReply(input);