preparing QueueKeeper and message translation
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / sal / AbstractModelDrivenSwitch.java
1 /**
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.openflowplugin.openflow.md.core.sal;
9
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.inventory.rev130819.NodeContext;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService;
20 import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
21 import org.opendaylight.yangtools.concepts.CompositeObjectRegistration.CompositeObjectRegistrationBuilder;
22 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
23
24 /**
25  * RPC abstract for MD-switch
26  */
27 public abstract class AbstractModelDrivenSwitch implements ModelDrivenSwitch {
28
29     private final InstanceIdentifier<Node> identifier;
30
31     private RoutedRpcRegistration<SalFlowService> flowRegistration;
32
33     private RoutedRpcRegistration<SalGroupService> groupRegistration;
34
35     private RoutedRpcRegistration<SalMeterService> meterRegistration;
36
37     private RoutedRpcRegistration<PacketProcessingService> packetRegistration;
38
39     private final SessionContext sessionContext;
40
41     protected AbstractModelDrivenSwitch(InstanceIdentifier<Node> identifier,SessionContext conductor) {
42         this.identifier = identifier;
43         this.sessionContext = conductor;
44     }
45
46     @Override
47     public final InstanceIdentifier<Node> getIdentifier() {
48         return this.identifier;
49     }
50
51     @Override
52     public CompositeObjectRegistration<ModelDrivenSwitch> register(ProviderContext ctx) {
53         CompositeObjectRegistrationBuilder<ModelDrivenSwitch> builder = CompositeObjectRegistration
54                 .<ModelDrivenSwitch> builderFor(this);
55
56         flowRegistration = ctx.addRoutedRpcImplementation(SalFlowService.class, this);
57         flowRegistration.registerPath(NodeContext.class, getIdentifier());
58         builder.add(flowRegistration);
59
60         //meterRegistration = ctx.addRoutedRpcImplementation(SalMeterService.class, this);
61         //meterRegistration.registerPath(NodeContext.class, getIdentifier());
62         //builder.add(meterRegistration);
63
64         //groupRegistration = ctx.addRoutedRpcImplementation(SalGroupService.class, this);
65         //groupRegistration.registerPath(NodeContext.class, getIdentifier());
66         //builder.add(groupRegistration);
67
68         //packetRegistration = ctx.addRoutedRpcImplementation(PacketProcessingService.class, this);
69         //packetRegistration.registerPath(NodeContext.class, getIdentifier());
70         //builder.add(packetRegistration);
71
72         return builder.toInstance();
73     }
74
75     /**
76      * @return session context 
77      */
78     public SessionContext getSessionContext() {
79         return sessionContext;
80     }
81
82 }