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.RoutedRpcRegistration;
11 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
12 import org.opendaylight.openflowplugin.api.openflow.md.ModelDrivenSwitch;
13 import org.opendaylight.openflowplugin.api.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.module.config.rev141015.NodeConfigService;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.SalPortService;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsService;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.OpendaylightQueueStatisticsService;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService;
29 import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
30 import org.opendaylight.yangtools.concepts.CompositeObjectRegistration.CompositeObjectRegistrationBuilder;
31 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
34 * RPC abstract for MD-switch
36 public abstract class AbstractModelDrivenSwitch implements ModelDrivenSwitch {
38 private final InstanceIdentifier<Node> identifier;
40 protected final SessionContext sessionContext;
42 private boolean isEntityOwner = false;
44 protected AbstractModelDrivenSwitch(InstanceIdentifier<Node> identifier,SessionContext conductor) {
45 this.identifier = identifier;
46 this.sessionContext = conductor;
50 public final InstanceIdentifier<Node> getIdentifier() {
51 return this.identifier;
55 public CompositeObjectRegistration<ModelDrivenSwitch> register(RpcProviderRegistry rpcProviderRegistry) {
56 CompositeObjectRegistrationBuilder<ModelDrivenSwitch> builder = CompositeObjectRegistration
57 .<ModelDrivenSwitch> builderFor(this);
59 final RoutedRpcRegistration<SalFlowService> flowRegistration = rpcProviderRegistry.addRoutedRpcImplementation(SalFlowService.class, this);
60 flowRegistration.registerPath(NodeContext.class, getIdentifier());
61 builder.add(flowRegistration);
63 final RoutedRpcRegistration<SalPortService> portRegistration = rpcProviderRegistry.addRoutedRpcImplementation(SalPortService.class, this);
64 portRegistration.registerPath(NodeContext.class, getIdentifier());
65 builder.add(portRegistration);
67 final RoutedRpcRegistration<SalMeterService> meterRegistration = rpcProviderRegistry.addRoutedRpcImplementation(SalMeterService.class, this);
68 meterRegistration.registerPath(NodeContext.class, getIdentifier());
69 builder.add(meterRegistration);
71 final RoutedRpcRegistration<SalGroupService> groupRegistration = rpcProviderRegistry.addRoutedRpcImplementation(SalGroupService.class, this);
72 groupRegistration.registerPath(NodeContext.class, getIdentifier());
73 builder.add(groupRegistration);
75 final RoutedRpcRegistration<SalTableService> tableRegistration = rpcProviderRegistry.addRoutedRpcImplementation(SalTableService.class, this);
76 tableRegistration.registerPath(NodeContext.class, getIdentifier());
77 builder.add(tableRegistration);
79 final RoutedRpcRegistration<PacketProcessingService> packetRegistration = rpcProviderRegistry.addRoutedRpcImplementation(PacketProcessingService.class, this);
80 packetRegistration.registerPath(NodeContext.class, getIdentifier());
81 builder.add(packetRegistration);
83 final RoutedRpcRegistration<OpendaylightFlowStatisticsService> flowStatisticsRegistration = rpcProviderRegistry.addRoutedRpcImplementation(OpendaylightFlowStatisticsService.class, this);
84 flowStatisticsRegistration.registerPath(NodeContext.class, getIdentifier());
85 builder.add(flowStatisticsRegistration);
87 final RoutedRpcRegistration<OpendaylightGroupStatisticsService> groupStatisticsRegistration = rpcProviderRegistry.addRoutedRpcImplementation(OpendaylightGroupStatisticsService.class, this);
88 groupStatisticsRegistration.registerPath(NodeContext.class, getIdentifier());
89 builder.add(groupStatisticsRegistration);
91 final RoutedRpcRegistration<OpendaylightMeterStatisticsService> meterStatisticsRegistration = rpcProviderRegistry.addRoutedRpcImplementation(OpendaylightMeterStatisticsService.class, this);
92 meterStatisticsRegistration.registerPath(NodeContext.class, getIdentifier());
93 builder.add(meterStatisticsRegistration);
95 final RoutedRpcRegistration<OpendaylightPortStatisticsService> portStatisticsRegistration = rpcProviderRegistry.addRoutedRpcImplementation(OpendaylightPortStatisticsService.class, this);
96 portStatisticsRegistration.registerPath(NodeContext.class, getIdentifier());
97 builder.add(portStatisticsRegistration);
99 final RoutedRpcRegistration<NodeConfigService> nodeConfigRegistration = rpcProviderRegistry.addRoutedRpcImplementation(NodeConfigService.class, this);
100 nodeConfigRegistration.registerPath(NodeContext.class, getIdentifier());
101 builder.add(nodeConfigRegistration);
103 final RoutedRpcRegistration<OpendaylightFlowTableStatisticsService> flowTableStatisticsRegistration = rpcProviderRegistry.addRoutedRpcImplementation(OpendaylightFlowTableStatisticsService.class, this);
104 flowTableStatisticsRegistration.registerPath(NodeContext.class, getIdentifier());
105 builder.add(flowTableStatisticsRegistration);
107 final RoutedRpcRegistration<OpendaylightQueueStatisticsService> queueStatisticsRegistration = rpcProviderRegistry.addRoutedRpcImplementation(OpendaylightQueueStatisticsService.class, this);
108 queueStatisticsRegistration.registerPath(NodeContext.class, getIdentifier());
109 builder.add(queueStatisticsRegistration);
111 return builder.build();
115 * @return session context
117 public SessionContext getSessionContext() {
118 return sessionContext;
122 public boolean isEntityOwner() {
123 return isEntityOwner;
127 public void setEntityOwnership(boolean isOwner) {
128 isEntityOwner = isOwner;