You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by cs...@apache.org on 2017/11/17 16:16:47 UTC
[1/5] aries-jax-rs-whiteboard git commit: Add test for application in
error with high ranking
Repository: aries-jax-rs-whiteboard
Updated Branches:
refs/heads/master 7a18a1da7 -> e6dfab21c
Add test for application in error with high ranking
Project: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/repo
Commit: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/commit/a915970e
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/a915970e
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/a915970e
Branch: refs/heads/master
Commit: a915970e0196205734202bc5037b70217a852708
Parents: 7a18a1d
Author: Carlos Sierra <cs...@apache.org>
Authored: Thu Nov 9 14:27:54 2017 +0100
Committer: Carlos Sierra <cs...@apache.org>
Committed: Thu Nov 9 14:27:54 2017 +0100
----------------------------------------------------------------------
jax-rs.itests/src/main/java/test/JaxrsTest.java | 59 ++++++++++++++++++++
1 file changed, 59 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/a915970e/jax-rs.itests/src/main/java/test/JaxrsTest.java
----------------------------------------------------------------------
diff --git a/jax-rs.itests/src/main/java/test/JaxrsTest.java b/jax-rs.itests/src/main/java/test/JaxrsTest.java
index 1cdee14..845bf93 100644
--- a/jax-rs.itests/src/main/java/test/JaxrsTest.java
+++ b/jax-rs.itests/src/main/java/test/JaxrsTest.java
@@ -598,6 +598,63 @@ public class JaxrsTest extends TestHelper {
}
@Test
+ public void testApplicationWithErrorAndHigherRanking() {
+
+ RuntimeDTO runtimeDTO = getRuntimeDTO();
+
+ assertEquals(0, runtimeDTO.applicationDTOs.length);
+ assertEquals(0, runtimeDTO.failedApplicationDTOs.length);
+
+ ServiceRegistration<Application> applicationRegistration =
+ registerApplication(new TestApplication());
+
+ runtimeDTO = getRuntimeDTO();
+
+ assertEquals(1, runtimeDTO.applicationDTOs.length);
+ assertEquals(0, runtimeDTO.failedApplicationDTOs.length);
+
+ ServiceRegistration<?> erroredRegistration = registerApplication(
+ new TestApplication() {
+
+ @Override
+ public Set<Object> getSingletons() {
+ throw new RuntimeException();
+ }
+
+ }, "service.ranking", 10);
+
+ runtimeDTO = getRuntimeDTO();
+
+ assertEquals(1, runtimeDTO.applicationDTOs.length);
+ assertEquals(1, runtimeDTO.failedApplicationDTOs.length);
+ assertEquals(
+ DTOConstants.FAILURE_REASON_UNKNOWN,
+ runtimeDTO.failedApplicationDTOs[0].failureReason);
+
+ assertEquals(
+ applicationRegistration.getReference().getProperty("service.id"),
+ runtimeDTO.applicationDTOs[0].serviceId);
+ assertEquals(
+ erroredRegistration.getReference().getProperty("service.id"),
+ runtimeDTO.failedApplicationDTOs[0].serviceId);
+
+ WebTarget webTarget = createDefaultTarget().path("/test-application");
+
+ assertEquals(200, webTarget.request().get().getStatus());
+ assertEquals("Hello application ", webTarget.request().get(String.class));
+
+ erroredRegistration.unregister();
+
+ runtimeDTO = getRuntimeDTO();
+
+ assertEquals(1, runtimeDTO.applicationDTOs.length);
+ assertEquals(0, runtimeDTO.failedApplicationDTOs.length);
+ assertEquals(
+ applicationRegistration.getReference().getProperty("service.id"),
+ runtimeDTO.applicationDTOs[0].serviceId);
+ }
+
+ @Test
public void testApplicationWithExtensionDryRun()
throws InterruptedException {
@@ -1315,6 +1372,8 @@ public class JaxrsTest extends TestHelper {
assertEquals(0, runtimeDTO.failedExtensionDTOs.length);
}
+
+
private JaxRSServiceRuntime getJaxRSServiceRuntime()
throws InterruptedException {
[5/5] aries-jax-rs-whiteboard git commit: Use new primitives in
component-dsl
Posted by cs...@apache.org.
Use new primitives in component-dsl
No need to implement the handling of the highest references here
anymore.
Project: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/repo
Commit: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/commit/e6dfab21
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/e6dfab21
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/e6dfab21
Branch: refs/heads/master
Commit: e6dfab21c3ba99e1a6eb77bc27f467770a7da646
Parents: a1dc538
Author: Carlos Sierra <cs...@apache.org>
Authored: Fri Nov 17 16:55:07 2017 +0100
Committer: Carlos Sierra <cs...@apache.org>
Committed: Fri Nov 17 16:55:07 2017 +0100
----------------------------------------------------------------------
.../aries/jax/rs/whiteboard/internal/Utils.java | 194 ++-----------------
1 file changed, 13 insertions(+), 181 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/e6dfab21/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Utils.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Utils.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Utils.java
index 70f12b2..c7b271b 100644
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Utils.java
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Utils.java
@@ -17,10 +17,8 @@
package org.apache.aries.jax.rs.whiteboard.internal;
-import org.apache.aries.osgi.functional.Event;
import org.apache.aries.osgi.functional.CachingServiceReference;
import org.apache.aries.osgi.functional.OSGi;
-import org.apache.aries.osgi.functional.SentEvent;
import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
import org.apache.cxf.message.Message;
import org.osgi.framework.ServiceObjects;
@@ -33,9 +31,6 @@ import java.util.Dictionary;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
-import java.util.TreeSet;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
import java.util.function.Function;
@@ -43,6 +38,7 @@ import static org.apache.aries.osgi.functional.OSGi.bundleContext;
import static org.apache.aries.osgi.functional.OSGi.just;
import static org.apache.aries.osgi.functional.OSGi.nothing;
import static org.apache.aries.osgi.functional.OSGi.onClose;
+import static org.apache.aries.osgi.functional.Utils.highest;
/**
* @author Carlos Sierra Andrés
@@ -117,11 +113,18 @@ public class Utils {
public static <K, T extends Comparable<? super T>> OSGi<T> highestPer(
Function<T, K> keySupplier, OSGi<T> program,
- Consumer<T> onAddingShadowed, Consumer<T> onRemovedShadowed) {
-
- return program.route(
- new HighestPerRouter<>(
- keySupplier, onAddingShadowed, onRemovedShadowed));
+ Consumer<? super T> onAddingShadowed,
+ Consumer<? super T> onRemovedShadowed) {
+
+ return program.splitBy(
+ keySupplier,
+ p -> highest(
+ p, Comparator.naturalOrder(),
+ discards -> discards.
+ effects(onAddingShadowed, onRemovedShadowed).
+ then(nothing())
+ )
+ );
}
public static <T> OSGi<ServiceTuple<T>> onlyGettables(
@@ -160,12 +163,6 @@ public class Utils {
}));
}
- public static <T extends Comparable<? super T>> OSGi<T> highestRanked(
- OSGi<T> program) {
-
- return program.route(new HighestRankedRouter<>());
- }
-
public static <T> OSGi<T> service(
CachingServiceReference<T> immutableServiceReference) {
@@ -313,169 +310,4 @@ public class Utils {
}
- private static class HighestRankedRouter<T extends Comparable<? super T>>
- implements Consumer<OSGi.Router<T>> {
-
- private final Comparator<Event<T>> _comparator;
-
- public HighestRankedRouter() {
- _comparator = Comparator.comparing(Event::getContent);
- }
-
- @Override
- public void accept(OSGi.Router<T> router) {
- AtomicReference<SentEvent<T>> _sent = new AtomicReference<>();
- final TreeSet<Event<T>> _set = new TreeSet<>(_comparator);
-
- router.onIncoming(ev -> {
- synchronized (_set) {
- _set.add(ev);
-
- if (ev == _set.last()) {
- _sent.set(router.signalAdd(ev));
- }
- }
- });
- router.onLeaving(ev -> {
- synchronized (_set) {
- if (_set.isEmpty()) {
- return;
- }
-
- _set.remove(ev);
-
- SentEvent<T> sent = _sent.get();
-
- if (sent != null && sent.getEvent() == ev) {
- sent.terminate();
-
- _sent.set(null);
- }
-
- if (!_set.isEmpty()) {
- _sent.set(router.signalAdd(_set.last()));
- }
- }
- });
- }
-
- }
-
- private static class HighestPerRouter<T extends Comparable<? super T>, K>
- implements Consumer<OSGi.Router<T>> {
-
- private final Function<T, K> _keySupplier;
- private final Consumer<T> _onAddingShadowed;
- private final Consumer<T> _onRemovedShadowed;
-
- public HighestPerRouter(
- Function<T, K> keySupplier,
- Consumer<T> onAddingShadowed, Consumer<T> onRemovedShadowed) {
-
- _keySupplier = keySupplier;
- _onAddingShadowed = onAddingShadowed;
- _onRemovedShadowed = onRemovedShadowed;
- }
-
- @Override
- public void accept(OSGi.Router<T> router) {
- /**
- * These can't be fields on the class or they would be shared among
- * invocations to OSGiResult.run :-O
- */
- final ConcurrentHashMap<K, TreeSet<Event<T>>> _map =
- new ConcurrentHashMap<>();
-
- final Map<K, SentEvent<T>> _sentEvents = new HashMap<>();
-
- router.onIncoming(e -> {
- K key = _keySupplier.apply(e.getContent());
-
- Comparator<Event<T>> comparator = Comparator.comparing(
- Event::getContent);
-
- _map.compute(
- key,
- (__, set) -> {
- if (set == null) {
- set = new TreeSet<>(comparator);
- }
-
- set.add(e);
-
- if (e == set.last()) {
- SentEvent<T> oldEvent = _sentEvents.get(key);
-
- if (oldEvent != null) {
- _sentEvents.remove(key);
-
- oldEvent.terminate();
-
- _onAddingShadowed.accept(
- oldEvent.getEvent().getContent());
- }
-
- _sentEvents.put(key, router.signalAdd(e));
- }
- else {
- _onAddingShadowed.accept(e.getContent());
- }
-
- return set;
- });
- });
- router.onLeaving(e -> {
- T content = e.getContent();
-
- K key = _keySupplier.apply(content);
-
- _map.compute(
- key,
- (__, set) -> {
- if (set.isEmpty()) {
- return set;
- }
-
- set.remove(e);
-
- _sentEvents.compute(key, (___, sentEvent) -> {
- if (sentEvent != null && sentEvent.getEvent() == e) {
- sentEvent.terminate();
-
- if (!set.isEmpty()) {
- Event<T> last = set.last();
-
- SentEvent<T> event = router.signalAdd(last);
-
- _onRemovedShadowed.accept(
- last.getContent());
-
- return event;
- }
-
- return null;
- }
- else {
- _onRemovedShadowed.accept(e.getContent());
- }
-
- return sentEvent;
- });
-
-
-
- return set;
- }
- );
- });
-
- router.onClose(() -> {
- _sentEvents.values().forEach(SentEvent::terminate);
-
- _sentEvents.clear();
- });
- }
-
- }
-
}
[4/5] aries-jax-rs-whiteboard git commit: Use test tools
Posted by cs...@apache.org.
Use test tools
that do cleanup after the test
Project: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/repo
Commit: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/commit/a1dc538f
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/a1dc538f
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/a1dc538f
Branch: refs/heads/master
Commit: a1dc538f73e3f080c4509bccf0b375a3449a6f16
Parents: 61b35d0
Author: Carlos Sierra <cs...@apache.org>
Authored: Fri Nov 17 16:54:28 2017 +0100
Committer: Carlos Sierra <cs...@apache.org>
Committed: Fri Nov 17 16:54:28 2017 +0100
----------------------------------------------------------------------
jax-rs.itests/src/main/java/test/JaxrsTest.java | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/a1dc538f/jax-rs.itests/src/main/java/test/JaxrsTest.java
----------------------------------------------------------------------
diff --git a/jax-rs.itests/src/main/java/test/JaxrsTest.java b/jax-rs.itests/src/main/java/test/JaxrsTest.java
index f77a60e..8575271 100644
--- a/jax-rs.itests/src/main/java/test/JaxrsTest.java
+++ b/jax-rs.itests/src/main/java/test/JaxrsTest.java
@@ -117,13 +117,10 @@ public class JaxrsTest extends TestHelper {
Long changeCount = (Long)_runtimeServiceReference.getProperty(
"service.changecount");
- Dictionary<String, Object> properties = new Hashtable<>();
-
- properties.put(JAX_RS_APPLICATION_BASE, "/test-counter");
-
ServiceRegistration<?> serviceRegistration =
- bundleContext.registerService(
- Application.class, new TestApplication(), properties);
+ registerApplication(
+ new TestApplication(), JAX_RS_APPLICATION_BASE,
+ "/test-counter");
Long newCount = (Long)_runtimeServiceReference.getProperty(
"service.changecount");
[3/5] aries-jax-rs-whiteboard git commit: Correct implementation of
error handling
Posted by cs...@apache.org.
Correct implementation of error handling
If an application that shadows other applications produces an unknown
error when it is registered, this application must be kept and signaled
as errored and the shadowed applications must be signaled as shadowed.
Project: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/repo
Commit: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/commit/61b35d0c
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/61b35d0c
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/61b35d0c
Branch: refs/heads/master
Commit: 61b35d0c0b138cf1da23a32567855f61db3cd9b2
Parents: 3bed8f0
Author: Carlos Sierra <cs...@apache.org>
Authored: Fri Nov 17 16:52:58 2017 +0100
Committer: Carlos Sierra <cs...@apache.org>
Committed: Fri Nov 17 16:52:58 2017 +0100
----------------------------------------------------------------------
jax-rs.itests/src/main/java/test/JaxrsTest.java | 28 +++---------
.../jax/rs/whiteboard/internal/Whiteboard.java | 46 ++++++++------------
2 files changed, 24 insertions(+), 50 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/61b35d0c/jax-rs.itests/src/main/java/test/JaxrsTest.java
----------------------------------------------------------------------
diff --git a/jax-rs.itests/src/main/java/test/JaxrsTest.java b/jax-rs.itests/src/main/java/test/JaxrsTest.java
index 845bf93..f77a60e 100644
--- a/jax-rs.itests/src/main/java/test/JaxrsTest.java
+++ b/jax-rs.itests/src/main/java/test/JaxrsTest.java
@@ -599,7 +599,6 @@ public class JaxrsTest extends TestHelper {
@Test
public void testApplicationWithErrorAndHigherRanking() {
-
RuntimeDTO runtimeDTO = getRuntimeDTO();
assertEquals(0, runtimeDTO.applicationDTOs.length);
@@ -625,23 +624,8 @@ public class JaxrsTest extends TestHelper {
runtimeDTO = getRuntimeDTO();
- assertEquals(1, runtimeDTO.applicationDTOs.length);
- assertEquals(1, runtimeDTO.failedApplicationDTOs.length);
- assertEquals(
- DTOConstants.FAILURE_REASON_UNKNOWN,
- runtimeDTO.failedApplicationDTOs[0].failureReason);
-
- assertEquals(
- applicationRegistration.getReference().getProperty("service.id"),
- runtimeDTO.applicationDTOs[0].serviceId);
- assertEquals(
- erroredRegistration.getReference().getProperty("service.id"),
- runtimeDTO.failedApplicationDTOs[0].serviceId);
-
- WebTarget webTarget = createDefaultTarget().path("/test-application");
-
- assertEquals(200, webTarget.request().get().getStatus());
- assertEquals("Hello application ", webTarget.request().get(String.class));
+ assertEquals(0, runtimeDTO.applicationDTOs.length);
+ assertEquals(2, runtimeDTO.failedApplicationDTOs.length);
erroredRegistration.unregister();
@@ -649,9 +633,11 @@ public class JaxrsTest extends TestHelper {
assertEquals(1, runtimeDTO.applicationDTOs.length);
assertEquals(0, runtimeDTO.failedApplicationDTOs.length);
- assertEquals(
- applicationRegistration.getReference().getProperty("service.id"),
- runtimeDTO.applicationDTOs[0].serviceId);
+
+ WebTarget webTarget = createDefaultTarget().path("/test-application");
+
+ assertEquals(200, webTarget.request().get().getStatus());
+ assertEquals("Hello application", webTarget.request().get(String.class));
}
@Test
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/61b35d0c/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Whiteboard.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Whiteboard.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Whiteboard.java
index a075901..724c838 100644
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Whiteboard.java
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Whiteboard.java
@@ -76,18 +76,17 @@ import static org.apache.aries.jax.rs.whiteboard.internal.Utils.getResourceProvi
import static org.apache.aries.jax.rs.whiteboard.internal.Utils.highestPer;
import static org.apache.aries.jax.rs.whiteboard.internal.Utils.ignoreResult;
import static org.apache.aries.jax.rs.whiteboard.internal.Utils.onlyGettables;
-import static org.apache.aries.jax.rs.whiteboard.internal.Utils.highestRanked;
import static org.apache.aries.jax.rs.whiteboard.internal.Utils.service;
import static org.apache.aries.jax.rs.whiteboard.internal.Utils.serviceObjects;
import static org.apache.aries.jax.rs.whiteboard.internal.Utils.updateProperty;
import static org.apache.aries.osgi.functional.OSGi.all;
-import static org.apache.aries.osgi.functional.OSGi.join;
import static org.apache.aries.osgi.functional.OSGi.just;
import static org.apache.aries.osgi.functional.OSGi.nothing;
import static org.apache.aries.osgi.functional.OSGi.onClose;
import static org.apache.aries.osgi.functional.OSGi.once;
import static org.apache.aries.osgi.functional.OSGi.register;
import static org.apache.aries.osgi.functional.OSGi.serviceReferences;
+import static org.apache.aries.osgi.functional.Utils.highest;
import static org.osgi.service.http.runtime.HttpServiceRuntimeConstants.HTTP_SERVICE_ENDPOINT;
import static org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME;
import static org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT;
@@ -257,7 +256,17 @@ public class Whiteboard {
);
return
- highestRankedPerPath.flatMap(
+ highestRankedPerPath.recoverWith(
+ (t, e) ->
+ just(t).map(
+ ServiceTuple::getCachingServiceReference
+ ).effects(
+ _runtime::addErroredApplication,
+ _runtime::removeErroredApplication
+ ).then(
+ nothing()
+ )
+ ).flatMap(
this::deployApplication
).map(
ServiceTuple::getCachingServiceReference
@@ -324,7 +333,7 @@ public class Whiteboard {
defaultApplication() {
return
- highestRanked(
+ highest(
serviceReferences(
CXFJaxRsServiceRegistrator.class,
String.format(
@@ -364,32 +373,11 @@ public class Whiteboard {
Bus bus, ServiceTuple<Application> tuple, Map<String, Object> props) {
return
- join(just(() -> {
- try {
- CXFJaxRsServiceRegistrator registrator =
- new CXFJaxRsServiceRegistrator(bus, tuple.getService());
-
- return
- onClose(registrator::close).then(
- register(
- CXFJaxRsServiceRegistrator.class, registrator,
- props)
- );
- }
- catch (RuntimeException e) {
- CachingServiceReference<Application> serviceReference =
- tuple.getCachingServiceReference();
-
- _runtime.addErroredApplication(serviceReference);
+ just(() -> new CXFJaxRsServiceRegistrator(bus, tuple.getService())).
+ flatMap(registrator ->
- return onClose(
- () ->
- _runtime.removeErroredApplication(serviceReference)
- ).then(
- nothing()
- );
- }
- }));
+ onClose(registrator::close).then(
+ register(CXFJaxRsServiceRegistrator.class, registrator, props)));
}
private OSGi<CachingServiceReference<Object>>
[2/5] aries-jax-rs-whiteboard git commit: Revert "Check earlier if
application throws error"
Posted by cs...@apache.org.
Revert "Check earlier if application throws error"
This reverts commit 57c5985a65d93e8d66285fc4d05d52d2cfc58c19.
Project: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/repo
Commit: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/commit/3bed8f06
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/3bed8f06
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/3bed8f06
Branch: refs/heads/master
Commit: 3bed8f06e1da0d23dd420a7866b2696adaf32c52
Parents: a915970
Author: Carlos Sierra <cs...@apache.org>
Authored: Thu Nov 9 14:37:52 2017 +0100
Committer: Carlos Sierra <cs...@apache.org>
Committed: Thu Nov 9 14:37:52 2017 +0100
----------------------------------------------------------------------
.../jax/rs/whiteboard/internal/Whiteboard.java | 64 ++++++++------------
1 file changed, 25 insertions(+), 39 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/3bed8f06/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Whiteboard.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Whiteboard.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Whiteboard.java
index 7d43068..a075901 100644
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Whiteboard.java
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Whiteboard.java
@@ -179,38 +179,6 @@ public class Whiteboard {
return new Whiteboard(bundleContext, configuration);
}
- private OSGi<ServiceTuple<Application>> filterErroringApplications(
- OSGi<ServiceTuple<Application>> program) {
-
- return program.flatMap(tuple -> {
- ExtensionManagerBus bus = createBus();
-
- try {
- CXFJaxRsServiceRegistrator registrator =
- new CXFJaxRsServiceRegistrator(bus, tuple.getService());
-
- registrator.close();
- bus.shutdown();
-
- return just(tuple);
- }
- catch (Exception e) {
- CachingServiceReference<Application> serviceReference =
- tuple.getCachingServiceReference();
-
- _runtime.addErroredApplication(serviceReference);
-
- return onClose(
- () ->
- _runtime.removeErroredApplication(serviceReference)
- ).then(
- nothing()
- );
- }
- });
-
- }
-
public void start() {
_osgiResult = _program.run(_bundleContext);
}
@@ -276,9 +244,6 @@ public class Whiteboard {
_runtime::addNotGettableApplication,
_runtime::removeNotGettableApplication);
- gettableAplicationForWhiteboard = filterErroringApplications(
- gettableAplicationForWhiteboard);
-
OSGi<ServiceTuple<Application>> highestRankedPerName = highestPer(
APPLICATION_NAME, gettableAplicationForWhiteboard,
t -> _runtime.addClashingApplication(t.getCachingServiceReference()),
@@ -399,11 +364,32 @@ public class Whiteboard {
Bus bus, ServiceTuple<Application> tuple, Map<String, Object> props) {
return
- just(() -> new CXFJaxRsServiceRegistrator(bus, tuple.getService())).
- flatMap(registrator ->
+ join(just(() -> {
+ try {
+ CXFJaxRsServiceRegistrator registrator =
+ new CXFJaxRsServiceRegistrator(bus, tuple.getService());
- onClose(registrator::close).then(
- register(CXFJaxRsServiceRegistrator.class, registrator, props)));
+ return
+ onClose(registrator::close).then(
+ register(
+ CXFJaxRsServiceRegistrator.class, registrator,
+ props)
+ );
+ }
+ catch (RuntimeException e) {
+ CachingServiceReference<Application> serviceReference =
+ tuple.getCachingServiceReference();
+
+ _runtime.addErroredApplication(serviceReference);
+
+ return onClose(
+ () ->
+ _runtime.removeErroredApplication(serviceReference)
+ ).then(
+ nothing()
+ );
+ }
+ }));
}
private OSGi<CachingServiceReference<Object>>