blob: c242b8ae652651559743bb2a1065067792ee5793 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2009, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.e4.core.internal.contexts.osgi;
import org.eclipse.osgi.service.debug.DebugOptions;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.util.tracker.ServiceTracker;
public class ContextsActivator implements BundleActivator {
static private ContextsActivator defaultInstance;
private BundleContext bundleContext;
private ServiceTracker debugTracker = null;
public ContextsActivator() {
defaultInstance = this;
}
public static ContextsActivator getDefault() {
return defaultInstance;
}
public void start(BundleContext context) throws Exception {
bundleContext = context;
}
public void stop(BundleContext context) throws Exception {
if (debugTracker != null) {
debugTracker.close();
debugTracker = null;
}
bundleContext = null;
}
public boolean getBooleanDebugOption(String option, boolean defaultValue) {
if (debugTracker == null) {
debugTracker = new ServiceTracker(bundleContext, DebugOptions.class.getName(), null);
debugTracker.open();
}
DebugOptions options = (DebugOptions) debugTracker.getService();
if (options != null) {
String value = options.getOption(option);
if (value != null)
return value.equalsIgnoreCase("true"); //$NON-NLS-1$
}
return defaultValue;
}
}