From 82b7fdcd16dd0c71265d5f7560c3f039beedcd5d Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Sat, 10 Feb 2024 13:56:22 +0100 Subject: [PATCH] Eliminate blueprint from test-extension This is a simple component, migrate it. JIRA: OPNFLWPLUG-1112 Change-Id: I3fccec39289314aa23bc906cc57b2138f408bf81 Signed-off-by: Robert Varga --- extension/test-extension/pom.xml | 14 +++++++ .../openflowplugin/extension/test/Test.java | 40 +++++++++++++++---- .../OSGI-INF/blueprint/test-extension.xml | 14 ------- 3 files changed, 46 insertions(+), 22 deletions(-) delete mode 100644 extension/test-extension/src/main/resources/OSGI-INF/blueprint/test-extension.xml diff --git a/extension/test-extension/pom.xml b/extension/test-extension/pom.xml index 6fbaa66b8a..86bbbb677a 100644 --- a/extension/test-extension/pom.xml +++ b/extension/test-extension/pom.xml @@ -12,6 +12,16 @@ bundle + + com.guicedee.services + javax.inject + true + + + jakarta.annotation + jakarta.annotation-api + true + org.opendaylight.openflowplugin openflowplugin-extension-nicira @@ -59,6 +69,10 @@ org.opendaylight.infrautils infrautils-util + + org.osgi + org.osgi.service.component.annotations + diff --git a/extension/test-extension/src/main/java/org/opendaylight/openflowplugin/extension/test/Test.java b/extension/test-extension/src/main/java/org/opendaylight/openflowplugin/extension/test/Test.java index f4b3c29119..696afcc339 100644 --- a/extension/test-extension/src/main/java/org/opendaylight/openflowplugin/extension/test/Test.java +++ b/extension/test-extension/src/main/java/org/opendaylight/openflowplugin/extension/test/Test.java @@ -9,7 +9,12 @@ package org.opendaylight.openflowplugin.extension.test; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; +import javax.annotation.PreDestroy; +import javax.inject.Inject; +import javax.inject.Singleton; import org.opendaylight.infrautils.utils.concurrent.LoggingFutures; +import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry; +import org.opendaylight.mdsal.binding.api.RpcProviderService; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtlBuilder; @@ -38,9 +43,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionRegLoadNodesNodeTableFlowApplyActionsCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.NxRegLoadBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.nx.reg.load.DstBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.test.rev130819.TestFlow; import org.opendaylight.yang.gen.v1.urn.opendaylight.test.rev130819.TestFlowInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.test.rev130819.TestFlowOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.test.rev130819.TestService; +import org.opendaylight.yangtools.concepts.Registration; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.util.BindingMap; import org.opendaylight.yangtools.yang.common.RpcResult; @@ -49,6 +55,10 @@ import org.opendaylight.yangtools.yang.common.Uint16; import org.opendaylight.yangtools.yang.common.Uint32; import org.opendaylight.yangtools.yang.common.Uint64; import org.opendaylight.yangtools.yang.common.Uint8; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.component.annotations.Reference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -57,13 +67,31 @@ import org.slf4j.LoggerFactory; * * @author msunal */ -public class Test implements TestService { +@Singleton +@Component(service = { }) +public final class Test implements TestFlow, AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(Test.class); - private AddFlow addFlow; + private final AddFlow addFlow; + private final Registration reg; + @Inject + @Activate + public Test(@Reference final RpcConsumerRegistry rpcService, + @Reference final RpcProviderService rpcProviderService) { + addFlow = rpcService.getRpc(AddFlow.class); + reg = rpcProviderService.registerRpcImplementation(this); + } + + @PreDestroy + @Deactivate @Override - public ListenableFuture> testFlow(final TestFlowInput input) { + public void close() { + reg.close(); + } + + @Override + public ListenableFuture> invoke(final TestFlowInput input) { // Construct the flow instance id final InstanceIdentifier flowInstanceId = InstanceIdentifier .builder(Nodes.class) // File under nodes @@ -128,8 +156,4 @@ public class Test implements TestService { LoggingFutures.addErrorLogging(addFlow.invoke(addFlowInput), LOG, "addFlow"); } } - - public void setAddFlow(final AddFlow addFlow) { - this.addFlow = addFlow; - } } diff --git a/extension/test-extension/src/main/resources/OSGI-INF/blueprint/test-extension.xml b/extension/test-extension/src/main/resources/OSGI-INF/blueprint/test-extension.xml deleted file mode 100644 index 0b2b93c8b8..0000000000 --- a/extension/test-extension/src/main/resources/OSGI-INF/blueprint/test-extension.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - -- 2.36.6