Use (fixed) accumulate

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/9f7ecf18
Tree: 
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/9f7ecf18
Diff: 
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/9f7ecf18

Branch: refs/heads/master
Commit: 9f7ecf18c0e14cc4e5556a8430512eca98bc1663
Parents: dc976c1
Author: Carlos Sierra <[email protected]>
Authored: Thu Aug 9 17:56:09 2018 +0200
Committer: Carlos Sierra <[email protected]>
Committed: Thu Aug 9 17:56:09 2018 +0200

----------------------------------------------------------------------
 integrations/shiro/shiro-authc/pom.xml          |  2 +-
 .../impl/ShiroAuthenticationActivator.java      | 25 ++++----------------
 integrations/shiro/shiro-authz/pom.xml          |  2 +-
 jax-rs.whiteboard/pom.xml                       |  2 +-
 4 files changed, 8 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/9f7ecf18/integrations/shiro/shiro-authc/pom.xml
----------------------------------------------------------------------
diff --git a/integrations/shiro/shiro-authc/pom.xml 
b/integrations/shiro/shiro-authc/pom.xml
index 5ec42c4..6bb081c 100644
--- a/integrations/shiro/shiro-authc/pom.xml
+++ b/integrations/shiro/shiro-authc/pom.xml
@@ -36,7 +36,7 @@
            <dependency>
             <groupId>org.apache.aries.component-dsl</groupId>
             
<artifactId>org.apache.aries.component-dsl.component-dsl</artifactId>
-            <version>1.2.0</version>
+            <version>1.2.1-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
            <dependency>

http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/9f7ecf18/integrations/shiro/shiro-authc/src/main/java/org/apache/aries/jax/rs/shiro/authc/impl/ShiroAuthenticationActivator.java
----------------------------------------------------------------------
diff --git 
a/integrations/shiro/shiro-authc/src/main/java/org/apache/aries/jax/rs/shiro/authc/impl/ShiroAuthenticationActivator.java
 
b/integrations/shiro/shiro-authc/src/main/java/org/apache/aries/jax/rs/shiro/authc/impl/ShiroAuthenticationActivator.java
index 8fde563..ad6f599 100644
--- 
a/integrations/shiro/shiro-authc/src/main/java/org/apache/aries/jax/rs/shiro/authc/impl/ShiroAuthenticationActivator.java
+++ 
b/integrations/shiro/shiro-authc/src/main/java/org/apache/aries/jax/rs/shiro/authc/impl/ShiroAuthenticationActivator.java
@@ -21,7 +21,9 @@ import static org.apache.aries.component.dsl.OSGi.coalesce;
 import static org.apache.aries.component.dsl.OSGi.configuration;
 import static org.apache.aries.component.dsl.OSGi.just;
 import static org.apache.aries.component.dsl.OSGi.register;
+import static org.apache.aries.component.dsl.OSGi.service;
 import static org.apache.aries.component.dsl.OSGi.serviceReferences;
+import static org.apache.aries.component.dsl.Utils.accumulate;
 import static 
org.osgi.service.jaxrs.whiteboard.JaxrsWhiteboardConstants.JAX_RS_EXTENSION;
 
 import java.util.ArrayList;
@@ -37,6 +39,7 @@ import javax.ws.rs.core.Feature;
 import org.apache.aries.component.dsl.CachingServiceReference;
 import org.apache.aries.component.dsl.OSGi;
 import org.apache.aries.component.dsl.OSGiResult;
+import org.apache.aries.component.dsl.Utils;
 import org.apache.shiro.realm.Realm;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
@@ -51,12 +54,8 @@ public class ShiroAuthenticationActivator implements 
BundleActivator {
     
     private OSGiResult registration;
 
-    private BundleContext context;
-
     @Override
     public void start(BundleContext context) throws Exception {
-        
-        this.context = context;
         _LOG.debug("Starting the Shiro JAX-RS Authentication Feature");
         
         registration = coalesce(
@@ -101,27 +100,13 @@ public class ShiroAuthenticationActivator implements 
BundleActivator {
         
         Object filter = properties.get("realms.target");
         
-        ConcurrentSkipListMap<CachingServiceReference<Realm>, Realm> 
discovered = new ConcurrentSkipListMap<>();
-        
         OSGi<List<Realm>> realms;
         if(filter == null) {
             _LOG.debug("The Shiro JAX-RS Authentication Feature is accepting 
all realms");
-            realms = serviceReferences(Realm.class)
-                .effects(csr -> discovered.put(csr, 
context.getService(csr.getServiceReference())), 
-                        csr -> {
-                            discovered.remove(csr);
-                            context.ungetService(csr.getServiceReference());
-                        })
-                .map(x -> new ArrayList<>(discovered.values()));
+            realms = accumulate(service(serviceReferences(Realm.class)));
         } else {
             _LOG.debug("The Shiro JAX-RS Authentication Feature is filtering 
realms using the filter {}", filter);
-            realms = serviceReferences(Realm.class, String.valueOf(filter))
-                    .effects(csr -> discovered.put(csr, 
context.getService(csr.getServiceReference())), 
-                            csr -> {
-                                discovered.remove(csr);
-                                
context.ungetService(csr.getServiceReference());
-                            })
-                    .map(x -> new ArrayList<>(discovered.values()));
+            realms = accumulate(service(serviceReferences(Realm.class, 
String.valueOf(filter))));
         }
         
         return realms.map(ShiroAuthenticationFeatureProvider::new)

http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/9f7ecf18/integrations/shiro/shiro-authz/pom.xml
----------------------------------------------------------------------
diff --git a/integrations/shiro/shiro-authz/pom.xml 
b/integrations/shiro/shiro-authz/pom.xml
index 375350b..8ec97ab 100644
--- a/integrations/shiro/shiro-authz/pom.xml
+++ b/integrations/shiro/shiro-authz/pom.xml
@@ -36,7 +36,7 @@
                <dependency>
             <groupId>org.apache.aries.component-dsl</groupId>
             
<artifactId>org.apache.aries.component-dsl.component-dsl</artifactId>
-            <version>1.2.0</version>
+            <version>1.2.1-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
            <dependency>

http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/9f7ecf18/jax-rs.whiteboard/pom.xml
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/pom.xml b/jax-rs.whiteboard/pom.xml
index 38826c9..369a2e9 100644
--- a/jax-rs.whiteboard/pom.xml
+++ b/jax-rs.whiteboard/pom.xml
@@ -31,7 +31,7 @@
         <dependency>
             <groupId>org.apache.aries.component-dsl</groupId>
             
<artifactId>org.apache.aries.component-dsl.component-dsl</artifactId>
-            <version>1.2.0</version>
+            <version>1.2.1-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
         <dependency>

Reply via email to