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 2021/03/07 18:38:07 UTC

[aries-component-dsl] 02/03: Without update selectors we can't propagate the update

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-component-dsl.git

commit bf80a9b2a49cd3d237c9108ac7084b0578ecd603
Author: Carlos Sierra Andrés <ca...@liferay.com>
AuthorDate: Sun Mar 7 19:10:27 2021 +0100

    Without update selectors we can't propagate the update
    
    Nodes supporting updates can't propagate the update because we can't
    differentiate which one we want to refresh.
---
 .../component/dsl/internal/RefreshWhenOSGi.java    | 36 ++++++++++++----------
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/component-dsl/src/main/java/org/apache/aries/component/dsl/internal/RefreshWhenOSGi.java b/component-dsl/src/main/java/org/apache/aries/component/dsl/internal/RefreshWhenOSGi.java
index 0db1055..e591787 100644
--- a/component-dsl/src/main/java/org/apache/aries/component/dsl/internal/RefreshWhenOSGi.java
+++ b/component-dsl/src/main/java/org/apache/aries/component/dsl/internal/RefreshWhenOSGi.java
@@ -28,24 +28,28 @@ import java.util.function.Predicate;
 public class RefreshWhenOSGi<T> extends OSGiImpl<T> {
 
     public RefreshWhenOSGi(OSGi<T> program, Predicate<T> refresher) {
-        super((executionContext, op) -> program.run(
-            executionContext,
-            op.pipe(
-                t -> {
-                    OSGiResult osgiResult = op.publish(t);
-
-                    return new OSGiResultImpl(
-                        osgiResult::close,
-                        () -> {
-                            if (refresher.test(t)) {
-                                return true;
+        super((executionContext, op) -> {
+            OSGiResult result = program.run(
+                executionContext,
+                op.pipe(
+                    t -> {
+                        OSGiResult osgiResult = op.publish(t);
+
+                        return new OSGiResultImpl(
+                            osgiResult::close,
+                            () -> {
+                                if (refresher.test(t)) {
+                                    return true;
+                                }
+
+                                return osgiResult.update();
                             }
+                        );
+                    }
+                ));
 
-                            return osgiResult.update();
-                        }
-                    );
-                }
-            )));
+            return new OSGiResultImpl(result::close, () -> false);
+        });
     }
 
 }