Bug 1458 - Migrate to next MD-SAL dataStore API
[openflowplugin.git] / test-provider / src / main / java / org / opendaylight / openflowplugin / test / OpenflowpluginTableFeaturesTestServiceProvider.xtend
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.test
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.controller.sal.binding.api.NotificationProviderService
13 import org.opendaylight.controller.md.sal.binding.api.DataBroker
14
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService
16 //import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalTableService
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInput
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey
23 import org.opendaylight.yangtools.concepts.CompositeObjectRegistration
24 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
25 import org.slf4j.LoggerFactory
26
27
28 class OpenflowpluginTableFeaturesTestServiceProvider implements AutoCloseable, SalTableService {
29
30
31     static val LOG = LoggerFactory.getLogger(OpenflowpluginTableFeaturesTestServiceProvider);
32     
33     @Property
34     RoutedRpcRegistration<SalTableService> tableRegistration;
35         
36
37     @Property
38     NotificationProviderService notificationService;
39
40
41     def void start() {
42         LOG.info("SalTableServiceProvider Started.");
43         
44     }
45
46
47     override close() {
48        LOG.info("SalTableServiceProvider stopped.");
49         tableRegistration.close;
50     }
51     
52       
53     override updateTable(UpdateTableInput input) {
54         LOG.info("updateTable - " + input);
55         return null;
56     }
57     
58     
59     def CompositeObjectRegistration<OpenflowpluginTableFeaturesTestServiceProvider> register(ProviderContext ctx) {
60         val builder = CompositeObjectRegistration
61                 .<OpenflowpluginTableFeaturesTestServiceProvider> builderFor(this);
62
63         tableRegistration = ctx.addRoutedRpcImplementation(SalTableService, this);
64         val nodeIndentifier = InstanceIdentifier.builder(Nodes).child(Node, new NodeKey(new NodeId(OpenflowpluginTestActivator.NODE_ID)));
65         tableRegistration.registerPath(NodeContext, nodeIndentifier.toInstance());
66         builder.add(tableRegistration);
67
68         return builder.toInstance();
69     }
70     
71 }