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 10:16:17 UTC
[sling-org-apache-sling-settings] 08/15: SLING-2155 : Remove check
for Sling Engine bundle
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.settings-1.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-settings.git
commit b1b28472a6a858b7b3b13f7d5448cf1300d01456
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Jul 22 12:32:18 2011 +0000
SLING-2155 : Remove check for Sling Engine bundle
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/settings@1149587 13f79535-47bb-0310-9956-ffa450edef68
---
.../org/apache/sling/settings/impl/Activator.java | 62 ++++------------------
.../settings/impl/SlingSettingsServiceImpl.java | 50 +----------------
2 files changed, 12 insertions(+), 100 deletions(-)
diff --git a/src/main/java/org/apache/sling/settings/impl/Activator.java b/src/main/java/org/apache/sling/settings/impl/Activator.java
index a68b8d7..2d1c2a8 100644
--- a/src/main/java/org/apache/sling/settings/impl/Activator.java
+++ b/src/main/java/org/apache/sling/settings/impl/Activator.java
@@ -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.ServiceRegistration;
* 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<String, String> props = new Hashtable<String, String>();
- 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 BundleActivator, BundleListener {
/**
* @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 BundleActivator, BundleListener {
serviceRegistration.unregister();
serviceRegistration = null;
}
- this.settingsService = null;
}
}
diff --git a/src/main/java/org/apache/sling/settings/impl/SlingSettingsServiceImpl.java b/src/main/java/org/apache/sling/settings/impl/SlingSettingsServiceImpl.java
index 2d2b958..358b588 100644
--- a/src/main/java/org/apache/sling/settings/impl/SlingSettingsServiceImpl.java
+++ b/src/main/java/org/apache/sling/settings/impl/SlingSettingsServiceImpl.java
@@ -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<String> getRunModes() {
return this.runModes;
}
-
- public boolean isDelayedStart() {
- return this.delayedStart;
- }
-
- public void initDelayed(final BundleContext context) {
- this.delayedStart = false;
- this.setupSlingId(context);
- }
}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.