Merge "Revert "BUG-2613: Migrating Openflow Specific NSF from controller project...
[openflowplugin.git] / test-provider / src / main / java / org / opendaylight / openflowplugin / test / OpenflowpluginMeterTestServiceProvider.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 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInput
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInput
23 import org.opendaylight.yangtools.concepts.CompositeObjectRegistration
24 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
25 import org.slf4j.LoggerFactory
26
27 class OpenflowpluginMeterTestServiceProvider implements AutoCloseable, SalMeterService {
28
29
30     static val LOG = LoggerFactory.getLogger(OpenflowpluginMeterTestServiceProvider);
31
32     @Property
33     DataBroker dataService;
34     
35     @Property
36     RoutedRpcRegistration<SalMeterService> meterRegistration;
37         
38
39     @Property
40     NotificationProviderService notificationService;
41
42
43     def void start() {
44         LOG.info("SalMeterServiceProvider Started.");
45         
46     }
47
48
49     override close() {
50        LOG.info("SalMeterServiceProvide stopped.");
51         meterRegistration.close;
52     }
53     
54     override addMeter(AddMeterInput input) {
55         LOG.info("addMeter - " + input);
56         return null;
57         
58     }
59     
60     override removeMeter(RemoveMeterInput input) {
61         LOG.info("removeMeter - " + input);
62         return null;
63     }
64     
65     override updateMeter(UpdateMeterInput input) {
66         LOG.info("updateMeter - " + input);
67         return null;
68     }
69     
70     
71     def CompositeObjectRegistration<OpenflowpluginMeterTestServiceProvider> register(ProviderContext ctx) {
72         val builder = CompositeObjectRegistration
73                 .<OpenflowpluginMeterTestServiceProvider> builderFor(this);
74
75         meterRegistration = ctx.addRoutedRpcImplementation(SalMeterService, this);
76         val nodeIndentifier = InstanceIdentifier.builder(Nodes).child(Node, new NodeKey(new NodeId(OpenflowpluginTestActivator.NODE_ID)));
77         meterRegistration.registerPath(NodeContext, nodeIndentifier.toInstance());
78         builder.add(meterRegistration);
79         return builder.toInstance();
80     }
81     
82 }
83
84