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 String plus = "addGroup - " + input;
106 OpenflowpluginGroupTestServiceProvider.LOG.info(plus);
114 * org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918
116 * #removeGroup(org.opendaylight.yang.gen.v1.urn.opendaylight
117 * .group.service.rev130918.RemoveGroupInput)
120 public ListenableFuture<RpcResult<RemoveGroupOutput>> removeGroup(
121 RemoveGroupInput input) {
122 String plus = "removeGroup - " + input;
123 OpenflowpluginGroupTestServiceProvider.LOG.info(plus);
131 * org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918
133 * #updateGroup(org.opendaylight.yang.gen.v1.urn.opendaylight
134 * .group.service.rev130918.UpdateGroupInput)
137 public ListenableFuture<RpcResult<UpdateGroupOutput>> updateGroup(
138 UpdateGroupInput input) {
139 String plus = "updateGroup - " + input;
140 OpenflowpluginGroupTestServiceProvider.LOG.info(plus);
144 public ObjectRegistration<OpenflowpluginGroupTestServiceProvider> register(
145 final RpcProviderRegistry rpcRegistry) {
146 RoutedRpcRegistration<SalGroupService> addRoutedRpcImplementation = rpcRegistry.addRoutedRpcImplementation(
147 SalGroupService.class, this);
148 setGroupRegistration(addRoutedRpcImplementation);
150 InstanceIdentifierBuilder<Nodes> builder1 = InstanceIdentifier
151 .<Nodes>builder(Nodes.class);
153 NodeId nodeId = new NodeId(OpenflowpluginTestActivator.NODE_ID);
154 NodeKey nodeKey = new NodeKey(nodeId);
156 InstanceIdentifierBuilder<Node> nodeIndentifier = builder1
157 .<Node, NodeKey>child(Node.class, nodeKey);
158 InstanceIdentifier<Node> instance = nodeIndentifier.build();
159 groupRegistration.registerPath(NodeContext.class, instance);
160 RoutedRpcRegistration<SalGroupService> groupRegistration1 = this
161 .getGroupRegistration();
162 return new AbstractObjectRegistration<OpenflowpluginGroupTestServiceProvider>(this) {
164 protected void removeRegistration() {
165 groupRegistration1.close();