Group Test-cases
[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.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 class OpenflowpluginTestServiceProvider implements AutoCloseable, SalFlowService {
28
29
30     static val LOG = LoggerFactory.getLogger(OpenflowpluginTestServiceProvider);
31
32     @Property
33     DataProviderService dataService;
34     
35     @Property
36     RoutedRpcRegistration<SalFlowService> flowRegistration;
37         
38
39     @Property
40     NotificationProviderService notificationService;
41
42
43     def void start() {
44         LOG.info("SalFlowServiceProvider Started.");
45         
46     }
47
48     override close() {
49        LOG.info("SalFlowServiceProvide stopped.");
50         flowRegistration.close;
51     }
52     
53     override addFlow(AddFlowInput input) {
54         LOG.info("addFlow - " + input);
55         return null;
56         
57     }
58     
59     override removeFlow(RemoveFlowInput input) {
60         LOG.info("removeFlow - " + input);
61         return null;
62     }
63     
64     override updateFlow(UpdateFlowInput input) {
65         LOG.info("updateFlow - " + input);
66         return null;
67     }
68     
69     
70     def CompositeObjectRegistration<OpenflowpluginTestServiceProvider> register(ProviderContext ctx) {
71         val builder = CompositeObjectRegistration
72                 .<OpenflowpluginTestServiceProvider> builderFor(this);
73
74         flowRegistration = ctx.addRoutedRpcImplementation(SalFlowService, this);
75         val nodeIndentifier = InstanceIdentifier.builder(Nodes).child(Node, new NodeKey(new NodeId(OpenflowpluginTestActivator.NODE_ID)));
76         flowRegistration.registerPath(NodeContext, nodeIndentifier.toInstance());
77         builder.add(flowRegistration);
78
79         return builder.toInstance();
80     }
81     
82 }
83
84