aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From csie...@apache.org
Subject [1/4] aries-jax-rs-whiteboard git commit: Source formatting
Date Mon, 28 Aug 2017 18:45:59 GMT
Repository: aries-jax-rs-whiteboard
Updated Branches:
  refs/heads/master 5e7d56a99 -> ae179e026


Source formatting


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

Branch: refs/heads/master
Commit: da42911b0905b128a3869d612f9588edf74b2c24
Parents: 5e7d56a
Author: Carlos Sierra <csierra@apache.org>
Authored: Mon Aug 28 12:10:21 2017 +0200
Committer: Carlos Sierra <csierra@apache.org>
Committed: Mon Aug 28 12:10:21 2017 +0200

----------------------------------------------------------------------
 .../jax/rs/whiteboard/internal/Whiteboard.java  | 56 +++++++++++++-------
 1 file changed, 36 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/da42911b/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 b19b523..78e5a06 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
@@ -57,6 +57,7 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.Map;
+import java.util.Optional;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.function.Consumer;
 import java.util.function.Function;
@@ -269,24 +270,33 @@ public class Whiteboard {
             );
     }
 
-    private static OSGi<Collection<String>> bestEffortCalculationOfEnpoints(Filter
filter) {
+    private static OSGi<Collection<String>> bestEffortCalculationOfEnpoints(
+        Filter filter) {
+
         Collection<String> endPoints = new ArrayList<>();
 
         return
             serviceReferences(HttpServiceRuntime.class, filter.toString()).
+                map(
+                    r -> Strings.stringPlus(
+                        r.getProperty(HTTP_SERVICE_ENDPOINT))
+                ).
+                filter(
+                    Optional::isPresent
+                ).
+                map(
+                    Optional::get
+                ).
                 foreach(
-                    reference -> Strings.stringPlus(reference.getProperty(HTTP_SERVICE_ENDPOINT)).
-                        ifPresent(endPoints::addAll)
-                    ,
-                    reference -> Strings.stringPlus(reference.getProperty(HTTP_SERVICE_ENDPOINT)).
-                        ifPresent(values -> values.forEach(endPoints::remove))
-                ).then(
-            just(endPoints)
-        );
+                    endPoints::addAll,
+                    endPoints::removeAll
+                ).
+            then(just(endPoints));
     }
 
     private static OSGi<ApplicationReference> chooseApplication(
-        ServiceReference<?> serviceReference, OSGi<ApplicationReference> theDefault)
{
+        ServiceReference<?> serviceReference,
+        OSGi<ApplicationReference> theDefault) {
 
         Object applicationSelectProperty = serviceReference.getProperty(
             JAX_RS_APPLICATION_SELECT);
@@ -548,24 +558,30 @@ public class Whiteboard {
         BundleContext bundleContext,
         ServiceReference<?> jaxRsRuntimeServiceReference,
         ApplicationReference defaultApplicationReference,
-        AriesJaxRSServiceRuntime runtime, ServiceRegistrationChangeCounter counter) {
+        AriesJaxRSServiceRuntime runtime,
+        ServiceRegistrationChangeCounter counter) {
+
+        OSGi<ServiceReference<Object>> extensionsForApplications =
+            serviceReferences(getApplicationExtensionsFilter()).
+                filter(new TargetFilter<>(jaxRsRuntimeServiceReference));
+
         return
             onlySupportedInterfaces(
-                countChanges(serviceReferences(getApplicationExtensionsFilter()).
-                    filter(new TargetFilter<>(jaxRsRuntimeServiceReference)),
-                    counter),
-                runtime::addInvalidExtension, runtime::removeInvalidExtension).
-                    flatMap(endpointReference ->
+                    countChanges(extensionsForApplications, counter),
+                    runtime::addInvalidExtension,
+                    runtime::removeInvalidExtension).
+                flatMap(resourceReference ->
             chooseApplication(
-                    endpointReference,
+                    resourceReference,
                     all(
                         just(defaultApplicationReference),
-                        allApplicationReferences())).
+                        allApplicationReferences())
+                    ).
                 flatMap(applicationReference ->
             waitForExtensionDependencies(
-                bundleContext, endpointReference, applicationReference, runtime,
+                bundleContext, resourceReference, applicationReference, runtime,
             safeRegisterExtension(
-                endpointReference,
+                resourceReference,
                 applicationReference.getApplicationName(),
                 applicationReference.getRegistrator(), runtime)
         )));


Mime
View raw message