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 <[email protected]> Authored: Thu Nov 9 14:37:52 2017 +0100 Committer: Carlos Sierra <[email protected]> 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>>
