Search in sources :

Example 1 with BundleMessageDataInjector

use of org.opendaylight.openflowplugin.extension.api.BundleMessageDataInjector in project openflowplugin by opendaylight.

the class SalExperimenterMessageServiceImpl method buildRequest.

@Override
protected OfHeader buildRequest(Xid xid, SendExperimenterInput input) throws ServiceException {
    final TypeVersionKey key = new TypeVersionKey(input.getExperimenterMessageOfChoice().getImplementedInterface(), getVersion());
    final ConverterMessageToOFJava<ExperimenterMessageOfChoice, ExperimenterDataOfChoice> messageConverter = extensionConverterProvider.getMessageConverter(key);
    if (messageConverter == null) {
        throw new ServiceException(new ConverterNotFoundException(key.toString()));
    }
    final ExperimenterInputBuilder experimenterInputBld;
    if (messageConverter instanceof BundleMessageDataInjector) {
        ((BundleMessageDataInjector) messageConverter).setNode(input.getNode());
        ((BundleMessageDataInjector) messageConverter).setXid(xid.getValue());
    }
    try {
        experimenterInputBld = new ExperimenterInputBuilder().setExperimenter(messageConverter.getExperimenterId()).setExpType(messageConverter.getType()).setExperimenterDataOfChoice(messageConverter.convert(input.getExperimenterMessageOfChoice())).setVersion(getVersion()).setXid(xid.getValue());
    } catch (ConversionException e) {
        throw new ServiceException(e);
    }
    return experimenterInputBld.build();
}
Also used : TypeVersionKey(org.opendaylight.openflowplugin.extension.api.TypeVersionKey) ConversionException(org.opendaylight.openflowplugin.extension.api.exception.ConversionException) ExperimenterInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder) ServiceException(org.opendaylight.openflowplugin.impl.services.util.ServiceException) ExperimenterMessageOfChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.experimenter.types.rev151020.experimenter.core.message.ExperimenterMessageOfChoice) ConverterNotFoundException(org.opendaylight.openflowplugin.extension.api.exception.ConverterNotFoundException) BundleMessageDataInjector(org.opendaylight.openflowplugin.extension.api.BundleMessageDataInjector) ExperimenterDataOfChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice)

Aggregations

BundleMessageDataInjector (org.opendaylight.openflowplugin.extension.api.BundleMessageDataInjector)1 TypeVersionKey (org.opendaylight.openflowplugin.extension.api.TypeVersionKey)1 ConversionException (org.opendaylight.openflowplugin.extension.api.exception.ConversionException)1 ConverterNotFoundException (org.opendaylight.openflowplugin.extension.api.exception.ConverterNotFoundException)1 ServiceException (org.opendaylight.openflowplugin.impl.services.util.ServiceException)1 ExperimenterInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder)1 ExperimenterDataOfChoice (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice)1 ExperimenterMessageOfChoice (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.experimenter.types.rev151020.experimenter.core.message.ExperimenterMessageOfChoice)1