You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2019/05/28 12:48:31 UTC

[sling-org-apache-sling-extensions-webconsolesecurityprovider] branch master updated: SLING-8442 : Remove dependency from launchpad starter api

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

cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-extensions-webconsolesecurityprovider.git


The following commit(s) were added to refs/heads/master by this push:
     new 1a69cca  SLING-8442 : Remove dependency from launchpad starter api
1a69cca is described below

commit 1a69ccaaaa811de6bd67d26bd132bbb883a5178e
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Tue May 28 14:48:23 2019 +0200

    SLING-8442 : Remove dependency from launchpad starter api
---
 bnd.bnd                                            | 12 +++++++
 pom.xml                                            | 34 ++----------------
 .../internal/Activator.java                        | 11 +-----
 .../internal/ServicesListener.java                 | 42 +++-------------------
 4 files changed, 19 insertions(+), 80 deletions(-)

diff --git a/bnd.bnd b/bnd.bnd
new file mode 100644
index 0000000..40a6f22
--- /dev/null
+++ b/bnd.bnd
@@ -0,0 +1,12 @@
+Bundle-Activator: org.apache.sling.extensions.webconsolesecurityprovider.internal.Activator
+
+Import-Package:\
+  !org.apache.sling.auth.core,\
+  !org.apache.sling.api.auth,\
+  !org.apache.sling.api.resource,\
+  *
+
+DynamicImport-Package:\
+  org.apache.sling.api.auth;version="[1.0,2)",\
+  org.apache.sling.api.resource;version="[2.3,3)",\
+  org.apache.sling.auth.core;version="[1.0,2)"
diff --git a/pom.xml b/pom.xml
index 561915b..b14ee1c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -19,16 +19,15 @@
 
     <modelVersion>4.0.0</modelVersion>
     <parent>
-        <artifactId>sling</artifactId>
+        <artifactId>sling-bundle-parent</artifactId>
         <groupId>org.apache.sling</groupId>
-        <version>30</version>
+        <version>35</version>
         <relativePath />
     </parent>
 
     <groupId>org.apache.sling</groupId>
     <artifactId>org.apache.sling.extensions.webconsolesecurityprovider</artifactId>
     <version>1.2.1-SNAPSHOT</version>
-    <packaging>bundle</packaging>
 
     <name>Apache Sling Web Console Security Provider</name>
     <description>
@@ -49,29 +48,6 @@
     <build>
         <plugins>
             <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-bundle-plugin</artifactId>
-                <extensions>true</extensions>
-                <configuration>
-                    <instructions>
-                        <Bundle-Activator>
-                            org.apache.sling.extensions.webconsolesecurityprovider.internal.Activator
-                        </Bundle-Activator>
-                        <Import-Package>
-                            !org.apache.sling.auth.core,
-                            !org.apache.sling.api.auth,
-                            !org.apache.sling.api.resource,
-                            *
-                        </Import-Package>
-                        <DynamicImport-Package>
-                            org.apache.sling.api.auth;version="[1.0,2)",
-                            org.apache.sling.api.resource;version="[2.3,3)",
-                            org.apache.sling.auth.core;version="[1.0,2)"
-                        </DynamicImport-Package>
-                    </instructions>                
-                </configuration>
-            </plugin>
-            <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-javadoc-plugin</artifactId>
                 <configuration>
@@ -111,12 +87,6 @@
             <scope>provided</scope>
         </dependency>
         <dependency>
-            <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.launchpad.api</artifactId>
-            <version>1.1.0</version>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
             <groupId>javax.servlet</groupId>
             <artifactId>javax.servlet-api</artifactId>
         </dependency>
diff --git a/src/main/java/org/apache/sling/extensions/webconsolesecurityprovider/internal/Activator.java b/src/main/java/org/apache/sling/extensions/webconsolesecurityprovider/internal/Activator.java
index 99ef6f3..0339c5d 100644
--- a/src/main/java/org/apache/sling/extensions/webconsolesecurityprovider/internal/Activator.java
+++ b/src/main/java/org/apache/sling/extensions/webconsolesecurityprovider/internal/Activator.java
@@ -16,24 +16,19 @@
  */
 package org.apache.sling.extensions.webconsolesecurityprovider.internal;
 
-import org.apache.sling.launchpad.api.StartupListener;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
 
 public class Activator implements BundleActivator {
 
     private ServicesListener listener;
 
-    private ServiceRegistration<StartupListener> registration;
-
     /**
      * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
      */
     @Override
     public void start(final BundleContext context) throws Exception {
         listener = new ServicesListener(context);
-        registration = context.registerService(StartupListener.class, listener, null);
     }
 
     /**
@@ -41,11 +36,7 @@ public class Activator implements BundleActivator {
      */
     @Override
     public void stop(final BundleContext context) throws Exception {
-        if ( registration != null ) {
-            registration.unregister();
-            registration = null;
-        }
-        if ( listener != null ) {
+        if (listener != null) {
             listener.deactivate();
             listener = null;
         }
diff --git a/src/main/java/org/apache/sling/extensions/webconsolesecurityprovider/internal/ServicesListener.java b/src/main/java/org/apache/sling/extensions/webconsolesecurityprovider/internal/ServicesListener.java
index b4b78fd..801b3e5 100644
--- a/src/main/java/org/apache/sling/extensions/webconsolesecurityprovider/internal/ServicesListener.java
+++ b/src/main/java/org/apache/sling/extensions/webconsolesecurityprovider/internal/ServicesListener.java
@@ -21,11 +21,8 @@ package org.apache.sling.extensions.webconsolesecurityprovider.internal;
 
 import java.util.Dictionary;
 import java.util.Hashtable;
-import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.felix.webconsole.WebConsoleSecurityProvider;
-import org.apache.sling.launchpad.api.StartupListener;
-import org.apache.sling.launchpad.api.StartupMode;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.InvalidSyntaxException;
@@ -39,7 +36,7 @@ import org.osgi.service.cm.ManagedService;
  * The <code>ServicesListener</code> listens for the required services
  * and registers the security provider when required services are available
  */
-public class ServicesListener implements StartupListener {
+public class ServicesListener {
 
     private static final String AUTH_SUPPORT_CLASS = "org.apache.sling.auth.core.AuthenticationSupport";
     private static final String AUTHENTICATOR_CLASS = "org.apache.sling.api.auth.Authenticator";
@@ -61,7 +58,7 @@ public class ServicesListener implements StartupListener {
         NONE,
         PROVIDER,
         PROVIDER2
-    };
+    }
 
     /** State */
     private volatile State registrationState = State.NONE;
@@ -72,9 +69,6 @@ public class ServicesListener implements StartupListener {
     /** The registration for the provider2 */
     private ServiceRegistration<?> provider2Reg;
 
-    /** Flag for marking if startup is finished. */
-    private final AtomicBoolean startupFinished = new AtomicBoolean(false);
-
     /**
      * Start listeners
      */
@@ -89,40 +83,12 @@ public class ServicesListener implements StartupListener {
     }
 
     /**
-     * @see org.apache.sling.launchpad.api.StartupListener#inform(org.apache.sling.launchpad.api.StartupMode, boolean)
-     */
-    @Override
-    public void inform(final StartupMode mode, final boolean finished) {
-        if ( finished && this.startupFinished.compareAndSet(false, true) ) {
-            notifyChange();
-        }
-    }
-
-    /**
-     * @see org.apache.sling.launchpad.api.StartupListener#startupFinished(org.apache.sling.launchpad.api.StartupMode)
-     */
-    @Override
-    public void startupFinished(final StartupMode mode) {
-        if ( this.startupFinished.compareAndSet(false, true) ) {
-            notifyChange();
-        }
-    }
-
-    /**
-     * @see org.apache.sling.launchpad.api.StartupListener#startupProgress(float)
-     */
-    @Override
-    public void startupProgress(final float progress) {
-        // nothing to do
-    }
-
-    /**
      * Notify of service changes from the listeners.
      */
     public synchronized void notifyChange() {
         // check if all services are available
-        final Object authSupport = this.startupFinished.get() ? this.authSupportListener.getService() : null;
-        final Object authenticator = this.startupFinished.get() ? this.authListener.getService() : null;
+        final Object authSupport = this.authSupportListener.getService();
+        final Object authenticator = this.authListener.getService();
         final boolean hasAuthServices = authSupport != null && authenticator != null;
         final Object repository = this.repositoryListener.getService();
         if ( registrationState == State.NONE ) {