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
8 package org.opendaylight.openflowplugin.test;
10 import com.google.common.collect.ImmutableSet;
11 import com.google.common.util.concurrent.ListenableFuture;
12 import org.opendaylight.mdsal.binding.api.DataBroker;
13 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
14 import org.opendaylight.mdsal.binding.api.RpcProviderService;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutput;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutput;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutput;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
26 import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
27 import org.opendaylight.yangtools.concepts.ObjectRegistration;
28 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
29 import org.opendaylight.yangtools.yang.common.RpcResult;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
33 public class OpenflowpluginTestServiceProvider implements AutoCloseable,
36 private static final Logger LOG = LoggerFactory
37 .getLogger(OpenflowpluginTestServiceProvider.class);
39 private final DataBroker dataService;
40 private ObjectRegistration<SalFlowService> flowRegistration;
41 private final NotificationPublishService notificationProviderService;
43 public OpenflowpluginTestServiceProvider(DataBroker dataService,
44 NotificationPublishService notificationProviderService) {
45 this.dataService = dataService;
46 this.notificationProviderService = notificationProviderService;
52 * @return {@link #dataService}
54 public DataBroker getDataService() {
59 * Get flow registration.
61 * @return {@link #flowRegistration}
63 public ObjectRegistration<SalFlowService> getFlowRegistration() {
64 return flowRegistration;
68 * Set {@link #flowRegistration}.
70 public void setFlowRegistration(final ObjectRegistration<SalFlowService> flowRegistration) {
71 this.flowRegistration = flowRegistration;
75 * Get notification service.
77 * @return {@link #notificationProviderService}
79 public NotificationPublishService getNotificationService() {
80 return notificationProviderService;
86 * @see java.lang.AutoCloseable#close()
89 public void close() throws Exception {
90 OpenflowpluginTestServiceProvider.LOG
91 .info("SalFlowServiceProvide stopped.");
92 flowRegistration.close();
99 * org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.
101 * #addFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.
102 * service.rev130819.AddFlowInput)
105 public ListenableFuture<RpcResult<AddFlowOutput>> addFlow(AddFlowInput input) {
106 OpenflowpluginTestServiceProvider.LOG.info("addFlow - {}", input);
114 * org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.
116 * #removeFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow
117 * .service.rev130819.RemoveFlowInput)
120 public ListenableFuture<RpcResult<RemoveFlowOutput>> removeFlow(RemoveFlowInput input) {
121 OpenflowpluginTestServiceProvider.LOG.info("removeFlow - {}", input);
129 * org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.
131 * #updateFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow
132 * .service.rev130819.UpdateFlowInput)
135 public ListenableFuture<RpcResult<UpdateFlowOutput>> updateFlow(UpdateFlowInput input) {
136 OpenflowpluginTestServiceProvider.LOG.info("updateFlow - {}", input);
140 public ObjectRegistration<OpenflowpluginTestServiceProvider> register(RpcProviderService rpcRegistry) {
141 setFlowRegistration(rpcRegistry.registerRpcImplementation(SalFlowService.class, this, ImmutableSet.of(
142 InstanceIdentifier.create(Nodes.class)
143 .child(Node.class, new NodeKey(new NodeId(OpenflowpluginTestActivator.NODE_ID))))));
145 return new AbstractObjectRegistration<OpenflowpluginTestServiceProvider>(this) {
147 protected void removeRegistration() {
148 flowRegistration.close();