Eliminate the use of CompositeObjectRegistration
[openflowplugin.git] / test-provider / src / main / java / org / opendaylight / openflowplugin / test / OpenflowpluginTestServiceProvider.java
index ec67835b82f8cc184188086fb601c415ed959000..1464509c06d7af4566394f1f4eb83b9b8dcf87e6 100644 (file)
@@ -25,8 +25,8 @@ 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;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration.CompositeObjectRegistrationBuilder;
+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;
@@ -166,13 +166,10 @@ public class OpenflowpluginTestServiceProvider implements AutoCloseable,
 
     /**
      * @param ctx
-     * @return {@link CompositeObjectRegistrationBuilder #toInstance()}
+     * @return {@link ObjectRegistration}
      */
-    public CompositeObjectRegistration<OpenflowpluginTestServiceProvider> register(
+    public ObjectRegistration<OpenflowpluginTestServiceProvider> register(
             final ProviderContext ctx) {
-        CompositeObjectRegistrationBuilder<OpenflowpluginTestServiceProvider> builder = CompositeObjectRegistration
-                .<OpenflowpluginTestServiceProvider> builderFor(this);
-
         RoutedRpcRegistration<SalFlowService> addRoutedRpcImplementation = ctx
                 .<SalFlowService> addRoutedRpcImplementation(
                         SalFlowService.class, this);
@@ -194,8 +191,11 @@ public class OpenflowpluginTestServiceProvider implements AutoCloseable,
 
         RoutedRpcRegistration<SalFlowService> flowRegistration2 = getFlowRegistration();
 
-        builder.add(flowRegistration2);
-
-        return builder.build();
+        return new AbstractObjectRegistration<OpenflowpluginTestServiceProvider>(this) {
+            @Override
+            protected void removeRegistration() {
+                flowRegistration2.close();
+            }
+        };
     }
 }