2 * Copyright (c) 2013 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.openflow.md.core.sal;
10 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
11 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
12 import org.opendaylight.openflowplugin.openflow.md.ModelDrivenSwitch;
13 import org.opendaylight.openflowplugin.openflow.md.core.session.SessionContext;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsService;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.OpendaylightGroupStatisticsService;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.OpendaylightMeterStatisticsService;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsService;
25 import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
26 import org.opendaylight.yangtools.concepts.CompositeObjectRegistration.CompositeObjectRegistrationBuilder;
27 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
30 * RPC abstract for MD-switch
32 public abstract class AbstractModelDrivenSwitch implements ModelDrivenSwitch {
34 private final InstanceIdentifier<Node> identifier;
36 private RoutedRpcRegistration<SalFlowService> flowRegistration;
38 private RoutedRpcRegistration<SalGroupService> groupRegistration;
40 private RoutedRpcRegistration<SalMeterService> meterRegistration;
42 private RoutedRpcRegistration<PacketProcessingService> packetRegistration;
44 private RoutedRpcRegistration<OpendaylightFlowStatisticsService> flowStatisticsRegistration;
46 private RoutedRpcRegistration<OpendaylightGroupStatisticsService> groupStatisticsRegistration;
48 private RoutedRpcRegistration<OpendaylightMeterStatisticsService> meterStatisticsRegistration;
50 private RoutedRpcRegistration<OpendaylightPortStatisticsService> portStatisticsRegistration;
52 private RoutedRpcRegistration<OpendaylightFlowTableStatisticsService> flowTableStatisticsRegistration;
54 protected final SessionContext sessionContext;
56 protected AbstractModelDrivenSwitch(InstanceIdentifier<Node> identifier,SessionContext conductor) {
57 this.identifier = identifier;
58 this.sessionContext = conductor;
62 public final InstanceIdentifier<Node> getIdentifier() {
63 return this.identifier;
67 public CompositeObjectRegistration<ModelDrivenSwitch> register(ProviderContext ctx) {
68 CompositeObjectRegistrationBuilder<ModelDrivenSwitch> builder = CompositeObjectRegistration
69 .<ModelDrivenSwitch> builderFor(this);
71 flowRegistration = ctx.addRoutedRpcImplementation(SalFlowService.class, this);
72 flowRegistration.registerPath(NodeContext.class, getIdentifier());
73 builder.add(flowRegistration);
75 meterRegistration = ctx.addRoutedRpcImplementation(SalMeterService.class, this);
76 meterRegistration.registerPath(NodeContext.class, getIdentifier());
77 builder.add(meterRegistration);
79 groupRegistration = ctx.addRoutedRpcImplementation(SalGroupService.class, this);
80 groupRegistration.registerPath(NodeContext.class, getIdentifier());
81 builder.add(groupRegistration);
83 packetRegistration = ctx.addRoutedRpcImplementation(PacketProcessingService.class, this);
84 packetRegistration.registerPath(NodeContext.class, getIdentifier());
85 builder.add(packetRegistration);
87 flowStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightFlowStatisticsService.class, this);
88 flowStatisticsRegistration.registerPath(NodeContext.class, getIdentifier());
89 builder.add(flowStatisticsRegistration);
91 groupStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightGroupStatisticsService.class, this);
92 groupStatisticsRegistration.registerPath(NodeContext.class, getIdentifier());
93 builder.add(groupStatisticsRegistration);
95 meterStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightMeterStatisticsService.class, this);
96 meterStatisticsRegistration.registerPath(NodeContext.class, getIdentifier());
97 builder.add(meterStatisticsRegistration);
99 portStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightPortStatisticsService.class, this);
100 portStatisticsRegistration.registerPath(NodeContext.class, getIdentifier());
101 builder.add(portStatisticsRegistration);
103 flowTableStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightFlowTableStatisticsService.class, this);
104 flowTableStatisticsRegistration.registerPath(NodeContext.class, getIdentifier());
105 builder.add(flowTableStatisticsRegistration);
107 return builder.toInstance();
111 * @return session context
113 public SessionContext getSessionContext() {
114 return sessionContext;