Initial integration with MD-SAL
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / sal / AbstractModelDrivenSwitch.java
1 package org.opendaylight.openflowplugin.openflow.md.core.sal;
2
3 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
4 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
5 import org.opendaylight.openflowplugin.openflow.md.ModelDrivenSwitch;
6 import org.opendaylight.openflowplugin.openflow.md.core.ConnectionConductor;
7 import org.opendaylight.openflowplugin.openflow.md.core.session.SessionContext;
8 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
9 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService;
10 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService;
14 import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
15 import org.opendaylight.yangtools.concepts.CompositeObjectRegistration.CompositeObjectRegistrationBuilder;
16 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
17 import org.opendaylight.yangtools.yang.binding.RpcService;
18
19 public abstract class AbstractModelDrivenSwitch implements ModelDrivenSwitch {
20
21     private final InstanceIdentifier<Node> identifier;
22
23     private RoutedRpcRegistration<SalFlowService> flowRegistration;
24
25     private RoutedRpcRegistration<SalGroupService> groupRegistration;
26
27     private RoutedRpcRegistration<SalMeterService> meterRegistration;
28
29     private RoutedRpcRegistration<PacketProcessingService> packetRegistration;
30
31     private final SessionContext sessionContext;
32
33     protected AbstractModelDrivenSwitch(InstanceIdentifier<Node> identifier,SessionContext conductor) {
34         this.identifier = identifier;
35         this.sessionContext = conductor;
36     }
37
38     @Override
39     public final InstanceIdentifier<Node> getIdentifier() {
40         return this.identifier;
41     }
42
43     @Override
44     public CompositeObjectRegistration<ModelDrivenSwitch> register(ProviderContext ctx) {
45         CompositeObjectRegistrationBuilder<ModelDrivenSwitch> builder = CompositeObjectRegistration
46                 .<ModelDrivenSwitch> builderFor(this);
47
48         flowRegistration = ctx.addRoutedRpcImplementation(SalFlowService.class, this);
49         flowRegistration.registerPath(NodeContext.class, getIdentifier());
50         builder.add(flowRegistration);
51
52         //meterRegistration = ctx.addRoutedRpcImplementation(SalMeterService.class, this);
53         //meterRegistration.registerPath(NodeContext.class, getIdentifier());
54         //builder.add(meterRegistration);
55
56         //groupRegistration = ctx.addRoutedRpcImplementation(SalGroupService.class, this);
57         //groupRegistration.registerPath(NodeContext.class, getIdentifier());
58         //builder.add(groupRegistration);
59
60         //packetRegistration = ctx.addRoutedRpcImplementation(PacketProcessingService.class, this);
61         //packetRegistration.registerPath(NodeContext.class, getIdentifier());
62         //builder.add(packetRegistration);
63
64         return builder.toInstance();
65     }
66
67     public SessionContext getConductor() {
68         return sessionContext;
69     }
70
71 }