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 2017/11/21 17:44:21 UTC

[02/11] aries-jax-rs-whiteboard git commit: Source format

Source format


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

Branch: refs/heads/master
Commit: dd157f6676ca2845c7ef126764f01346c78e6a67
Parents: 9db4620
Author: Carlos Sierra <cs...@apache.org>
Authored: Mon Nov 20 09:07:24 2017 +0100
Committer: Carlos Sierra <cs...@apache.org>
Committed: Mon Nov 20 09:07:24 2017 +0100

----------------------------------------------------------------------
 jax-rs.itests/src/main/java/test/JaxrsTest.java |   7 +-
 .../internal/AriesJaxRSServiceRuntime.java      | 284 +++++++++----------
 2 files changed, 143 insertions(+), 148 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/dd157f66/jax-rs.itests/src/main/java/test/JaxrsTest.java
----------------------------------------------------------------------
diff --git a/jax-rs.itests/src/main/java/test/JaxrsTest.java b/jax-rs.itests/src/main/java/test/JaxrsTest.java
index c32d56a..427134e 100644
--- a/jax-rs.itests/src/main/java/test/JaxrsTest.java
+++ b/jax-rs.itests/src/main/java/test/JaxrsTest.java
@@ -71,9 +71,6 @@ import static org.junit.Assert.assertNull;
 
 public class JaxrsTest extends TestHelper {
 
-    private Collection<ServiceRegistration<?>> _registrations =
-        new ArrayList<>();
-
     @After
     public void tearDown() {
         Iterator<ServiceRegistration<?>> iterator = _registrations.iterator();
@@ -1378,8 +1375,8 @@ public class JaxrsTest extends TestHelper {
 
         assertEquals(0, runtimeDTO.failedExtensionDTOs.length);
     }
-
-
+    private Collection<ServiceRegistration<?>> _registrations =
+        new ArrayList<>();
 
     private JaxRSServiceRuntime getJaxRSServiceRuntime()
         throws InterruptedException {

http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/dd157f66/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/AriesJaxRSServiceRuntime.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/AriesJaxRSServiceRuntime.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/AriesJaxRSServiceRuntime.java
index 7bc252d..0e714dc 100644
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/AriesJaxRSServiceRuntime.java
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/AriesJaxRSServiceRuntime.java
@@ -56,52 +56,16 @@ public class AriesJaxRSServiceRuntime implements JaxRSServiceRuntime {
     private static final Logger _LOGGER = LoggerFactory.getLogger(
         Whiteboard.class);
 
-    public void addErroredExtension(
-        CachingServiceReference<?> cachingServiceReference) {
-
-        _erroredExtensions.add(cachingServiceReference);
-    }
+    public static String getApplicationName(PropertyHolder properties) {
+        Object property = properties.get(JAX_RS_NAME);
 
-    public void removeErroredExtension(
-        CachingServiceReference<?> cachingServiceReference) {
+        if (property == null) {
+            return generateApplicationName(properties);
+        }
 
-        _erroredExtensions.remove(cachingServiceReference);
+        return property.toString();
     }
 
-    private ConcurrentHashMap<String, Map<String, Object>>
-        _applications = new ConcurrentHashMap<>();
-    private ConcurrentHashMap<String, Collection<CachingServiceReference<?>>>
-        _applicationEndpoints = new ConcurrentHashMap<>();
-    private ConcurrentHashMap<String, Collection<CachingServiceReference<?>>>
-        _applicationExtensions = new ConcurrentHashMap<>();
-    private Collection<CachingServiceReference<Application>>
-        _ungettableApplications = new CopyOnWriteArrayList<>();
-    private Collection<CachingServiceReference<Application>> _shadowedApplications =
-        new CopyOnWriteArrayList<>();
-    private Set<CachingServiceReference<Application>> _dependentApplications =
-        ConcurrentHashMap.newKeySet();
-    private Set<CachingServiceReference<?>> _applicationDependentExtensions =
-        ConcurrentHashMap.newKeySet();
-    private Set<CachingServiceReference<?>> _applicationDependentResources =
-        ConcurrentHashMap.newKeySet();
-    private Collection<CachingServiceReference<Application>> _clashingApplications =
-        new CopyOnWriteArrayList<>();
-    private Collection<CachingServiceReference<Application>> _erroredApplications =
-        new CopyOnWriteArrayList<>();
-    private Collection<CachingServiceReference<?>> _erroredEndpoints =
-        new CopyOnWriteArrayList<>();
-    private Collection<CachingServiceReference<?>> _erroredExtensions =
-        new CopyOnWriteArrayList<>();
-    private Collection<CachingServiceReference<?>> _ungettableEndpoints =
-        new CopyOnWriteArrayList<>();
-    private Collection<CachingServiceReference<?>> _ungettableExtensions =
-        new CopyOnWriteArrayList<>();
-    private Set<CachingServiceReference<?>> _dependentServices =
-        ConcurrentHashMap.newKeySet();
-    private Collection<CachingServiceReference<?>> _invalidExtensions =
-        new CopyOnWriteArrayList<>();
-    private volatile Map<String, Object> _defaultApplicationProperties;
-
     public void addApplicationDependentExtension(
         CachingServiceReference<?> cachingServiceReference) {
 
@@ -155,6 +119,12 @@ public class AriesJaxRSServiceRuntime implements JaxRSServiceRuntime {
         _erroredEndpoints.add(serviceReference);
     }
 
+    public void addErroredExtension(
+        CachingServiceReference<?> cachingServiceReference) {
+
+        _erroredExtensions.add(cachingServiceReference);
+    }
+
     public void addInvalidExtension(
         CachingServiceReference<?> serviceReference) {
 
@@ -203,16 +173,6 @@ public class AriesJaxRSServiceRuntime implements JaxRSServiceRuntime {
         return _shadowedApplications.add(serviceReference);
     }
 
-    public static String getApplicationName(PropertyHolder properties) {
-        Object property = properties.get(JAX_RS_NAME);
-
-        if (property == null) {
-            return generateApplicationName(properties);
-        }
-
-        return property.toString();
-    }
-
     @Override
     public RuntimeDTO getRuntimeDTO() {
         RuntimeDTO runtimeDTO = new RuntimeDTO();
@@ -318,6 +278,12 @@ public class AriesJaxRSServiceRuntime implements JaxRSServiceRuntime {
         _erroredEndpoints.remove(serviceReference);
     }
 
+    public void removeErroredExtension(
+        CachingServiceReference<?> cachingServiceReference) {
+
+        _erroredExtensions.remove(cachingServiceReference);
+    }
+
     public void removeInvalidExtension(CachingServiceReference<?> serviceReference) {
         _invalidExtensions.remove(serviceReference);
     }
@@ -363,6 +329,115 @@ public class AriesJaxRSServiceRuntime implements JaxRSServiceRuntime {
     public Map<String, Object> unsetApplicationForPath(String path) {
         return _applications.remove(path);
     }
+    private ConcurrentHashMap<String, Map<String, Object>>
+        _applications = new ConcurrentHashMap<>();
+    private ConcurrentHashMap<String, Collection<CachingServiceReference<?>>>
+        _applicationEndpoints = new ConcurrentHashMap<>();
+    private ConcurrentHashMap<String, Collection<CachingServiceReference<?>>>
+        _applicationExtensions = new ConcurrentHashMap<>();
+    private Collection<CachingServiceReference<Application>>
+        _ungettableApplications = new CopyOnWriteArrayList<>();
+    private Collection<CachingServiceReference<Application>> _shadowedApplications =
+        new CopyOnWriteArrayList<>();
+    private Set<CachingServiceReference<Application>> _dependentApplications =
+        ConcurrentHashMap.newKeySet();
+    private Set<CachingServiceReference<?>> _applicationDependentExtensions =
+        ConcurrentHashMap.newKeySet();
+    private Set<CachingServiceReference<?>> _applicationDependentResources =
+        ConcurrentHashMap.newKeySet();
+    private Collection<CachingServiceReference<Application>> _clashingApplications =
+        new CopyOnWriteArrayList<>();
+    private Collection<CachingServiceReference<Application>> _erroredApplications =
+        new CopyOnWriteArrayList<>();
+    private Collection<CachingServiceReference<?>> _erroredEndpoints =
+        new CopyOnWriteArrayList<>();
+    private Collection<CachingServiceReference<?>> _erroredExtensions =
+        new CopyOnWriteArrayList<>();
+    private Collection<CachingServiceReference<?>> _ungettableEndpoints =
+        new CopyOnWriteArrayList<>();
+    private Collection<CachingServiceReference<?>> _ungettableExtensions =
+        new CopyOnWriteArrayList<>();
+    private Set<CachingServiceReference<?>> _dependentServices =
+        ConcurrentHashMap.newKeySet();
+    private Collection<CachingServiceReference<?>> _invalidExtensions =
+        new CopyOnWriteArrayList<>();
+    private volatile Map<String, Object> _defaultApplicationProperties;
+
+    private static FailedApplicationDTO buildFailedApplicationDTO(
+        int reason, CachingServiceReference<Application> serviceReference) {
+
+        FailedApplicationDTO failedApplicationDTO = new FailedApplicationDTO();
+
+        Object nameProperty = serviceReference.getProperty(
+            JaxRSWhiteboardConstants.JAX_RS_NAME);
+
+        failedApplicationDTO.name = nameProperty == null ?
+            generateApplicationName(serviceReference::getProperty) :
+            nameProperty.toString();
+        failedApplicationDTO.serviceId =
+            (long)serviceReference.getProperty("service.id");
+
+        failedApplicationDTO.failureReason = reason;
+
+        return failedApplicationDTO;
+    }
+
+    private static <T> BiFunction<String, Collection<T>, Collection<T>> merger(
+        T t) {
+
+        return (__, collection) -> {
+            if (collection == null) {
+                collection = new ArrayList<>();
+            }
+
+            collection.add(t);
+
+            return collection;
+        };
+    }
+
+    private static ExtensionDTO populateExtensionDTO(
+        ExtensionDTO extensionDTO, CachingServiceReference<?> serviceReference) {
+
+        extensionDTO.name = getApplicationName(serviceReference::getProperty);
+        extensionDTO.serviceId = (Long)serviceReference.getProperty(
+            "service.id");
+        extensionDTO.extensionTypes =
+            Arrays.stream(
+                canonicalize(serviceReference.getProperty("objectClass"))).
+            filter(
+                SUPPORTED_EXTENSION_INTERFACES::contains
+            ).
+            toArray(String[]::new);
+
+        return extensionDTO;
+    }
+
+    private static ResourceDTO populateResourceDTO(
+        ResourceDTO resourceDTO, CachingServiceReference<?> serviceReference) {
+
+        resourceDTO.name = getApplicationName(serviceReference::getProperty);
+        resourceDTO.serviceId = (Long)serviceReference.getProperty(
+            "service.id");
+
+        return resourceDTO;
+    }
+
+    private static <T> BiFunction<String, Collection<T>, Collection<T>> remover(
+        T t) {
+
+        return (__, collection) -> {
+            if (collection != null) {
+                collection.remove(t);
+
+                if (collection.isEmpty()) {
+                    return null;
+                }
+            }
+
+            return collection;
+        };
+    }
 
     private Stream<ApplicationDTO> applicationDTOStream() {
         return _applications.values().stream().
@@ -372,6 +447,20 @@ public class AriesJaxRSServiceRuntime implements JaxRSServiceRuntime {
             );
     }
 
+    private Stream<FailedExtensionDTO> applicationDependentExtensionsDTOStream() {
+        return _applicationDependentExtensions.stream().map(
+            sr -> buildFailedExtensionDTO(
+                DTOConstants.FAILURE_REASON_REQUIRED_APPLICATION_UNAVAILABLE, sr)
+        );
+    }
+
+    private Stream<FailedResourceDTO> applicationDependentResourcesDTOStream() {
+        return _applicationDependentResources.stream().map(
+            sr -> buildFailedResourceDTO(
+                DTOConstants.FAILURE_REASON_REQUIRED_APPLICATION_UNAVAILABLE, sr)
+        );
+    }
+
     private ApplicationDTO buildApplicationDTO(
         Map<String, Object> properties) {
 
@@ -460,7 +549,6 @@ public class AriesJaxRSServiceRuntime implements JaxRSServiceRuntime {
         );
     }
 
-
     private Stream<ResourceDTO> getApplicationEndpointsStream(String name) {
         Collection<CachingServiceReference<?>> applicationEndpoints =
             _applicationEndpoints.get(name);
@@ -498,20 +586,6 @@ public class AriesJaxRSServiceRuntime implements JaxRSServiceRuntime {
         );
     }
 
-    private Stream<FailedExtensionDTO> applicationDependentExtensionsDTOStream() {
-        return _applicationDependentExtensions.stream().map(
-            sr -> buildFailedExtensionDTO(
-                DTOConstants.FAILURE_REASON_REQUIRED_APPLICATION_UNAVAILABLE, sr)
-        );
-    }
-
-    private Stream<FailedResourceDTO> applicationDependentResourcesDTOStream() {
-        return _applicationDependentResources.stream().map(
-            sr -> buildFailedResourceDTO(
-                DTOConstants.FAILURE_REASON_REQUIRED_APPLICATION_UNAVAILABLE, sr)
-        );
-    }
-
     private Stream<FailedApplicationDTO> shadowedApplicationsDTOStream() {
         return _shadowedApplications.stream().
             map(sr -> buildFailedApplicationDTO(
@@ -540,80 +614,4 @@ public class AriesJaxRSServiceRuntime implements JaxRSServiceRuntime {
         );
     }
 
-    private static FailedApplicationDTO buildFailedApplicationDTO(
-        int reason, CachingServiceReference<Application> serviceReference) {
-
-        FailedApplicationDTO failedApplicationDTO = new FailedApplicationDTO();
-
-        Object nameProperty = serviceReference.getProperty(
-            JaxRSWhiteboardConstants.JAX_RS_NAME);
-
-        failedApplicationDTO.name = nameProperty == null ?
-            generateApplicationName(serviceReference::getProperty) :
-            nameProperty.toString();
-        failedApplicationDTO.serviceId =
-            (long)serviceReference.getProperty("service.id");
-
-        failedApplicationDTO.failureReason = reason;
-
-        return failedApplicationDTO;
-    }
-
-    private static <T> BiFunction<String, Collection<T>, Collection<T>> merger(
-        T t) {
-
-        return (__, collection) -> {
-            if (collection == null) {
-                collection = new ArrayList<>();
-            }
-
-            collection.add(t);
-
-            return collection;
-        };
-    }
-
-    private static ExtensionDTO populateExtensionDTO(
-        ExtensionDTO extensionDTO, CachingServiceReference<?> serviceReference) {
-
-        extensionDTO.name = getApplicationName(serviceReference::getProperty);
-        extensionDTO.serviceId = (Long)serviceReference.getProperty(
-            "service.id");
-        extensionDTO.extensionTypes =
-            Arrays.stream(
-                canonicalize(serviceReference.getProperty("objectClass"))).
-            filter(
-                SUPPORTED_EXTENSION_INTERFACES::contains
-            ).
-            toArray(String[]::new);
-
-        return extensionDTO;
-    }
-
-    private static ResourceDTO populateResourceDTO(
-        ResourceDTO resourceDTO, CachingServiceReference<?> serviceReference) {
-
-        resourceDTO.name = getApplicationName(serviceReference::getProperty);
-        resourceDTO.serviceId = (Long)serviceReference.getProperty(
-            "service.id");
-
-        return resourceDTO;
-    }
-
-    private static <T> BiFunction<String, Collection<T>, Collection<T>> remover(
-        T t) {
-
-        return (__, collection) -> {
-            if (collection != null) {
-                collection.remove(t);
-
-                if (collection.isEmpty()) {
-                    return null;
-                }
-            }
-
-            return collection;
-        };
-    }
-
 }
\ No newline at end of file