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.group.service.rev130918.SalGroupService;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.OpendaylightGroupStatisticsService;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.OpendaylightMeterStatisticsService;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService;
23 import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
24 import org.opendaylight.yangtools.concepts.CompositeObjectRegistration.CompositeObjectRegistrationBuilder;
25 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
28 * RPC abstract for MD-switch
30 public abstract class AbstractModelDrivenSwitch implements ModelDrivenSwitch {
32 private final InstanceIdentifier<Node> identifier;
34 private RoutedRpcRegistration<SalFlowService> flowRegistration;
36 private RoutedRpcRegistration<SalGroupService> groupRegistration;
38 private RoutedRpcRegistration<SalMeterService> meterRegistration;
40 private RoutedRpcRegistration<PacketProcessingService> packetRegistration;
42 private RoutedRpcRegistration<OpendaylightFlowStatisticsService> flowStatisticsRegistration;
44 private RoutedRpcRegistration<OpendaylightGroupStatisticsService> groupStatisticsRegistration;
46 private RoutedRpcRegistration<OpendaylightMeterStatisticsService> meterStatisticsRegistration;
48 protected final SessionContext sessionContext;
50 protected AbstractModelDrivenSwitch(InstanceIdentifier<Node> identifier,SessionContext conductor) {
51 this.identifier = identifier;
52 this.sessionContext = conductor;
56 public final InstanceIdentifier<Node> getIdentifier() {
57 return this.identifier;
61 public CompositeObjectRegistration<ModelDrivenSwitch> register(ProviderContext ctx) {
62 CompositeObjectRegistrationBuilder<ModelDrivenSwitch> builder = CompositeObjectRegistration
63 .<ModelDrivenSwitch> builderFor(this);
65 flowRegistration = ctx.addRoutedRpcImplementation(SalFlowService.class, this);
66 flowRegistration.registerPath(NodeContext.class, getIdentifier());
67 builder.add(flowRegistration);
69 meterRegistration = ctx.addRoutedRpcImplementation(SalMeterService.class, this);
70 meterRegistration.registerPath(NodeContext.class, getIdentifier());
71 builder.add(meterRegistration);
73 groupRegistration = ctx.addRoutedRpcImplementation(SalGroupService.class, this);
74 groupRegistration.registerPath(NodeContext.class, getIdentifier());
75 builder.add(groupRegistration);
77 packetRegistration = ctx.addRoutedRpcImplementation(PacketProcessingService.class, this);
78 packetRegistration.registerPath(NodeContext.class, getIdentifier());
79 builder.add(packetRegistration);
81 flowStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightFlowStatisticsService.class, this);
82 flowStatisticsRegistration.registerPath(NodeContext.class, getIdentifier());
83 builder.add(flowStatisticsRegistration);
85 groupStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightGroupStatisticsService.class, this);
86 groupStatisticsRegistration.registerPath(NodeContext.class, getIdentifier());
87 builder.add(groupStatisticsRegistration);
89 meterStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightMeterStatisticsService.class, this);
90 meterStatisticsRegistration.registerPath(NodeContext.class, getIdentifier());
91 builder.add(meterStatisticsRegistration);
93 return builder.toInstance();
97 * @return session context
99 public SessionContext getSessionContext() {
100 return sessionContext;