2 * Copyright (c) 2015 Cisco Systems, Inc. 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;
10 import java.util.concurrent.Future;
11 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
12 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
13 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
14 import org.opendaylight.openflowplugin.extension.api.ConvertorMessageToOFJava;
15 import org.opendaylight.openflowplugin.extension.api.ExtensionConverterProviderKeeper;
16 import org.opendaylight.openflowplugin.extension.api.TypeVersionKey;
17 import org.opendaylight.openflowplugin.extension.api.exception.ConversionException;
18 import org.opendaylight.openflowplugin.extension.api.exception.ConverterNotFoundException;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.experimenter.message.service.rev151020.SalExperimenterMessageService;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.experimenter.message.service.rev151020.SendExperimenterInput;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.experimenter.types.rev151020.experimenter.core.message.ExperimenterMessageOfChoice;
25 import org.opendaylight.yangtools.yang.common.RpcResult;
28 public class SalExperimenterMessageServiceImpl extends AbstractVoidService<SendExperimenterInput> implements SalExperimenterMessageService {
30 public SalExperimenterMessageServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
31 super(requestContextStack, deviceContext);
35 protected OfHeader buildRequest(Xid xid, SendExperimenterInput input) throws ConversionException {
36 final TypeVersionKey key = new TypeVersionKey(input.getExperimenterMessageOfChoice().getImplementedInterface(), getVersion());
37 final ConvertorMessageToOFJava<ExperimenterMessageOfChoice, ExperimenterDataOfChoice> messageConverter =
38 ((ExtensionConverterProviderKeeper) getDeviceContext())
39 .getExtensionConverterProvider().getMessageConverter(key);
41 if (messageConverter == null) {
42 throw new ConverterNotFoundException(key.toString());
45 final ExperimenterInputBuilder experimenterInputBld = new ExperimenterInputBuilder()
46 .setExperimenter(messageConverter.getExperimenterId())
47 .setExpType(messageConverter.getType())
48 .setExperimenterDataOfChoice(messageConverter.convert(input.getExperimenterMessageOfChoice()))
49 .setVersion(getVersion())
50 .setXid(xid.getValue());
51 return experimenterInputBld.build();
55 public Future<RpcResult<Void>> sendExperimenter(SendExperimenterInput input) {
56 return handleServiceCall(input);