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.group.service.rev130918.SalGroupService;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.OpendaylightGroupStatisticsService;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.OpendaylightMeterStatisticsService;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService;
22 import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
23 import org.opendaylight.yangtools.concepts.CompositeObjectRegistration.CompositeObjectRegistrationBuilder;
24 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
27 * RPC abstract for MD-switch
29 public abstract class AbstractModelDrivenSwitch implements ModelDrivenSwitch {
31 private final InstanceIdentifier<Node> identifier;
33 private RoutedRpcRegistration<SalFlowService> flowRegistration;
35 private RoutedRpcRegistration<SalGroupService> groupRegistration;
37 private RoutedRpcRegistration<SalMeterService> meterRegistration;
39 private RoutedRpcRegistration<PacketProcessingService> packetRegistration;
41 private RoutedRpcRegistration<OpendaylightGroupStatisticsService> groupStatisticsRegistration;
43 private RoutedRpcRegistration<OpendaylightMeterStatisticsService> meterStatisticsRegistration;
45 protected final SessionContext sessionContext;
47 protected AbstractModelDrivenSwitch(InstanceIdentifier<Node> identifier,SessionContext conductor) {
48 this.identifier = identifier;
49 this.sessionContext = conductor;
53 public final InstanceIdentifier<Node> getIdentifier() {
54 return this.identifier;
58 public CompositeObjectRegistration<ModelDrivenSwitch> register(ProviderContext ctx) {
59 CompositeObjectRegistrationBuilder<ModelDrivenSwitch> builder = CompositeObjectRegistration
60 .<ModelDrivenSwitch> builderFor(this);
62 flowRegistration = ctx.addRoutedRpcImplementation(SalFlowService.class, this);
63 flowRegistration.registerPath(NodeContext.class, getIdentifier());
64 builder.add(flowRegistration);
66 meterRegistration = ctx.addRoutedRpcImplementation(SalMeterService.class, this);
67 meterRegistration.registerPath(NodeContext.class, getIdentifier());
68 builder.add(meterRegistration);
70 groupRegistration = ctx.addRoutedRpcImplementation(SalGroupService.class, this);
71 groupRegistration.registerPath(NodeContext.class, getIdentifier());
72 builder.add(groupRegistration);
74 packetRegistration = ctx.addRoutedRpcImplementation(PacketProcessingService.class, this);
75 packetRegistration.registerPath(NodeContext.class, getIdentifier());
76 builder.add(packetRegistration);
78 groupStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightGroupStatisticsService.class, this);
79 groupStatisticsRegistration.registerPath(NodeContext.class, getIdentifier());
80 builder.add(groupStatisticsRegistration);
82 meterStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightMeterStatisticsService.class, this);
83 meterStatisticsRegistration.registerPath(NodeContext.class, getIdentifier());
84 builder.add(meterStatisticsRegistration);
86 return builder.toInstance();
90 * @return session context
92 public SessionContext getSessionContext() {
93 return sessionContext;