2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.openflowplugin.test;
11 import java.util.concurrent.Future;
13 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
14 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
15 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInput;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutput;
24 import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
25 import org.opendaylight.yangtools.concepts.CompositeObjectRegistration.CompositeObjectRegistrationBuilder;
26 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
27 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
28 import org.opendaylight.yangtools.yang.common.RpcResult;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
32 public class OpenflowpluginTableFeaturesTestServiceProvider implements
33 AutoCloseable, SalTableService {
35 private final static Logger LOG = LoggerFactory
36 .getLogger(OpenflowpluginTableFeaturesTestServiceProvider.class);
37 private RoutedRpcRegistration<SalTableService> tableRegistration;
38 private NotificationProviderService notificationService;
41 * get table registration
43 * @return {@link #tableRegistration}
45 public RoutedRpcRegistration<SalTableService> getTableRegistration() {
46 return this.tableRegistration;
50 * set {@link #tableRegistration}
52 * @param tableRegistration
54 public void setTableRegistration(
55 final RoutedRpcRegistration<SalTableService> tableRegistration) {
56 this.tableRegistration = tableRegistration;
60 * get notification service
62 * @return {@link #notificationService}
64 public NotificationProviderService getNotificationService() {
65 return this.notificationService;
69 * set {@link #notificationService}
71 * @param notificationService
73 public void setNotificationService(
74 final NotificationProviderService notificationService) {
75 this.notificationService = notificationService;
79 OpenflowpluginTableFeaturesTestServiceProvider.LOG
80 .info("SalTableServiceProvider Started.");
86 * @see java.lang.AutoCloseable#close()
89 public void close() throws Exception {
90 OpenflowpluginTableFeaturesTestServiceProvider.LOG
91 .info("SalTableServiceProvider stopped.");
92 tableRegistration.close();
99 * org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026
101 * #updateTable(org.opendaylight.yang.gen.v1.urn.opendaylight
102 * .table.service.rev131026.UpdateTableInput)
105 public Future<RpcResult<UpdateTableOutput>> updateTable(
106 UpdateTableInput input) {
107 String plus = ("updateTable - " + input);
108 OpenflowpluginTableFeaturesTestServiceProvider.LOG.info(plus);
114 * @return {@link CompositeObjectRegistrationBuilder #toInstance()}
116 public CompositeObjectRegistration<OpenflowpluginTableFeaturesTestServiceProvider> register(
117 final ProviderContext ctx) {
118 CompositeObjectRegistrationBuilder<OpenflowpluginTableFeaturesTestServiceProvider> builder = CompositeObjectRegistration
119 .<OpenflowpluginTableFeaturesTestServiceProvider> builderFor(this);
121 RoutedRpcRegistration<SalTableService> addRoutedRpcImplementation = ctx
122 .<SalTableService> addRoutedRpcImplementation(
123 SalTableService.class, this);
125 setTableRegistration(addRoutedRpcImplementation);
127 InstanceIdentifierBuilder<Nodes> builder1 = InstanceIdentifier
128 .<Nodes> builder(Nodes.class);
130 NodeId nodeId = new NodeId(OpenflowpluginTestActivator.NODE_ID);
131 NodeKey nodeKey = new NodeKey(nodeId);
133 InstanceIdentifierBuilder<Node> nodeIndentifier = builder1
134 .<Node, NodeKey> child(Node.class, nodeKey);
136 InstanceIdentifier<Node> instance = nodeIndentifier.build();
138 tableRegistration.registerPath(NodeContext.class, instance);
140 RoutedRpcRegistration<SalTableService> tableRegistration1 = this
141 .getTableRegistration();
143 builder.add(tableRegistration1);
145 return builder.build();