You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:27:47 UTC

[sling-org-apache-sling-discovery-commons] 12/16: SLING-6837 : Migrate to R6 annotations

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.discovery.commons-1.0.20
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-commons.git

commit d4f4b13132d9b1b380ff3bb37801d24c0c426951
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon May 8 05:48:28 2017 +0000

    SLING-6837 : Migrate to R6 annotations
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/commons@1794285 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            | 41 ++++++----------------
 .../sling/discovery/commons/package-info.java      |  3 +-
 .../commons/providers/base/package-info.java       |  3 +-
 .../discovery/commons/providers/package-info.java  |  3 +-
 .../commons/providers/spi/base/IdMapService.java   | 38 ++++++++++----------
 .../spi/base/OakBacklogClusterSyncService.java     | 25 +++++++------
 .../providers/spi/base/SyncTokenService.java       | 21 ++++++-----
 .../commons/providers/spi/base/package-info.java   |  5 ++-
 .../commons/providers/spi/package-info.java        |  3 +-
 .../commons/providers/util/package-info.java       |  3 +-
 10 files changed, 64 insertions(+), 81 deletions(-)

diff --git a/pom.xml b/pom.xml
index 78e7b7a..2e9cfc3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>26</version>
+        <version>30</version>
         <relativePath />
     </parent>
 
@@ -53,10 +53,10 @@
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
                 <extensions>true</extensions>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-scr-plugin</artifactId>
+                <configuration>
+                  <!-- Disable baseline check for 1.0.20 release -->
+                    <skip>true</skip>
+                </configuration>
             </plugin>
 			<!-- discovery.commons exports a few test classes for reuse.
                  In order for others to use these, the test-jar must be built/installed too.
@@ -97,23 +97,15 @@
     </profiles>
     <dependencies>
         <dependency>
-            <groupId>org.apache.felix</groupId>
-            <artifactId>org.apache.felix.scr.annotations</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>biz.aQute</groupId>
-            <artifactId>bndlib</artifactId>
-        </dependency>
-        <dependency>
-        	<groupId>org.apache.sling</groupId>
-        	<artifactId>org.apache.sling.commons.scheduler</artifactId>
-        	<version>2.4.0</version>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.discovery.api</artifactId>
+            <version>1.0.0</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.discovery.api</artifactId>
-            <version>1.0.0</version>
+            <artifactId>org.apache.sling.commons.scheduler</artifactId>
+            <version>2.4.0</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
@@ -137,8 +129,6 @@
 		<dependency>
 			<groupId>javax.jcr</groupId>
 			<artifactId>jcr</artifactId>
-			<version>2.0</version>
-			<scope>provided</scope>
 		</dependency>
         <dependency>
         	<groupId>org.apache.sling</groupId>
@@ -168,12 +158,6 @@
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>osgi.core</artifactId>
-            <version>6.0.0</version>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.compendium</artifactId>
         </dependency>
         <dependency>
             <groupId>org.apache.jackrabbit</groupId>
@@ -189,18 +173,16 @@
         </dependency>
 		<dependency>
 			<groupId>javax.servlet</groupId>
-			<artifactId>servlet-api</artifactId>
+			<artifactId>javax.servlet-api</artifactId>
         	<scope>test</scope>
 		</dependency>
         <dependency>
             <groupId>com.google.code.findbugs</groupId>
             <artifactId>jsr305</artifactId>
-            <version>2.0.0</version>
         </dependency>
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
-            <version>1.6.1</version>
         </dependency>
         <!-- Testing -->
         <dependency>
@@ -249,7 +231,6 @@
             <!-- with 2.5.1 jmock-junit4, which has a dependency on junit 4.4 
                 you get the following: NoSuchMethodError: org.junit.runner.Request.classes(Lorg/junit/runner/Computer;[Ljava/lang/Class;)Lorg/junit/runner/Request; 
                 hence this explicit newer dependency. -->
-            <version>2.8.2</version>
         </dependency>
     </dependencies>
 </project>
diff --git a/src/main/java/org/apache/sling/discovery/commons/package-info.java b/src/main/java/org/apache/sling/discovery/commons/package-info.java
index 81c665b..a6d0fab 100644
--- a/src/main/java/org/apache/sling/discovery/commons/package-info.java
+++ b/src/main/java/org/apache/sling/discovery/commons/package-info.java
@@ -25,5 +25,4 @@
 @Version("1.2.0")
 package org.apache.sling.discovery.commons;
 
-import aQute.bnd.annotation.Version;
-
+import org.osgi.annotation.versioning.Version;
diff --git a/src/main/java/org/apache/sling/discovery/commons/providers/base/package-info.java b/src/main/java/org/apache/sling/discovery/commons/providers/base/package-info.java
index 394e219..9d9bd43 100644
--- a/src/main/java/org/apache/sling/discovery/commons/providers/base/package-info.java
+++ b/src/main/java/org/apache/sling/discovery/commons/providers/base/package-info.java
@@ -25,5 +25,4 @@
 @Version("1.0.0")
 package org.apache.sling.discovery.commons.providers.base;
 
-import aQute.bnd.annotation.Version;
-
+import org.osgi.annotation.versioning.Version;
diff --git a/src/main/java/org/apache/sling/discovery/commons/providers/package-info.java b/src/main/java/org/apache/sling/discovery/commons/providers/package-info.java
index 067d576..5242a84 100644
--- a/src/main/java/org/apache/sling/discovery/commons/providers/package-info.java
+++ b/src/main/java/org/apache/sling/discovery/commons/providers/package-info.java
@@ -25,5 +25,4 @@
 @Version("1.0.0")
 package org.apache.sling.discovery.commons.providers;
 
-import aQute.bnd.annotation.Version;
-
+import org.osgi.annotation.versioning.Version;
diff --git a/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/IdMapService.java b/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/IdMapService.java
index 22c34d4..1de1dbc 100644
--- a/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/IdMapService.java
+++ b/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/IdMapService.java
@@ -27,11 +27,6 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.Service;
 import org.apache.sling.api.resource.LoginException;
 import org.apache.sling.api.resource.ModifiableValueMap;
 import org.apache.sling.api.resource.PersistenceException;
@@ -39,31 +34,38 @@ import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.api.resource.ResourceResolverFactory;
 import org.apache.sling.api.resource.ValueMap;
-import org.apache.sling.api.resource.observation.ResourceChangeListener;
 import org.apache.sling.api.resource.observation.ResourceChange;
 import org.apache.sling.api.resource.observation.ResourceChange.ChangeType;
+import org.apache.sling.api.resource.observation.ResourceChangeListener;
 import org.apache.sling.discovery.commons.providers.util.ResourceHelper;
 import org.apache.sling.settings.SlingSettingsService;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.component.annotations.ReferencePolicyOption;
 
 /**
  * The IdMapService is responsible for storing a slingId-clusterNodeId
  * pair to the repository and given all other instances in the cluster
  * do the same can map clusterNodeIds to slingIds (or vice-versa)
  */
-@Component(immediate = false)
-@Service(value = { IdMapService.class })
+@Component(service = { IdMapService.class },
+    property = {
+            Constants.SERVICE_VENDOR + "=The Apache Software Foundation"
+    })
 public class IdMapService extends AbstractServiceWithBackgroundCheck implements ResourceChangeListener {
 
-    @Reference
+    @Reference(policyOption=ReferencePolicyOption.GREEDY)
     private ResourceResolverFactory resourceResolverFactory;
 
-    @Reference
+    @Reference(policyOption=ReferencePolicyOption.GREEDY)
     private SlingSettingsService settingsService;
 
-    @Reference
+    @Reference(policyOption=ReferencePolicyOption.GREEDY)
     private DiscoveryLiteConfig commonsConfig;
 
     private boolean initialized = false;
@@ -72,19 +74,19 @@ public class IdMapService extends AbstractServiceWithBackgroundCheck implements
 
     private long me;
 
-    private final Map<Integer, String> oldIdMapCache = new HashMap<Integer, String>();
-    private final Map<Integer, String> idMapCache = new HashMap<Integer, String>();
+    private final Map<Integer, String> oldIdMapCache = new HashMap<>();
+    private final Map<Integer, String> idMapCache = new HashMap<>();
 
     private long lastCacheInvalidation = -1;
 
     private BundleContext bundleContext;
 
     private volatile ServiceRegistration<ResourceChangeListener> eventHandlerRegistration;
-    
+
     /** test-only constructor **/
     public static IdMapService testConstructor(
             DiscoveryLiteConfig commonsConfig,
-            SlingSettingsService settingsService, 
+            SlingSettingsService settingsService,
             ResourceResolverFactory resourceResolverFactory) {
         IdMapService service = new IdMapService();
         service.commonsConfig = commonsConfig;
@@ -128,7 +130,7 @@ public class IdMapService extends AbstractServiceWithBackgroundCheck implements
             logger.info("registerEventHandler: bundleContext is null - cannot register");
             return;
         }
-        Dictionary<String,Object> properties = new Hashtable<String,Object>();
+        Dictionary<String,Object> properties = new Hashtable<>();
         properties.put(Constants.SERVICE_DESCRIPTION, "IdMap Change Listener.");
         properties.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation");
         String[] topics = new String[] {
@@ -196,7 +198,7 @@ public class IdMapService extends AbstractServiceWithBackgroundCheck implements
             // or when my clusterNodeId is already mapped to another slingId
             // in both cases: clean that up
             boolean foundMe = false;
-            for (String aKey : new HashSet<String>(idmap.keySet())) {
+            for (String aKey : new HashSet<>(idmap.keySet())) {
                 Object value = idmap.get(aKey);
                 if (value instanceof Number) {
                     Number n = (Number)value;
@@ -299,7 +301,7 @@ public class IdMapService extends AbstractServiceWithBackgroundCheck implements
     private Map<Integer, String> readIdMap(ResourceResolver resourceResolver) throws PersistenceException {
         Resource resource = ResourceHelper.getOrCreateResource(resourceResolver, getIdMapPath());
         ValueMap idmapValueMap = resource.adaptTo(ValueMap.class);
-        Map<Integer, String> idmap = new HashMap<Integer, String>();
+        Map<Integer, String> idmap = new HashMap<>();
         for (String slingId : idmapValueMap.keySet()) {
             Object value = idmapValueMap.get(slingId);
             if (value instanceof Number) {
diff --git a/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/OakBacklogClusterSyncService.java b/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/OakBacklogClusterSyncService.java
index 3185043..f171728 100644
--- a/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/OakBacklogClusterSyncService.java
+++ b/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/OakBacklogClusterSyncService.java
@@ -23,10 +23,6 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.Service;
 import org.apache.sling.api.resource.LoginException;
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.api.resource.ResourceResolverFactory;
@@ -35,13 +31,20 @@ import org.apache.sling.discovery.InstanceDescription;
 import org.apache.sling.discovery.commons.providers.BaseTopologyView;
 import org.apache.sling.discovery.commons.providers.spi.ClusterSyncService;
 import org.apache.sling.settings.SlingSettingsService;
+import org.osgi.framework.Constants;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.component.annotations.ReferencePolicyOption;
 
 /**
  * The OakBacklogClusterSyncService will wait until all instances
  * in the local cluster are no longer in any backlog state.
  */
-@Component(immediate = false)
-@Service(value = { ClusterSyncService.class, OakBacklogClusterSyncService.class })
+@Component(service = { ClusterSyncService.class, OakBacklogClusterSyncService.class },
+            property = {
+                    Constants.SERVICE_VENDOR + "=The Apache Software Foundation"
+            })
 public class OakBacklogClusterSyncService extends AbstractServiceWithBackgroundCheck implements ClusterSyncService {
 
     static enum BacklogStatus {
@@ -50,16 +53,16 @@ public class OakBacklogClusterSyncService extends AbstractServiceWithBackgroundC
         NO_BACKLOG /* when oak's discovery lite descriptor declared we're backlog-free now */
     }
 
-    @Reference
+    @Reference(policyOption=ReferencePolicyOption.GREEDY)
     private IdMapService idMapService;
 
-    @Reference
+    @Reference(policyOption=ReferencePolicyOption.GREEDY)
     protected DiscoveryLiteConfig commonsConfig;
 
-    @Reference
+    @Reference(policyOption=ReferencePolicyOption.GREEDY)
     protected ResourceResolverFactory resourceResolverFactory;
 
-    @Reference
+    @Reference(policyOption=ReferencePolicyOption.GREEDY)
     protected SlingSettingsService settingsService;
 
     private ClusterSyncHistory consistencyHistory = new ClusterSyncHistory();
@@ -203,7 +206,7 @@ public class OakBacklogClusterSyncService extends AbstractServiceWithBackgroundC
             }
 
             ClusterView cluster = view.getLocalInstance().getClusterView();
-            Set<String> slingIds = new HashSet<String>();
+            Set<String> slingIds = new HashSet<>();
             for (InstanceDescription instance : cluster.getInstances()) {
                 slingIds.add(instance.getSlingId());
             }
diff --git a/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/SyncTokenService.java b/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/SyncTokenService.java
index dd57256..91c6ceb 100644
--- a/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/SyncTokenService.java
+++ b/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/SyncTokenService.java
@@ -18,10 +18,6 @@
  */
 package org.apache.sling.discovery.commons.providers.spi.base;
 
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.Service;
 import org.apache.sling.api.resource.LoginException;
 import org.apache.sling.api.resource.ModifiableValueMap;
 import org.apache.sling.api.resource.PersistenceException;
@@ -34,6 +30,11 @@ import org.apache.sling.discovery.commons.providers.BaseTopologyView;
 import org.apache.sling.discovery.commons.providers.spi.ClusterSyncService;
 import org.apache.sling.discovery.commons.providers.util.ResourceHelper;
 import org.apache.sling.settings.SlingSettingsService;
+import org.osgi.framework.Constants;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.component.annotations.ReferencePolicyOption;
 
 /**
  * Implements the syncToken idea: each instance stores a key-value
@@ -45,17 +46,19 @@ import org.apache.sling.settings.SlingSettingsService;
  * (thus all topology-dependent activity is now stalled and waiting)
  * and are aware of the new discoveryLite view.
  */
-@Component(immediate = false)
-@Service(value = { ClusterSyncService.class, SyncTokenService.class })
+@Component(service = { ClusterSyncService.class, SyncTokenService.class },
+    property = {
+            Constants.SERVICE_VENDOR + "=The Apache Software Foundation"
+    })
 public class SyncTokenService extends AbstractServiceWithBackgroundCheck implements ClusterSyncService {
 
-    @Reference
+    @Reference(policyOption=ReferencePolicyOption.GREEDY)
     protected DiscoveryLiteConfig commonsConfig;
 
-    @Reference
+    @Reference(policyOption=ReferencePolicyOption.GREEDY)
     protected ResourceResolverFactory resourceResolverFactory;
 
-    @Reference
+    @Reference(policyOption=ReferencePolicyOption.GREEDY)
     protected SlingSettingsService settingsService;
 
     protected ClusterSyncHistory clusterSyncHistory = new ClusterSyncHistory();
diff --git a/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/package-info.java b/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/package-info.java
index 8a66f21..a191f55 100644
--- a/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/package-info.java
+++ b/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/package-info.java
@@ -22,8 +22,7 @@
  *
  * @version 2.0.0
  */
-@Version("2.0.0")
+@Version("2.1.0")
 package org.apache.sling.discovery.commons.providers.spi.base;
 
-import aQute.bnd.annotation.Version;
-
+import org.osgi.annotation.versioning.Version;
diff --git a/src/main/java/org/apache/sling/discovery/commons/providers/spi/package-info.java b/src/main/java/org/apache/sling/discovery/commons/providers/spi/package-info.java
index e09f0f5..df9d9f2 100644
--- a/src/main/java/org/apache/sling/discovery/commons/providers/spi/package-info.java
+++ b/src/main/java/org/apache/sling/discovery/commons/providers/spi/package-info.java
@@ -25,5 +25,4 @@
 @Version("1.0.0")
 package org.apache.sling.discovery.commons.providers.spi;
 
-import aQute.bnd.annotation.Version;
-
+import org.osgi.annotation.versioning.Version;
diff --git a/src/main/java/org/apache/sling/discovery/commons/providers/util/package-info.java b/src/main/java/org/apache/sling/discovery/commons/providers/util/package-info.java
index 242bce5..b4778b2 100644
--- a/src/main/java/org/apache/sling/discovery/commons/providers/util/package-info.java
+++ b/src/main/java/org/apache/sling/discovery/commons/providers/util/package-info.java
@@ -25,5 +25,4 @@
 @Version("1.0.0")
 package org.apache.sling.discovery.commons.providers.util;
 
-import aQute.bnd.annotation.Version;
-
+import org.osgi.annotation.versioning.Version;

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.