aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From csie...@apache.org
Subject aries-jax-rs-whiteboard git commit: cleanup changecount logic
Date Thu, 03 Aug 2017 17:38:43 GMT
Repository: aries-jax-rs-whiteboard
Updated Branches:
  refs/heads/master 14019e2d5 -> 3df0d7a93


cleanup changecount logic

Signed-off-by: Raymond Auge <rotty3000@apache.org>


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

Branch: refs/heads/master
Commit: 3df0d7a9305e744b754c7c40b7229a29d41fa871
Parents: 14019e2
Author: Raymond Auge <rotty3000@apache.org>
Authored: Thu Aug 3 13:13:03 2017 -0400
Committer: Raymond Auge <rotty3000@apache.org>
Committed: Thu Aug 3 13:13:03 2017 -0400

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


http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/3df0d7a9/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 e498e54..a9d87d0 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
@@ -72,14 +72,12 @@ import static org.osgi.service.jaxrs.whiteboard.JaxRSWhiteboardConstants.JAX_RS_
  */
 public class Whiteboard {
     public static OSGi<Void> createWhiteboard(Dictionary<String, ?> configuration)
{
-        AtomicLong changeCount = new AtomicLong();
-
         return
             bundleContext().flatMap(bundleContext ->
             just(createBus(bundleContext, configuration)).flatMap(bus ->
             just(createDefaultJaxRsServiceRegistrator(bus)).flatMap(defaultServiceRegistrator
->
             registerJaxRSServiceRuntime(bundleContext, bus, Maps.from(configuration)).flatMap(registratorRegistration
->
-            just(new ServiceRegistrationChangeCounter(changeCount, "service.changecount",
registratorRegistration)).flatMap(counter ->
+            just(new ServiceRegistrationChangeCounter(registratorRegistration)).flatMap(counter
->
                 all(
                     countChanges(whiteboardApplications(bus), counter),
                     countChanges(whiteBoardApplicationSingletons(), counter),
@@ -280,29 +278,22 @@ public class Whiteboard {
     private static class ServiceRegistrationChangeCounter
         implements ChangeCounter{
 
-        private final AtomicLong _atomicLong;
-        private String _property;
+        private static final String changecount = "service.changecount";
+        private final AtomicLong _atomicLong = new AtomicLong();
         private ServiceRegistration<?> _serviceRegistration;
         private final Hashtable<String, Object> _properties;
 
         public ServiceRegistrationChangeCounter(
-            AtomicLong atomicLong, String property,
             ServiceRegistration<?> serviceRegistration) {
 
-            _atomicLong = atomicLong;
-            _property = property;
             _serviceRegistration = serviceRegistration;
 
             ServiceReference<?> serviceReference =
                 _serviceRegistration.getReference();
 
-            String[] propertyKeys = serviceReference.getPropertyKeys();
-
             _properties = new Hashtable<>();
 
-            for (int i = 0; i < propertyKeys.length; i++) {
-                String propertyKey = propertyKeys[i];
-
+            for (String propertyKey : serviceReference.getPropertyKeys()) {
                 _properties.put(
                     propertyKey, serviceReference.getProperty(propertyKey));
             }
@@ -312,10 +303,11 @@ public class Whiteboard {
         public void inc() {
             long l = _atomicLong.incrementAndGet();
 
+            @SuppressWarnings("unchecked")
             Hashtable<String, Object> properties =
                 (Hashtable<String, Object>)_properties.clone();
 
-            properties.put(_property, l);
+            properties.put(changecount, l);
 
             _serviceRegistration.setProperties(properties);
         }


Mime
View raw message