X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=test-provider%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Ftest%2FOpenflowpluginTestServiceProvider.java;h=00d76392440e6d1757d55720eafdbcb0ba22f9b9;hb=0267562f3c2be39373f289008a367776dd325ff8;hp=10ee6a4d0dd0ceafdc4286e98c2feec3d2b28240;hpb=961fdf1e8294c9084420fe8f3ef21549710b0af3;p=openflowplugin.git diff --git a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestServiceProvider.java b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestServiceProvider.java index 10ee6a4d0d..00d7639244 100644 --- a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestServiceProvider.java +++ b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestServiceProvider.java @@ -1,18 +1,17 @@ -/** +/* * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.test; +import com.google.common.collect.ImmutableSet; import com.google.common.util.concurrent.ListenableFuture; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.RpcProviderService; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput; @@ -20,7 +19,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.Remo import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; @@ -28,23 +26,20 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N import org.opendaylight.yangtools.concepts.AbstractObjectRegistration; import org.opendaylight.yangtools.concepts.ObjectRegistration; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder; import org.opendaylight.yangtools.yang.common.RpcResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class OpenflowpluginTestServiceProvider implements AutoCloseable, - SalFlowService { - - private static final Logger LOG = LoggerFactory - .getLogger(OpenflowpluginTestServiceProvider.class); +public class OpenflowpluginTestServiceProvider implements AutoCloseable, SalFlowService { + private static final Logger LOG = LoggerFactory.getLogger(OpenflowpluginTestServiceProvider.class); private final DataBroker dataService; - private RoutedRpcRegistration flowRegistration; - private final NotificationProviderService notificationProviderService; + private final NotificationPublishService notificationProviderService; + + private ObjectRegistration flowRegistration = null; - public OpenflowpluginTestServiceProvider(DataBroker dataService, - NotificationProviderService notificationProviderService) { + public OpenflowpluginTestServiceProvider(final DataBroker dataService, + final NotificationPublishService notificationProviderService) { this.dataService = dataService; this.notificationProviderService = notificationProviderService; } @@ -63,15 +58,14 @@ public class OpenflowpluginTestServiceProvider implements AutoCloseable, * * @return {@link #flowRegistration} */ - public RoutedRpcRegistration getFlowRegistration() { + public ObjectRegistration getFlowRegistration() { return flowRegistration; } /** * Set {@link #flowRegistration}. */ - public void setFlowRegistration( - final RoutedRpcRegistration flowRegistration) { + public void setFlowRegistration(final ObjectRegistration flowRegistration) { this.flowRegistration = flowRegistration; } @@ -80,7 +74,7 @@ public class OpenflowpluginTestServiceProvider implements AutoCloseable, * * @return {@link #notificationProviderService} */ - public NotificationProviderService getNotificationService() { + public NotificationPublishService getNotificationService() { return notificationProviderService; } @@ -90,7 +84,7 @@ public class OpenflowpluginTestServiceProvider implements AutoCloseable, * @see java.lang.AutoCloseable#close() */ @Override - public void close() throws Exception { + public void close() { OpenflowpluginTestServiceProvider.LOG .info("SalFlowServiceProvide stopped."); flowRegistration.close(); @@ -106,9 +100,8 @@ public class OpenflowpluginTestServiceProvider implements AutoCloseable, * service.rev130819.AddFlowInput) */ @Override - public ListenableFuture> addFlow(AddFlowInput input) { - String plus = "addFlow - " + input; - OpenflowpluginTestServiceProvider.LOG.info(plus); + public ListenableFuture> addFlow(final AddFlowInput input) { + OpenflowpluginTestServiceProvider.LOG.info("addFlow - {}", input); return null; } @@ -122,9 +115,8 @@ public class OpenflowpluginTestServiceProvider implements AutoCloseable, * .service.rev130819.RemoveFlowInput) */ @Override - public ListenableFuture> removeFlow(RemoveFlowInput input) { - String plus = "removeFlow - " + input; - OpenflowpluginTestServiceProvider.LOG.info(plus); + public ListenableFuture> removeFlow(final RemoveFlowInput input) { + OpenflowpluginTestServiceProvider.LOG.info("removeFlow - {}", input); return null; } @@ -138,37 +130,20 @@ public class OpenflowpluginTestServiceProvider implements AutoCloseable, * .service.rev130819.UpdateFlowInput) */ @Override - public ListenableFuture> updateFlow(UpdateFlowInput input) { - String plus = "updateFlow - " + input; - OpenflowpluginTestServiceProvider.LOG.info(plus); + public ListenableFuture> updateFlow(final UpdateFlowInput input) { + OpenflowpluginTestServiceProvider.LOG.info("updateFlow - {}", input); return null; } - public ObjectRegistration register(RpcProviderRegistry rpcRegistry) { - RoutedRpcRegistration addRoutedRpcImplementation = - rpcRegistry.addRoutedRpcImplementation(SalFlowService.class, this); - - setFlowRegistration(addRoutedRpcImplementation); - - InstanceIdentifierBuilder builderII = InstanceIdentifier - .builder(Nodes.class); - - NodeId nodeId = new NodeId(OpenflowpluginTestActivator.NODE_ID); - NodeKey nodeKey = new NodeKey(nodeId); - - InstanceIdentifierBuilder nodeIdentifier = builderII - .child(Node.class, nodeKey); - - InstanceIdentifier instance = nodeIdentifier.build(); - - flowRegistration.registerPath(NodeContext.class, instance); - - RoutedRpcRegistration flowRegistration2 = getFlowRegistration(); + public ObjectRegistration register(final RpcProviderService rpcRegistry) { + setFlowRegistration(rpcRegistry.registerRpcImplementation(SalFlowService.class, this, ImmutableSet.of( + InstanceIdentifier.create(Nodes.class) + .child(Node.class, new NodeKey(new NodeId(OpenflowpluginTestActivator.NODE_ID)))))); - return new AbstractObjectRegistration(this) { + return new AbstractObjectRegistration<>(this) { @Override protected void removeRegistration() { - flowRegistration2.close(); + flowRegistration.close(); } }; }