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;
12 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
13 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
14 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
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 * @param groupRegistration
57 public void setGroupRegistration(
58 final RoutedRpcRegistration<SalGroupService> groupRegistration) {
59 this.groupRegistration = groupRegistration;
63 * get notification service
65 * @return {@link #notificationService}
67 public NotificationProviderService getNotificationService() {
68 return notificationService;
72 * set {@link #notificationService}
74 * @param notificationService
76 public void setNotificationService(
77 final NotificationProviderService notificationService) {
78 this.notificationService = notificationService;
82 OpenflowpluginGroupTestServiceProvider.LOG
83 .info("SalGroupServiceProvider Started.");
89 * @see java.lang.AutoCloseable#close()
92 public void close() throws Exception {
93 OpenflowpluginGroupTestServiceProvider.LOG
94 .info("SalGroupServiceProvide stopped.");
95 groupRegistration.close();
102 * org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918
104 * #addGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.group
105 * .service.rev130918.AddGroupInput)
108 public Future<RpcResult<AddGroupOutput>> addGroup(AddGroupInput input) {
109 String plus = ("addGroup - " + input);
110 OpenflowpluginGroupTestServiceProvider.LOG.info(plus);
118 * org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918
120 * #removeGroup(org.opendaylight.yang.gen.v1.urn.opendaylight
121 * .group.service.rev130918.RemoveGroupInput)
124 public Future<RpcResult<RemoveGroupOutput>> removeGroup(
125 RemoveGroupInput input) {
126 String plus = ("removeGroup - " + input);
127 OpenflowpluginGroupTestServiceProvider.LOG.info(plus);
135 * org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918
137 * #updateGroup(org.opendaylight.yang.gen.v1.urn.opendaylight
138 * .group.service.rev130918.UpdateGroupInput)
141 public Future<RpcResult<UpdateGroupOutput>> updateGroup(
142 UpdateGroupInput input) {
143 String plus = ("updateGroup - " + input);
144 OpenflowpluginGroupTestServiceProvider.LOG.info(plus);
150 * @return {@link ObjectRegistration}
152 public ObjectRegistration<OpenflowpluginGroupTestServiceProvider> register(
153 final ProviderContext ctx) {
154 RoutedRpcRegistration<SalGroupService> addRoutedRpcImplementation = ctx
155 .<SalGroupService> addRoutedRpcImplementation(
156 SalGroupService.class, this);
157 setGroupRegistration(addRoutedRpcImplementation);
159 InstanceIdentifierBuilder<Nodes> builder1 = InstanceIdentifier
160 .<Nodes> builder(Nodes.class);
162 NodeId nodeId = new NodeId(OpenflowpluginTestActivator.NODE_ID);
163 NodeKey nodeKey = new NodeKey(nodeId);
165 InstanceIdentifierBuilder<Node> nodeIndentifier = builder1
166 .<Node, NodeKey> child(Node.class, nodeKey);
167 InstanceIdentifier<Node> instance = nodeIndentifier.build();
168 groupRegistration.registerPath(NodeContext.class, instance);
169 RoutedRpcRegistration<SalGroupService> groupRegistration1 = this
170 .getGroupRegistration();
171 return new AbstractObjectRegistration<OpenflowpluginGroupTestServiceProvider>(this) {
173 protected void removeRegistration() {
174 groupRegistration1.close();