Added test-provider project.
[openflowplugin.git] / test-provider / src / main / java / org / opendaylight / openflowplugin / test / OpenflowpluginTestServiceProvider.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.sal.binding.api.data.DataProviderService
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext
19 import org.opendaylight.yangtools.concepts.CompositeObjectRegistration
20 import org.opendaylight.yangtools.concepts.Registration
21 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
22 import org.opendaylight.yangtools.yang.binding.NotificationListener
23 import org.slf4j.LoggerFactory
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId
28
29 class OpenflowpluginTestServiceProvider implements AutoCloseable, SalFlowService {
30
31
32     static val LOG = LoggerFactory.getLogger(OpenflowpluginTestServiceProvider);
33
34     @Property
35     DataProviderService dataService;
36     
37     @Property
38     RoutedRpcRegistration<SalFlowService> flowRegistration;
39         
40
41     @Property
42     NotificationProviderService notificationService;
43
44
45     def void start() {
46         LOG.info("SalFlowServiceProvider Started.");
47         
48     }
49
50
51     override close() {
52        LOG.info("SalFlowServiceProvide stopped.");
53         flowRegistration.close;
54     }
55     
56     override addFlow(AddFlowInput input) {
57         LOG.info("addFlow - " + input);
58         return null;
59         
60     }
61     
62     override removeFlow(RemoveFlowInput input) {
63         LOG.info("removeFlow - " + input);
64         return null;
65     }
66     
67     override updateFlow(UpdateFlowInput input) {
68         LOG.info("updateFlow - " + input);
69         return null;
70     }
71     
72     
73     def CompositeObjectRegistration<OpenflowpluginTestServiceProvider> register(ProviderContext ctx) {
74         val builder = CompositeObjectRegistration
75                 .<OpenflowpluginTestServiceProvider> builderFor(this);
76
77         flowRegistration = ctx.addRoutedRpcImplementation(SalFlowService, this);
78         val nodeIndentifier = InstanceIdentifier.builder(Nodes).child(Node, new NodeKey(new NodeId(OpenflowpluginTestActivator.NODE_ID)));
79         flowRegistration.registerPath(NodeContext, nodeIndentifier.toInstance());
80         builder.add(flowRegistration);
81
82         return builder.toInstance();
83     }
84     
85 }
86
87