incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1591232 - in /sling/trunk/launchpad/impl: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/sling/ src/main/java/org/apache/sling/launchpad/ src/main/java/org/apache/sling/launchpad/impl/
Date Wed, 30 Apr 2014 10:10:27 GMT
Author: cziegeler
Date: Wed Apr 30 10:10:27 2014
New Revision: 1591232

URL: http://svn.apache.org/r1591232
Log:
SLING-3529 : Move startup handling to a separate bundle

Added:
    sling/trunk/launchpad/impl/   (with props)
    sling/trunk/launchpad/impl/pom.xml   (with props)
    sling/trunk/launchpad/impl/src/
    sling/trunk/launchpad/impl/src/main/
    sling/trunk/launchpad/impl/src/main/java/
    sling/trunk/launchpad/impl/src/main/java/org/
    sling/trunk/launchpad/impl/src/main/java/org/apache/
    sling/trunk/launchpad/impl/src/main/java/org/apache/sling/
    sling/trunk/launchpad/impl/src/main/java/org/apache/sling/launchpad/
    sling/trunk/launchpad/impl/src/main/java/org/apache/sling/launchpad/impl/
    sling/trunk/launchpad/impl/src/main/java/org/apache/sling/launchpad/impl/Activator.java
  (with props)
    sling/trunk/launchpad/impl/src/main/java/org/apache/sling/launchpad/impl/DefaultStartupHandler.java
  (with props)

Propchange: sling/trunk/launchpad/impl/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Apr 30 10:10:27 2014
@@ -0,0 +1,14 @@
+target
+sling
+bin
+logs
+jackrabbit-repository
+derby.log
+*.iml
+*.ipr
+*.iws
+.settings
+.project
+.classpath
+.externalToolBuilders
+maven-eclipse.xml

Added: sling/trunk/launchpad/impl/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/impl/pom.xml?rev=1591232&view=auto
==============================================================================
--- sling/trunk/launchpad/impl/pom.xml (added)
+++ sling/trunk/launchpad/impl/pom.xml Wed Apr 30 10:10:27 2014
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+    agreements. See the NOTICE file distributed with this work for additional information
+    regarding copyright ownership. The ASF licenses this file to you under the Apache License,
+    Version 2.0 (the "License"); you may not use this file except in compliance with the
+    License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+    Unless required by applicable law or agreed to in writing, software distributed under
the
+    License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+    either express or implied. See the License for the specific language governing permissions
+    and limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.sling</groupId>
+        <artifactId>sling</artifactId>
+        <version>19</version>
+        <relativePath>../../parent/pom.xml</relativePath>
+    </parent>
+
+    <artifactId>org.apache.sling.launchpad.impl</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <packaging>bundle</packaging>
+    <name>Apache Sling Launchpad Implementation</name>
+
+    <description>
+        This module contains the implementation of the launchpad startup handling
+    </description>
+
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/launchpad/impl</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/launchpad/impl</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/launchpad/impl</url>
+    </scm>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-Activator>org.apache.sling.launchpad.impl.Activator</Bundle-Activator>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+    
+    <dependencies>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <version>5.0.0</version>
+            <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>
+    </dependencies>
+</project>
\ No newline at end of file

Propchange: sling/trunk/launchpad/impl/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/launchpad/impl/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Added: sling/trunk/launchpad/impl/src/main/java/org/apache/sling/launchpad/impl/Activator.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/impl/src/main/java/org/apache/sling/launchpad/impl/Activator.java?rev=1591232&view=auto
==============================================================================
--- sling/trunk/launchpad/impl/src/main/java/org/apache/sling/launchpad/impl/Activator.java
(added)
+++ sling/trunk/launchpad/impl/src/main/java/org/apache/sling/launchpad/impl/Activator.java
Wed Apr 30 10:10:27 2014
@@ -0,0 +1,188 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.launchpad.impl;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+
+import org.apache.sling.launchpad.api.StartupMode;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class Activator implements BundleActivator {
+
+    /** The data file which works as a marker to detect the first startup. */
+    private static final String DATA_FILE = "launchpad-timestamp.txt";
+
+    /** Name of the mode override property. */
+    private static final String OVERRIDE_PROP = "org.apache.sling.launchpad.startupmode";
+
+    /**
+     * The name of the configuration property defining if the startup level
+     * is increased incrementally for installs and updates.
+     * If enabled the framework starts with the start level defined by
+     * {@link Constants#FRAMEWORK_BEGINNING_STARTLEVEL}
+     * and the startup manager increases the start level one by one until
+     * the initial framework start level is reached.
+     * The default value is true, enabling this feature.
+     */
+    private static final String SLING_INSTALL_INCREMENTAL_START = "sling.framework.startup.incremental";
+
+    /**
+     * The name of the configuration property defining the final start level
+     * The framework starts with the start level defined by
+     * {@link Constants#FRAMEWORK_BEGINNING_STARTLEVEL}
+     * and the startup manager increases the start level until
+     * this start level is reached.
+     * Default value is 30.
+     */
+    private static final String SLING_INSTALL_STARTLEVEL = "sling.framework.startup.startlevel";
+
+    private String getProperty(final BundleContext context, final String name, final String
defaultValue) {
+        String value = context.getProperty(name);
+        if ( value == null ) {
+            value = System.getProperty(name);
+            if ( value == null ) {
+                value = defaultValue;
+            }
+        }
+        return value;
+    }
+
+    private int getIntProperty(final Logger logger, final BundleContext context, final String
name, final int defaultValue) {
+        String value = this.getProperty(context, name, null);
+        if ( value != null ) {
+            try {
+                return Integer.valueOf(value);
+            } catch (final NumberFormatException nfe) {
+                logger.warn("Unable to parse integer value {} for property {}. Ignoring and
using default {}",
+                        new Object[] {value, name, defaultValue});
+            }
+        }
+        return defaultValue;
+    }
+
+    /**
+     * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+     */
+    public void start(final BundleContext context) throws Exception {
+        final Logger logger = LoggerFactory.getLogger("org.apache.sling.launchpad.startup");
+
+        final File confDir = new File(context.getProperty(Constants.FRAMEWORK_STORAGE));
+
+        // check for override property
+        final String overrideMode = this.getProperty(context, OVERRIDE_PROP, null);
+        final StartupMode mode;
+        if ( overrideMode != null ) {
+            mode = StartupMode.valueOf(overrideMode.toUpperCase());
+            logger.info("Startup override property set. Starting in mode {}", mode);
+        } else {
+            mode = this.detectMode(logger, confDir);
+            logger.info("Detected startup mode. Starting in mode {}",  mode);
+        }
+
+        final int targetSlingStartLevel = this.getIntProperty(logger, context, SLING_INSTALL_STARTLEVEL,
30);
+        final int targetFrameworkStartLevel = this.getIntProperty(logger, context, Constants.FRAMEWORK_BEGINNING_STARTLEVEL,
1);
+
+        final int targetStartLevel;
+        if (targetSlingStartLevel >= targetFrameworkStartLevel ) {
+            targetStartLevel = targetSlingStartLevel;
+        } else {
+            targetStartLevel = targetFrameworkStartLevel;
+            logger.warn("Ignoring target Sling framework start level as it is lower than
the framework beginning start level: {} - {}",
+                    targetSlingStartLevel, targetFrameworkStartLevel);
+        }
+        final boolean incrementalStartupEnabled = Boolean.valueOf(this.getProperty(context,
SLING_INSTALL_INCREMENTAL_START, "true"));
+
+        new DefaultStartupHandler(context, logger, mode, targetStartLevel, incrementalStartupEnabled);
+
+        this.markInstalled(logger, confDir);
+    }
+
+    /**
+     * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+     */
+    public void stop(final BundleContext context) throws Exception {
+        // nothing to do
+    }
+
+    /**
+     * Detect the startup mode by comparing time stamps
+     */
+    private StartupMode detectMode(final Logger logger, final File confDir) {
+        final File dataFile = new File(confDir, DATA_FILE);
+        if (dataFile.exists()) {
+
+            FileReader fis = null;
+            try {
+                final long selfStamp = dataFile.lastModified();
+                if (selfStamp > 0) {
+
+                    fis = new FileReader(dataFile);
+                    final char[] txt = new char[128];
+                    final int len = fis.read(txt);
+                    final String value = new String(txt, 0, len);
+
+                    final long storedStamp = Long.parseLong(value);
+
+                    logger.info("Stored startup timestamp: {}", storedStamp);
+
+                    return (storedStamp >= selfStamp ? StartupMode.RESTART : StartupMode.UPDATE);
+                }
+
+            } catch (final NumberFormatException nfe) {
+                // fallback to assume restart
+                return StartupMode.RESTART;
+
+            } catch (final IOException ioe) {
+                logger.error("IOException during reading of installed flag.", ioe);
+
+            } finally {
+                if (fis != null) {
+                    try { fis.close(); } catch (IOException ignore) {}
+                }
+            }
+        }
+        // not installed yet - fallback
+        return StartupMode.INSTALL;
+    }
+
+    /**
+     * Set the finished installation marker.
+     */
+    private void markInstalled(final Logger logger, final File confDir) {
+        final File dataFile = new File(confDir, DATA_FILE);
+        try {
+            confDir.mkdirs();
+            final FileWriter fos = new FileWriter(dataFile);
+            try {
+                fos.write(String.valueOf(System.currentTimeMillis()));
+            } finally {
+                try { fos.close(); } catch (final IOException ignore) {}
+            }
+        } catch (final IOException ioe) {
+            logger.error( "IOException during writing of installed flag.", ioe);
+        }
+    }
+}

Propchange: sling/trunk/launchpad/impl/src/main/java/org/apache/sling/launchpad/impl/Activator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/launchpad/impl/src/main/java/org/apache/sling/launchpad/impl/Activator.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Added: sling/trunk/launchpad/impl/src/main/java/org/apache/sling/launchpad/impl/DefaultStartupHandler.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/impl/src/main/java/org/apache/sling/launchpad/impl/DefaultStartupHandler.java?rev=1591232&view=auto
==============================================================================
--- sling/trunk/launchpad/impl/src/main/java/org/apache/sling/launchpad/impl/DefaultStartupHandler.java
(added)
+++ sling/trunk/launchpad/impl/src/main/java/org/apache/sling/launchpad/impl/DefaultStartupHandler.java
Wed Apr 30 10:10:27 2014
@@ -0,0 +1,331 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.launchpad.impl;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.sling.launchpad.api.StartupHandler;
+import org.apache.sling.launchpad.api.StartupListener;
+import org.apache.sling.launchpad.api.StartupMode;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleListener;
+import org.osgi.framework.FrameworkEvent;
+import org.osgi.framework.FrameworkListener;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.startlevel.FrameworkStartLevel;
+import org.osgi.util.tracker.ServiceTracker;
+import org.osgi.util.tracker.ServiceTrackerCustomizer;
+import org.slf4j.Logger;
+
+/**
+ * The installation listener is listening for
+ * - framework events
+ * - events from other services
+ *
+ * It notifies listeners about the finish of the startup and
+ * about an approximate progress.
+ *
+ * @see StartupHandler
+ * @see StartupListener
+ */
+public class DefaultStartupHandler
+    implements StartupHandler, BundleListener, FrameworkListener, Runnable {
+
+    /** Logger. */
+    private final Logger logger;
+
+    /** Marker for finished. */
+    private final AtomicBoolean finished = new AtomicBoolean(false);
+
+    /** Marker if startup should wait */
+    private final AtomicInteger startupShouldWait = new AtomicInteger(0);
+
+    /** The queue for increasing the start level. */
+    private final BlockingQueue<Boolean> queue = new LinkedBlockingQueue<Boolean>();
+
+    /** The start level service. */
+    private final FrameworkStartLevel startLevelService;
+
+    /** The target start level. */
+    private final int targetStartLevel;
+
+    /** The startup mode. */
+    private final StartupMode startupMode;
+
+    /** Service tracker for startup listeners. */
+    private final ServiceTracker<StartupListener, StartupListener> listenerTracker;
+
+    /** Expected bundle counts. */
+    private final int expectedBundlesCount;
+
+    /** Active bundle set. */
+    private final Set<String> activeBundles = new HashSet<String>();
+
+    /** Bundle Context. */
+    private final BundleContext bundleContext;
+
+    /** Use incremental start level handling. */
+    private final boolean useIncremental;
+
+    /**
+     * Constructor.
+     */
+    public DefaultStartupHandler(final BundleContext context,
+            final Logger logger,
+            final StartupMode mode,
+            final int targetStartLevel,
+            final boolean isIncrementalStartupEnabled) {
+        this.logger = logger;
+        this.bundleContext = context;
+        this.startupMode = mode;
+        this.targetStartLevel = targetStartLevel;
+
+        this.startLevelService = context.getBundle(0).adapt(FrameworkStartLevel.class);
+        this.finished.set(this.startLevelService.getStartLevel() >= this.targetStartLevel);
+
+        this.listenerTracker = new ServiceTracker<StartupListener, StartupListener>(context,
StartupListener.class.getName(),
+                new ServiceTrackerCustomizer<StartupListener, StartupListener>() {
+
+                    public void removedService(final ServiceReference<StartupListener>
reference, final StartupListener service) {
+                        context.ungetService(reference);
+                    }
+
+                    public void modifiedService(final ServiceReference<StartupListener>
reference, final StartupListener service) {
+                        // nothing to do
+                    }
+
+                    public StartupListener addingService(final ServiceReference<StartupListener>
reference) {
+                        final StartupListener listener = context.getService(reference);
+                        if ( listener != null ) {
+                            listener.inform(startupMode, finished.get());
+                        }
+                        return listener;
+                    }
+                });
+        this.listenerTracker.open();
+        context.addFrameworkListener(this);
+
+        this.useIncremental = this.startupMode != StartupMode.RESTART && isIncrementalStartupEnabled;
+
+        if ( !this.useIncremental ) {
+            final Bundle[] bundles = context.getBundles();
+            this.expectedBundlesCount = (bundles != null && bundles.length > 0
? bundles.length : 10);
+
+            context.addBundleListener(this);
+        } else {
+            this.expectedBundlesCount = -1;
+        }
+
+        this.bundleContext.registerService(StartupHandler.class.getName(), this, null);
+        logger.info("Started startup handler with target start level={}, and expected bundle
count={}",
+               this.targetStartLevel, this.expectedBundlesCount);
+        final Thread t = new Thread(this);
+        t.setDaemon(true);
+        t.start();
+    }
+
+    /**
+     * @see org.apache.sling.launchpad.api.StartupHandler#getMode()
+     */
+    public StartupMode getMode() {
+        return this.startupMode;
+    }
+
+    /**
+     * @see org.apache.sling.launchpad.api.StartupHandler#isFinished()
+     */
+    public boolean isFinished() {
+        return this.finished.get();
+    }
+
+    /**
+     * @see java.lang.Runnable#run()
+     */
+    public void run() {
+        while ( !this.finished.get() ) {
+            Boolean doInc = null;
+            try {
+                doInc = this.queue.take();
+            } catch (final InterruptedException e) {
+                // ignore
+            }
+            if ( doInc != null && doInc ) {
+                if ( this.useIncremental ) {
+                    // if the installer is idle we first wait
+                    // we have to do this to give the installer or plugins for the installer,
+                    // time to start after the start level has changed
+                    if ( this.startupShouldWait.get() == 0 ) {
+                        this.sleep(2000L);
+                    }
+                    // now we wait until the installer is idle
+                    while ( this.startupShouldWait.get() != 0 ) {
+                        this.sleep(50L);
+                    }
+                    this.incStartLevel();
+                } else {
+                    // no incremental startup, directly go to final start level
+                    logger.debug("Increasing start level to {}", this.targetStartLevel);
+                    this.startLevelService.setStartLevel(this.targetStartLevel);
+
+                }
+            }
+        }
+    }
+
+    /**
+     * Increment the current start level by one
+     */
+    private void incStartLevel() {
+        final int newLevel = this.startLevelService.getStartLevel() + 1;
+        logger.debug("Increasing start level to {}", newLevel);
+        this.startLevelService.setStartLevel(newLevel);
+    }
+
+    /**
+     * @see org.apache.sling.launchpad.api.StartupHandler#waitWithStartup(boolean)
+     */
+    public void waitWithStartup(final boolean flag) {
+        logger.debug("Wait with startup {}", flag);
+        if ( flag ) {
+            this.startupShouldWait.incrementAndGet();
+        } else {
+            this.startupShouldWait.decrementAndGet();
+        }
+    }
+
+    /**
+     * Sleep a little bit
+     * @param time Sleeping time
+     */
+    private void sleep(final long time) {
+        try {
+            Thread.sleep(time);
+        } catch ( final InterruptedException e) {
+            // ignore
+        }
+    }
+
+    /**
+     * Put a task in the queue
+     * @param info Add new boolean information to queue
+     */
+    private void enqueue(final boolean info) {
+        try {
+            this.queue.put(info);
+        } catch (final InterruptedException e) {
+            // ignore
+        }
+    }
+
+    /**
+     * @see org.osgi.framework.FrameworkListener#frameworkEvent(org.osgi.framework.FrameworkEvent)
+     */
+    public void frameworkEvent(final FrameworkEvent event) {
+        if ( finished.get() ) {
+            return;
+        }
+        logger.debug("Received framework event {}:{}", event, event.getType());
+
+        if ( event.getType() == FrameworkEvent.STARTLEVEL_CHANGED || event.getType() == FrameworkEvent.STARTED)
{
+            if ( this.startLevelService.getStartLevel() >= this.targetStartLevel ) {
+                this.startupFinished();
+            } else {
+                this.enqueue(true);
+                if ( this.expectedBundlesCount == -1 ) {
+                    final int startLevel = this.startLevelService.getStartLevel();
+                    logger.info("Startup progress {}/{}", startLevel, targetStartLevel);
+                    final float ratio = (float) startLevel / (float) targetStartLevel;
+                    this.startupProgress(ratio);
+                }
+            }
+        }
+    }
+
+    /**
+     * Notify finished startup
+     */
+    private void startupFinished() {
+        logger.info("Startup finished.");
+        this.finished.set(true);
+
+        final Object[] listeners = this.listenerTracker.getServices();
+        if ( listeners != null ) {
+            for(final Object l : listeners) {
+                if ( l instanceof StartupListener ) {
+                    ((StartupListener) l).startupFinished(this.startupMode);
+                }
+            }
+        }
+        // stop the queue
+        this.enqueue(false);
+
+        // clear bundle set
+        this.activeBundles.clear();
+
+        // unregister listeners
+        if ( !this.useIncremental ) {
+            this.bundleContext.removeBundleListener(this);
+        }
+        this.bundleContext.removeFrameworkListener(this);
+    }
+
+    /**
+     * Notify startup progress
+     * @param ratio ratio
+     */
+    private void startupProgress(final float ratio) {
+        final Object[] listeners = this.listenerTracker.getServices();
+        if ( listeners != null ) {
+            for(final Object l : listeners) {
+                if ( l instanceof StartupListener ) {
+                    ((StartupListener) l).startupProgress(ratio);
+                }
+            }
+        }
+    }
+
+    /**
+     * @see org.osgi.framework.BundleListener#bundleChanged(org.osgi.framework.BundleEvent)
+     */
+    public void bundleChanged(final BundleEvent event) {
+        if (!finished.get()) {
+            logger.debug("Received bundle event {}", event);
+
+            if (event.getType() == BundleEvent.RESOLVED || event.getType() == BundleEvent.STARTED)
{
+                // Add (if not existing) bundle to active bundles and refresh progress bar
+                activeBundles.add(event.getBundle().getSymbolicName());
+
+                logger.info("Startup progress {}/{}", activeBundles.size(), expectedBundlesCount);
+                final float ratio = (float) activeBundles.size() / (float) expectedBundlesCount;
+                this.startupProgress(ratio);
+            } else if (event.getType() == BundleEvent.STOPPED) {
+                // Only remove bundle from active bundles,
+                // but do not refresh progress bar, to prevent progress bar from going back
+                activeBundles.remove(event.getBundle().getSymbolicName());
+            }
+        }
+    }
+}

Propchange: sling/trunk/launchpad/impl/src/main/java/org/apache/sling/launchpad/impl/DefaultStartupHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/launchpad/impl/src/main/java/org/apache/sling/launchpad/impl/DefaultStartupHandler.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url



Mime
View raw message