[maven-release-plugin] copy for tag org.apache.sling.discovery.commons-1.0.20

git-svn-id: https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.discovery.commons-1.0.20@1794305 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/pom.xml b/pom.xml
index 00159c1..6583f77 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/InitDelayingTopologyEventListener.java b/src/main/java/org/apache/sling/discovery/commons/InitDelayingTopologyEventListener.java
index 4014f80..04320f3 100644
--- a/src/main/java/org/apache/sling/discovery/commons/InitDelayingTopologyEventListener.java
+++ b/src/main/java/org/apache/sling/discovery/commons/InitDelayingTopologyEventListener.java
@@ -18,7 +18,8 @@
  */
 package org.apache.sling.discovery.commons;
 
-import java.sql.Date;
+import java.util.Timer;
+import java.util.TimerTask;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.sling.commons.scheduler.Scheduler;
@@ -42,7 +43,7 @@
  *      (as the discovery API says the first event received is an INIT event).
  *      </li>
  *  <li>if the last event received was not a CHANGING event
- *      (ie it was an INIT, CHANGED or PROPERTIES), then 
+ *      (ie it was an INIT, CHANGED or PROPERTIES), then
  *      as soon as the startup time passes this facade will simulate
  *      an INIT event
  *      (again, as the discovery API says the first event received is an INIT event)
@@ -51,7 +52,7 @@
  * Note that users of this facade must call dispose to avoid any async calls
  * to the delegate after startup, in case they themselves are deactivated!
  * @since 1.1.0
- */
+ **/
 public class InitDelayingTopologyEventListener implements TopologyEventListener {
 
     /** the logger used by this listener - can be set in the constructor optionally to fit better into user log structure */
@@ -67,32 +68,37 @@
     private final AtomicBoolean active = new AtomicBoolean(false);
 
     /** flag indicating whether we're still delaying or not **/
-    private boolean delaying = true;
-    
-    /** the last pending delayed event - we only have to keep the last event to support all different cases **/
-    private TopologyEvent pendingDelayedEvent = null;
+    private volatile boolean delaying = true;
 
-    /** 
+    /** the last pending delayed event - we only have to keep the last event to support all different cases **/
+    private volatile TopologyEvent pendingDelayedEvent;
+
+    /**
      * Creates a new init-delaying listener with the given delay, delegate and scheduler.
      * <p>
      * For properly disposing the caller should use the dispose method!
+     * @param startupDelay The startup delay in seconds
+     * @param delegate The topology event listener
      * @see #dispose()
      */
-    public InitDelayingTopologyEventListener(final long startupDelay, final TopologyEventListener delegate, final Scheduler scheduler) {
-        this(startupDelay, delegate, scheduler, null);
+    public InitDelayingTopologyEventListener(final long startupDelay,
+            final TopologyEventListener delegate) {
+        this(startupDelay, delegate, (Logger)null);
     }
 
     /**
      * Creates a new init-delaying listener with the given delay, delegate, scheduler and optinoal logger.
      * <p>
      * For properly disposing the caller should use the dispose method!
+     * @param startupDelay The startup delay in seconds
+     * @param delegate The topology event listener
+     * @param loggerOrNull Optional logger instance
      * @see #dispose()
      */
-    public InitDelayingTopologyEventListener(final long startupDelay, final TopologyEventListener delegate, 
-            final Scheduler scheduler, final Logger loggerOrNull) {
-        if ( scheduler == null ) {
-            throw new IllegalArgumentException("scheduler must not be null");
-        }
+    public InitDelayingTopologyEventListener(final long startupDelay,
+            final TopologyEventListener delegate,
+            final Logger loggerOrNull) {
+
         if ( delegate == null ) {
             throw new IllegalArgumentException("delegate must not be null");
         }
@@ -106,13 +112,13 @@
             this.logger = LoggerFactory.getLogger(this.getClass());
         }
         final Runnable r = new Runnable() {
-            
+
             @Override
             public void run() {
                 if (InitDelayingTopologyEventListener.this.active.get()) {
                     // only call afterStartupDelay if we're active
                     // (to avoid this call if disposed in the meantime)
-                    
+
                     // and since after disposing this listener is no longer
                     // used - ie it is a throw-away - you can create
                     // such a listener on each activate and dispose it on
@@ -123,20 +129,59 @@
                 }
             }
         };
-        
+
         // mark this listener as active
         this.active.set(true);
 
-        // schedule me if you can
-        if ( !scheduler.schedule(r, scheduler.AT(new Date(System.currentTimeMillis() + startupDelay * 1000))) ) {
-            // if for whatever reason scheduling doesn't work, let's run now
-            logger.warn("activate: could not schedule startupDelay handler with scheduler ({}) - "
-                    + "thus starting ({}) immediately", scheduler, delegate);
-            r.run();
-        }
+        // schedule me
+        final Timer timer = new Timer();
+        final TimerTask task = new TimerTask() {
+
+            @Override
+            public void run() {
+                r.run();
+            }
+        };
+        timer.schedule(task, startupDelay * 1000);
         // SLING-5560 : at this point either r is invoked immediately or scheduled after the delay
     }
-    
+
+    /**
+     * Creates a new init-delaying listener with the given delay, delegate and scheduler.
+     * <p>
+     * For properly disposing the caller should use the dispose method!
+     * @param startupDelay The startup delay in seconds
+     * @param delegate The topology event listener
+     * @param scheduler Scheduler to schedule the delay (not used)
+     * @see #dispose()
+     * @deprecated Use {@link InitDelayingTopologyEventListener#InitDelayingTopologyEventListener(long, TopologyEventListener)}
+     */
+    @Deprecated
+    public InitDelayingTopologyEventListener(final long startupDelay,
+            final TopologyEventListener delegate,
+            final Scheduler scheduler) {
+        this(startupDelay, delegate, scheduler, null);
+    }
+
+    /**
+     * Creates a new init-delaying listener with the given delay, delegate, scheduler and optinoal logger.
+     * <p>
+     * For properly disposing the caller should use the dispose method!
+     * @param startupDelay The startup delay in seconds
+     * @param delegate The topology event listener
+     * @param scheduler Scheduler to schedule the delay (not used)
+     * @param loggerOrNull Optional logger instance
+     * @see #dispose()
+     * @deprecated Use {@link InitDelayingTopologyEventListener#InitDelayingTopologyEventListener(long, TopologyEventListener, Logger)}
+     */
+    @Deprecated
+    public InitDelayingTopologyEventListener(final long startupDelay,
+            final TopologyEventListener delegate,
+            final Scheduler scheduler,
+            final Logger loggerOrNull) {
+        this(startupDelay, delegate, loggerOrNull);
+    }
+
     @Override
     public void handleTopologyEvent(TopologyEvent event) {
         synchronized ( syncObj ) {
@@ -146,7 +191,7 @@
                 // event
                 this.logger.debug("handleTopologyEvent: delaying processing of received topology event (startup delay active) {}", event);
                 this.pendingDelayedEvent = event;
-                
+
                 // and we're delaying - so stop processing now and return
                 return;
             } else if ( this.pendingDelayedEvent != null ) {
@@ -157,7 +202,7 @@
                 // in afterStartupDelay).
                 // which means that we must now convert the new event into an INIT
                 // to ensure our code gets an INIT first thing
-                
+
                 // paranoia check:
                 if ( event.getType() == Type.TOPOLOGY_CHANGING ) {
                     // this should never happen - but if it does, rinse and repeat
@@ -180,14 +225,14 @@
         // no delaying applicable - call delegate
         this.delegate.handleTopologyEvent(event);
     }
-    
+
     /**
      * Marks this listener as no longer active - ensures that it doesn't call the delegate
      * via any potentially pending scheduler callback.
      * <p>
      * Note that after dispose you can *still* call handleTopologyEvent and the events
-     * are passed to the delegate - but those are expected to be 'late' events and not 
-     * really part of the normal game. Hence, the caller must also ensure that the 
+     * are passed to the delegate - but those are expected to be 'late' events and not
+     * really part of the normal game. Hence, the caller must also ensure that the
      * handleTopologyEvent method isn't called anymore (which typically is automatically
      * guaranteed since the caller is typically an osgi service that gets unregistered anyway)
      */
@@ -204,7 +249,7 @@
         synchronized ( this.syncObj ) {
             // stop any future delaying
             this.delaying = false;
-            
+
             if ( this.pendingDelayedEvent == null ) {
                 // if no event received while we delayed,
                 // then we don't have to do anything later
@@ -214,25 +259,25 @@
                 // if the last delayed event was CHANGING
                 // then we must convert the next upcoming CHANGED, PROPERTIES
                 // into an INIT
-                
+
                 // and the way this is done in this class is by leving this
                 // event sit in this.pendingDelayedEvent, for grabs in handleTopologyEvent later
                 this.logger.debug("afterStartupDelay: startup delay passed, pending delayed event was CHANGING. "
                         + "Waiting for next stable topology event");
             } else {
                 // otherwise the last delayed event was either an INIT, CHANGED or PROPERTIES
-                // - but in any case we definitely never 
+                // - but in any case we definitely never
                 // processed any INIT - and our code expects an INIT
                 // as the first event ever..
-                
+
                 // so we now convert the event into an INIT
-                final TopologyEvent artificialInitEvent = 
+                final TopologyEvent artificialInitEvent =
                         new TopologyEvent(Type.TOPOLOGY_INIT, null, this.pendingDelayedEvent.getNewView());
-                
+
                 this.logger.debug("afterStartupDelay: startup delay passed, last pending delayed event was stable ({}). "
-                        + "Simulating an INIT event with that view: {}", this.pendingDelayedEvent, artificialInitEvent); 
+                        + "Simulating an INIT event with that view: {}", this.pendingDelayedEvent, artificialInitEvent);
                 this.pendingDelayedEvent = null;
-                
+
                 // call the delegate.
                 // we must do this call in the synchronized block
                 // to ensure any concurrent new event waits properly
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 427fb1a..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
@@ -20,10 +20,9 @@
 /**
  * Provides commons utility for users for the Discovery API.
  *
- * @version 1.0.0
+ * @version 1.2.0
  */
-@Version("1.1.0")
+@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.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.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 @@
 
     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 @@
             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 @@
             // 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 @@
     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.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.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 @@
         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 @@
             }
 
             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.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 @@
  * (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;
diff --git a/src/test/java/org/apache/sling/discovery/commons/TestInitDelayingTopologyEventListener.java b/src/test/java/org/apache/sling/discovery/commons/TestInitDelayingTopologyEventListener.java
index 8f224da..f49233f 100644
--- a/src/test/java/org/apache/sling/discovery/commons/TestInitDelayingTopologyEventListener.java
+++ b/src/test/java/org/apache/sling/discovery/commons/TestInitDelayingTopologyEventListener.java
@@ -45,13 +45,13 @@
 import org.slf4j.LoggerFactory;
 
 public class TestInitDelayingTopologyEventListener {
-    
+
     private final Logger logger = LoggerFactory.getLogger(this.getClass());
-    
+
     class TestListener implements TopologyEventListener {
 
         private List<TopologyEvent> events = new LinkedList<TopologyEvent>();
-        
+
         @Override
         public void handleTopologyEvent(TopologyEvent event) {
             synchronized(events) {
@@ -59,7 +59,7 @@
                 events.notifyAll();
             }
         }
-        
+
         public List<TopologyEvent> getEvents() {
             synchronized(events) {
                 return events;
@@ -213,7 +213,7 @@
     @Test
     public void testConstructor() throws Exception {
         final TopologyEventListener delegate = new TopologyEventListener() {
-            
+
             @Override
             public void handleTopologyEvent(TopologyEvent event) {
                 // nothing here atm
@@ -239,12 +239,6 @@
             // ok
         }
         try{
-            new InitDelayingTopologyEventListener(1, delegate, null);
-            fail("should complain");
-        } catch(IllegalArgumentException re) {
-            // ok
-        }
-        try{
             new InitDelayingTopologyEventListener(-1, delegate, scheduler, null);
             fail("should complain");
         } catch(IllegalArgumentException re) {
@@ -263,12 +257,6 @@
             // ok
         }
         try{
-            new InitDelayingTopologyEventListener(1, delegate, null, null);
-            fail("should complain");
-        } catch(IllegalArgumentException re) {
-            // ok
-        }
-        try{
             new InitDelayingTopologyEventListener(-1, delegate, scheduler, logger);
             fail("should complain");
         } catch(IllegalArgumentException re) {
@@ -286,14 +274,8 @@
         } catch(IllegalArgumentException re) {
             // ok
         }
-        try{
-            new InitDelayingTopologyEventListener(1, delegate, null, logger);
-            fail("should complain");
-        } catch(IllegalArgumentException re) {
-            // ok
-        }
     }
-    
+
     private TopologyView createView(boolean current) {
         final TopologyView view = Mockito.mock(TopologyView.class);
         Mockito.when(view.isCurrent()).thenReturn(current);
@@ -331,7 +313,7 @@
             }
         }
     }
-    
+
     @Test
     public void testDisposing() throws Exception {
         final TestListener delegate = new TestListener();
@@ -347,7 +329,7 @@
         delegate.assureEventCnt(1, 1000);
         delegate.assureEventCnt(1, 500);
     }
-    
+
     @Test
     public void testNoEvents() throws Exception {
         final TestListener delegate = new TestListener();
@@ -355,7 +337,7 @@
         InitDelayingTopologyEventListener listener = new InitDelayingTopologyEventListener(1, delegate, scheduler, logger);
         // no events:
         delegate.assureEventCnt(0, 1500);
-        
+
         // then the first init is passed through
         listener.handleTopologyEvent(createEvent(Type.TOPOLOGY_INIT));
         delegate.waitForEventCnt(1, 5000);