Return-Path: X-Original-To: apmail-sling-commits-archive@www.apache.org Delivered-To: apmail-sling-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DF1D8708E for ; Fri, 22 Jul 2011 12:32:42 +0000 (UTC) Received: (qmail 16373 invoked by uid 500); 22 Jul 2011 12:32:42 -0000 Delivered-To: apmail-sling-commits-archive@sling.apache.org Received: (qmail 16308 invoked by uid 500); 22 Jul 2011 12:32:41 -0000 Mailing-List: contact commits-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sling.apache.org Delivered-To: mailing list commits@sling.apache.org Received: (qmail 16301 invoked by uid 99); 22 Jul 2011 12:32:41 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 22 Jul 2011 12:32:41 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 22 Jul 2011 12:32:39 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id CFDE723888CF; Fri, 22 Jul 2011 12:32:19 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1149587 - in /sling/trunk/bundles/extensions/settings/src/main/java/org/apache/sling/settings/impl: Activator.java SlingSettingsServiceImpl.java Date: Fri, 22 Jul 2011 12:32:19 -0000 To: commits@sling.apache.org From: cziegeler@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110722123219.CFDE723888CF@eris.apache.org> Author: cziegeler Date: Fri Jul 22 12:32:18 2011 New Revision: 1149587 URL: http://svn.apache.org/viewvc?rev=1149587&view=rev Log: SLING-2155 : Remove check for Sling Engine bundle Modified: sling/trunk/bundles/extensions/settings/src/main/java/org/apache/sling/settings/impl/Activator.java sling/trunk/bundles/extensions/settings/src/main/java/org/apache/sling/settings/impl/SlingSettingsServiceImpl.java Modified: sling/trunk/bundles/extensions/settings/src/main/java/org/apache/sling/settings/impl/Activator.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/settings/src/main/java/org/apache/sling/settings/impl/Activator.java?rev=1149587&r1=1149586&r2=1149587&view=diff ============================================================================== --- sling/trunk/bundles/extensions/settings/src/main/java/org/apache/sling/settings/impl/Activator.java (original) +++ sling/trunk/bundles/extensions/settings/src/main/java/org/apache/sling/settings/impl/Activator.java Fri Jul 22 12:32:18 2011 @@ -24,8 +24,6 @@ import java.util.Hashtable; import org.apache.sling.settings.SlingSettingsService; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; -import org.osgi.framework.BundleEvent; -import org.osgi.framework.BundleListener; import org.osgi.framework.Constants; import org.osgi.framework.ServiceRegistration; @@ -34,67 +32,29 @@ import org.osgi.framework.ServiceRegistr * It registers the SlingSettingsService. * */ -public class Activator implements BundleActivator, BundleListener { +public class Activator implements BundleActivator { /** The service registration */ private ServiceRegistration serviceRegistration; - /** The bundle context. */ - private BundleContext bundleContext; - - /** The settings service. */ - private SlingSettingsServiceImpl settingsService; - /** * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) */ - public void start(BundleContext context) throws Exception { - this.bundleContext = context; - this.settingsService = new SlingSettingsServiceImpl(context); - // for compatibility, we might have to wait for the engine bundle - // to be started to get the Sling ID - - if ( this.settingsService.isDelayedStart() ) { - this.bundleContext.addBundleListener(this); - this.tryToStart(); - } else { - this.startService(); - } - } - - /** - * @param event - */ - public void bundleChanged(BundleEvent event) { - if ( SlingSettingsServiceImpl.ENGINE_SYMBOLIC_NAME.equals(event.getBundle().getSymbolicName())) { - this.tryToStart(); - } - - } - - private synchronized void tryToStart() { - if ( this.settingsService.isDelayedStart() ) { - this.settingsService.initDelayed(this.bundleContext); - if ( !this.settingsService.isDelayedStart() ) { - this.bundleContext.removeBundleListener(this); - this.startService(); - } - } - } + public void start(final BundleContext bundleContext) throws Exception { + final SlingSettingsService settingsService = new SlingSettingsServiceImpl(bundleContext); - private void startService() { final Dictionary props = new Hashtable(); - props.put(Constants.SERVICE_PID, this.settingsService.getClass().getName()); + props.put(Constants.SERVICE_PID, settingsService.getClass().getName()); props.put(Constants.SERVICE_DESCRIPTION, "Apache Sling Settings Service"); props.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation"); - serviceRegistration = this.bundleContext.registerService(new String[] { + serviceRegistration = bundleContext.registerService(new String[] { SlingSettingsService.class.getName()}, - this.settingsService, props); - SlingPropertiesPrinter.initPlugin(this.bundleContext); - SlingSettingsPrinter.initPlugin(this.bundleContext, this.settingsService); + settingsService, props); + SlingPropertiesPrinter.initPlugin(bundleContext); + SlingSettingsPrinter.initPlugin(bundleContext, settingsService); try { - RunModeCommand.initPlugin(this.bundleContext, this.settingsService.getRunModes()); + RunModeCommand.initPlugin(bundleContext, settingsService.getRunModes()); } catch (Throwable ignore) { // we just ignore this } @@ -104,8 +64,7 @@ public class Activator implements Bundle /** * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) */ - public void stop(BundleContext context) throws Exception { - this.bundleContext.removeBundleListener(this); + public void stop(final BundleContext context) throws Exception { try { RunModeCommand.destroyPlugin(); } catch (Throwable ignore) { @@ -118,6 +77,5 @@ public class Activator implements Bundle serviceRegistration.unregister(); serviceRegistration = null; } - this.settingsService = null; } } Modified: sling/trunk/bundles/extensions/settings/src/main/java/org/apache/sling/settings/impl/SlingSettingsServiceImpl.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/settings/src/main/java/org/apache/sling/settings/impl/SlingSettingsServiceImpl.java?rev=1149587&r1=1149586&r2=1149587&view=diff ============================================================================== --- sling/trunk/bundles/extensions/settings/src/main/java/org/apache/sling/settings/impl/SlingSettingsServiceImpl.java (original) +++ sling/trunk/bundles/extensions/settings/src/main/java/org/apache/sling/settings/impl/SlingSettingsServiceImpl.java Fri Jul 22 12:32:18 2011 @@ -23,8 +23,6 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.net.MalformedURLException; -import java.net.URI; -import java.net.URISyntaxException; import java.net.URL; import java.util.Collections; import java.util.HashSet; @@ -32,7 +30,6 @@ import java.util.Set; import java.util.UUID; import org.apache.sling.settings.SlingSettingsService; -import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -43,8 +40,6 @@ import org.slf4j.LoggerFactory; public class SlingSettingsServiceImpl implements SlingSettingsService { - public static final String ENGINE_SYMBOLIC_NAME = "org.apache.sling.engine"; - /** The logger */ private final Logger logger = LoggerFactory.getLogger(this.getClass()); @@ -62,8 +57,6 @@ public class SlingSettingsServiceImpl /** The name of the data file holding the sling id. */ private static final String DATA_FILE = "sling.id.file"; - /** Flag indicating a delayed start of this service. */ - private boolean delayedStart = false; /** * Create the service and search the Sling home urls and * get/create a sling id. @@ -104,24 +97,6 @@ public class SlingSettingsServiceImpl } this.slingId = this.readSlingId(idFile); - // if we don't have an id yet, we look for the engine bundle for compatibility reasons - if ( this.slingId == null ) { - final Bundle engineBundle = this.searchEngineBundle(context); - if ( engineBundle != null && engineBundle.getState() != Bundle.UNINSTALLED ) { - final BundleContext engineCtx = engineBundle.getBundleContext(); - if ( engineCtx == null ) { - // we need a delayed start - this.delayedStart = true; - return; - } - final File engineIdFile = engineCtx.getDataFile(DATA_FILE); - this.slingId = this.readSlingId(engineIdFile); - if ( this.slingId != null ) { - this.writeSlingId(idFile, this.slingId); - } - } - } - // no sling id yet or failure to read file: create an id and store if (slingId == null) { slingId = UUID.randomUUID().toString(); @@ -206,22 +181,10 @@ public class SlingSettingsServiceImpl } } - /** Search the engine bundle. */ - private Bundle searchEngineBundle(final BundleContext bc) { - final Bundle[] bundles = bc.getBundles(); - for(final Bundle b : bundles) { - if ( ENGINE_SYMBOLIC_NAME.equals(b.getSymbolicName()) ) { - return b; - } - } - return null; - } - - /** - * @see org.apache.sling.settings.SlingSettingsService#getAbsolutePathWithinSlingHome() + * @see org.apache.sling.settings.SlingSettingsService#getAbsolutePathWithinSlingHome(String) */ - public String getAbsolutePathWithinSlingHome(String relativePath) { + public String getAbsolutePathWithinSlingHome(final String relativePath) { return new File(slingHome, relativePath).getAbsolutePath(); } @@ -252,13 +215,4 @@ public class SlingSettingsServiceImpl public Set getRunModes() { return this.runModes; } - - public boolean isDelayedStart() { - return this.delayedStart; - } - - public void initDelayed(final BundleContext context) { - this.delayedStart = false; - this.setupSlingId(context); - } }