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 com.google.common.util.concurrent.ListenableFuture;
12 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
13 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
14 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupOutput;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutput;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
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.yangtools.concepts.AbstractObjectRegistration;
28 import org.opendaylight.yangtools.concepts.ObjectRegistration;
29 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
30 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
31 import org.opendaylight.yangtools.yang.common.RpcResult;
32 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory;
35 public class OpenflowpluginGroupTestServiceProvider implements AutoCloseable,
38 private static final Logger LOG = LoggerFactory
39 .getLogger(OpenflowpluginGroupTestServiceProvider.class);
40 private RoutedRpcRegistration<SalGroupService> groupRegistration;
41 private NotificationProviderService notificationService;
44 * Get group registration.
46 * @return {@link #groupRegistration}
48 public RoutedRpcRegistration<SalGroupService> getGroupRegistration() {
49 return groupRegistration;
53 * Set {@link #groupRegistration}.
55 public void setGroupRegistration(
56 final RoutedRpcRegistration<SalGroupService> groupRegistration) {
57 this.groupRegistration = groupRegistration;
61 * Get notification service.
63 * @return {@link #notificationService}
65 public NotificationProviderService getNotificationService() {
66 return notificationService;
70 * Set {@link #notificationService}.
72 public void setNotificationService(
73 final NotificationProviderService notificationService) {
74 this.notificationService = notificationService;
78 OpenflowpluginGroupTestServiceProvider.LOG
79 .info("SalGroupServiceProvider Started.");
85 * @see java.lang.AutoCloseable#close()
88 public void close() throws Exception {
89 OpenflowpluginGroupTestServiceProvider.LOG
90 .info("SalGroupServiceProvide stopped.");
91 groupRegistration.close();
98 * org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918
100 * #addGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.group
101 * .service.rev130918.AddGroupInput)
104 public ListenableFuture<RpcResult<AddGroupOutput>> addGroup(AddGroupInput input) {
105 OpenflowpluginGroupTestServiceProvider.LOG.info("addGroup - {}", input);
113 * org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918
115 * #removeGroup(org.opendaylight.yang.gen.v1.urn.opendaylight
116 * .group.service.rev130918.RemoveGroupInput)
119 public ListenableFuture<RpcResult<RemoveGroupOutput>> removeGroup(
120 RemoveGroupInput input) {
121 OpenflowpluginGroupTestServiceProvider.LOG.info("removeGroup - {}", input);
129 * org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918
131 * #updateGroup(org.opendaylight.yang.gen.v1.urn.opendaylight
132 * .group.service.rev130918.UpdateGroupInput)
135 public ListenableFuture<RpcResult<UpdateGroupOutput>> updateGroup(
136 UpdateGroupInput input) {
137 OpenflowpluginGroupTestServiceProvider.LOG.info("updateGroup - {}", input);
141 public ObjectRegistration<OpenflowpluginGroupTestServiceProvider> register(
142 final RpcProviderRegistry rpcRegistry) {
143 RoutedRpcRegistration<SalGroupService> addRoutedRpcImplementation = rpcRegistry.addRoutedRpcImplementation(
144 SalGroupService.class, this);
145 setGroupRegistration(addRoutedRpcImplementation);
147 InstanceIdentifierBuilder<Nodes> builder1 = InstanceIdentifier
148 .<Nodes>builder(Nodes.class);
150 NodeId nodeId = new NodeId(OpenflowpluginTestActivator.NODE_ID);
151 NodeKey nodeKey = new NodeKey(nodeId);
153 InstanceIdentifierBuilder<Node> nodeIndentifier = builder1
154 .<Node, NodeKey>child(Node.class, nodeKey);
155 InstanceIdentifier<Node> instance = nodeIndentifier.build();
156 groupRegistration.registerPath(NodeContext.class, instance);
157 RoutedRpcRegistration<SalGroupService> groupRegistration1 = this
158 .getGroupRegistration();
159 return new AbstractObjectRegistration<OpenflowpluginGroupTestServiceProvider>(this) {
161 protected void removeRegistration() {
162 groupRegistration1.close();