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
9 package org.opendaylight.openflowplugin.impl.util;
11 import org.opendaylight.openflowplugin.api.OFConstants;
12 import org.opendaylight.openflowplugin.api.openflow.device.TranslatorLibrary;
13 import org.opendaylight.openflowplugin.api.openflow.translator.TranslatorLibrarian;
14 import org.opendaylight.openflowplugin.impl.translator.AggregatedFlowStatisticsTranslator;
15 import org.opendaylight.openflowplugin.impl.translator.FlowRemovedTranslator;
16 import org.opendaylight.openflowplugin.impl.translator.FlowRemovedV10Translator;
17 import org.opendaylight.openflowplugin.impl.translator.PacketReceivedTranslator;
18 import org.opendaylight.openflowplugin.impl.translator.PortUpdateTranslator;
19 import org.opendaylight.openflowplugin.impl.translator.TranslatorKeyFactory;
20 import org.opendaylight.openflowplugin.impl.translator.TranslatorLibraryBuilder;
21 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemoved;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketIn;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortGrouping;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase;
27 public final class TranslatorLibraryUtil {
30 private TranslatorLibraryUtil() {
31 throw new IllegalStateException("This class should not be instantiated");
34 private static final TranslatorKeyFactory OF_13_TRANSLATOR_KEY_FACTORY =
35 new TranslatorKeyFactory(OFConstants.OFP_VERSION_1_3);
36 private static final TranslatorKeyFactory OF_10_TRANSLATOR_KEY_FACTORY =
37 new TranslatorKeyFactory(OFConstants.OFP_VERSION_1_0);
39 public static void injectBasicTranslatorLibrary(final TranslatorLibrarian librarian,
40 final ConvertorExecutor convertorExecutor) {
41 final TranslatorLibrary basicTranslatorLibrary = new TranslatorLibraryBuilder()
42 .addTranslator(OF_13_TRANSLATOR_KEY_FACTORY.createTranslatorKey(PacketIn.class),
43 new PacketReceivedTranslator(convertorExecutor))
44 .addTranslator(OF_13_TRANSLATOR_KEY_FACTORY.createTranslatorKey(PortGrouping.class),
45 new PortUpdateTranslator())
46 .addTranslator(OF_13_TRANSLATOR_KEY_FACTORY.createTranslatorKey(MultipartReplyAggregateCase.class),
47 new AggregatedFlowStatisticsTranslator())
48 .addTranslator(OF_13_TRANSLATOR_KEY_FACTORY.createTranslatorKey(FlowRemoved.class),
49 new FlowRemovedTranslator(convertorExecutor))
50 .addTranslator(OF_10_TRANSLATOR_KEY_FACTORY.createTranslatorKey(PacketIn.class),
51 new PacketReceivedTranslator(convertorExecutor))
52 .addTranslator(OF_10_TRANSLATOR_KEY_FACTORY.createTranslatorKey(PortGrouping.class),
53 new PortUpdateTranslator())
54 .addTranslator(OF_10_TRANSLATOR_KEY_FACTORY.createTranslatorKey(MultipartReplyAggregateCase.class),
55 new AggregatedFlowStatisticsTranslator())
56 .addTranslator(OF_10_TRANSLATOR_KEY_FACTORY.createTranslatorKey(FlowRemoved.class),
57 new FlowRemovedV10Translator(convertorExecutor))
60 librarian.setTranslatorLibrary(basicTranslatorLibrary);