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 2020/09/11 16:17:06 UTC
[aries-jax-rs-whiteboard] 02/06: [ARIES-2001] Refactor to not use
ServiceTuple after getResourceProvider
This is an automated email from the ASF dual-hosted git repository.
csierra pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/aries-jax-rs-whiteboard.git
commit e50fc8fe0adae6e3fe9320f4999dc6658b4f9817
Author: Carlos Sierra Andrés <ca...@liferay.com>
AuthorDate: Wed Sep 2 11:42:42 2020 +0200
[ARIES-2001] Refactor to not use ServiceTuple after getResourceProvider
This refactor should state more clearly that the service tuple is not
used after `getResourceProvider` (since we don't bind it), so it is
safe now to dispose the service tuple by one of the resource providers.
---
.../jax/rs/whiteboard/internal/Whiteboard.java | 56 ++++++++++------------
1 file changed, 25 insertions(+), 31 deletions(-)
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 d270754..6fd10b5 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
@@ -360,6 +360,7 @@ public class Whiteboard {
__ -> serviceObjects.ungetService(service)
);
}
+
return just(
new PrototypeServiceReferenceResourceProvider(
cachingServiceReference,
@@ -855,38 +856,31 @@ public class Whiteboard {
() -> "Errored ServiceReference {} for endpoint left")
).
then(nothing())
- ).flatMap(st ->
- just(st).
- flatMap(
- Whiteboard::getResourceProvider
- ).effects(
- rp -> _runtime.addApplicationEndpoint(
- registratorProperties::get,
- st.getCachingServiceReference(),
- registrator.getBus(), st.getService().getClass()),
- rp -> _runtime.removeApplicationEndpoint(
- registratorProperties::get,
- st.getCachingServiceReference())
- ).effects(
- registrator::add,
- registrator::remove
- ).effects(
- ifDebugEnabled(
- _log,
- () -> "Registered endpoint " +
- st.getCachingServiceReference().
- getServiceReference() + " into application " +
- getServiceName(registratorProperties::get)
- ),
- ifDebugEnabled(
- _log,
- () -> "Unregistered endpoint " +
- st.getCachingServiceReference().
- getServiceReference() + " from application " +
- getServiceName(registratorProperties::get)
- )
-
+ ).flatMap(
+ Whiteboard::getResourceProvider
+ ).effects(
+ rp -> _runtime.addApplicationEndpoint(
+ registratorProperties::get, serviceReference,
+ registrator.getBus(), rp.getResourceClass()),
+ rp -> _runtime.removeApplicationEndpoint(
+ registratorProperties::get, serviceReference)
+ ).effects(
+ registrator::add,
+ registrator::remove
+ ).effects(
+ ifDebugEnabled(
+ _log,
+ () -> "Registered endpoint " +
+ serviceReference.getServiceReference() + " into application " +
+ getServiceName(registratorProperties::get)
+ ),
+ ifDebugEnabled(
+ _log,
+ () -> "Unregistered endpoint " +
+ serviceReference.getServiceReference() + " from application " +
+ getServiceName(registratorProperties::get)
)
+
);
}