You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by ti...@apache.org on 2021/10/13 10:32:00 UTC
[aries-jax-rs-whiteboard] branch fix/lifecycle created (now 23d4066)
This is an automated email from the ASF dual-hosted git repository.
timothyjward pushed a change to branch fix/lifecycle
in repository https://gitbox.apache.org/repos/asf/aries-jax-rs-whiteboard.git.
at 23d4066 Further CXF lifecycle workarounds
This branch includes the following new commits:
new 23d4066 Further CXF lifecycle workarounds
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[aries-jax-rs-whiteboard] 01/01: Further CXF lifecycle workarounds
Posted by ti...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
timothyjward pushed a commit to branch fix/lifecycle
in repository https://gitbox.apache.org/repos/asf/aries-jax-rs-whiteboard.git
commit 23d40666d15fdc7c47a41d039677dc434a8c2cb6
Author: Tim Ward <ti...@apache.org>
AuthorDate: Wed Oct 13 11:27:54 2021 +0100
Further CXF lifecycle workarounds
---
.../main/java/test/WhiteboardLifecycleTest.java | 37 +++++++++++++++++++---
.../activator/CxfJaxrsBundleActivator.java | 12 ++++---
2 files changed, 40 insertions(+), 9 deletions(-)
diff --git a/jax-rs.itests/src/main/java/test/WhiteboardLifecycleTest.java b/jax-rs.itests/src/main/java/test/WhiteboardLifecycleTest.java
index cd0aa09..2fd09b6 100644
--- a/jax-rs.itests/src/main/java/test/WhiteboardLifecycleTest.java
+++ b/jax-rs.itests/src/main/java/test/WhiteboardLifecycleTest.java
@@ -20,27 +20,56 @@ package test;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
+import javax.ws.rs.client.ClientBuilder;
+
import org.apache.cxf.bus.osgi.CXFActivator;
import org.junit.Test;
import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
import org.osgi.framework.FrameworkUtil;
+import org.osgi.service.jaxrs.client.SseEventSourceFactory;
+import org.osgi.util.tracker.ServiceTracker;
import test.types.TestHelper;
public class WhiteboardLifecycleTest extends TestHelper {
@Test
- public void testCXFLifecycle() throws Exception {
- assertNotNull(_runtimeTracker.getService());
+ public void testCXFLifecycleWhiteboard() throws Exception {
+ testTracking(_runtimeTracker);
+ }
+
+ private void testTracking(ServiceTracker<?,?> tracker) throws BundleException, InterruptedException {
+ assertNotNull(tracker.waitForService(5000));
Bundle cxfBundle = FrameworkUtil.getBundle(CXFActivator.class);
cxfBundle.stop();
- assertNull(_runtimeTracker.getService());
+ assertNull(tracker.getService());
cxfBundle.start();
- assertNotNull(_runtimeTracker.waitForService(5000));
+ assertNotNull(tracker.waitForService(5000));
+ }
+
+ @Test
+ public void testCXFLifecycleClientBuilder() throws Exception {
+ ServiceTracker<ClientBuilder, ClientBuilder> tracker = new ServiceTracker<>(bundleContext, ClientBuilder.class, null);
+ tracker.open();
+
+ testTracking(tracker);
+
+ tracker.close();
+ }
+
+ @Test
+ public void testCXFLifecycleSseBuilderFactory() throws Exception {
+ ServiceTracker<SseEventSourceFactory, SseEventSourceFactory> tracker = new ServiceTracker<>(bundleContext, SseEventSourceFactory.class, null);
+ tracker.open();
+
+ testTracking(tracker);
+
+ tracker.close();
}
}
\ No newline at end of file
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CxfJaxrsBundleActivator.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CxfJaxrsBundleActivator.java
index 375ba79..ab85480 100644
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CxfJaxrsBundleActivator.java
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CxfJaxrsBundleActivator.java
@@ -100,9 +100,11 @@ public class CxfJaxrsBundleActivator implements BundleActivator {
_log.debug("Starting the whiteboard factory");
}
- OSGi<?> runWhiteboards =
- bundles(ACTIVE)
- .filter(b -> b.equals(FrameworkUtil.getBundle(CXFActivator.class)))
+ OSGi<?> waitForCXF =
+ bundles(ACTIVE)
+ .filter(b -> b.equals(FrameworkUtil.getBundle(CXFActivator.class)));
+
+ OSGi<?> runWhiteboards = waitForCXF
.then(
all(
configurations("org.apache.aries.jax.rs.whiteboard"),
@@ -130,8 +132,8 @@ public class CxfJaxrsBundleActivator implements BundleActivator {
_defaultOSGiResult =
all(
- ignore(registerClient()),
- ignore(registerSseEventSourceFactory()),
+ ignore(waitForCXF.then(registerClient())),
+ ignore(waitForCXF.then(registerSseEventSourceFactory())),
ignore(runWhiteboards)
)
.run(bundleContext);