use of org.osgi.util.tracker.ServiceTracker in project felix by apache.
the class SimpleWebConsolePlugin method deactivate.
/**
* This method will close all service trackers, created by
* {@link #getService(String)} method. If you override this method, don't
* forget to call the super.
*
* @see org.apache.felix.webconsole.AbstractWebConsolePlugin#deactivate()
*/
public void deactivate() {
for (Iterator ti = services.values().iterator(); ti.hasNext(); ) {
ServiceTracker tracker = (ServiceTracker) ti.next();
tracker.close();
ti.remove();
}
super.deactivate();
}
use of org.osgi.util.tracker.ServiceTracker in project felix by apache.
the class BundlesServlet method activate.
/**
* @see org.apache.felix.webconsole.AbstractWebConsolePlugin#activate(org.osgi.framework.BundleContext)
*/
@Override
public void activate(BundleContext bundleContext) {
super.activate(bundleContext);
bundleInfoTracker = new ServiceTracker(bundleContext, BundleInfoProvider.class.getName(), null);
bundleInfoTracker.open();
// bootdelegation property parsing from Apache Felix R4SearchPolicyCore
String bootDelegation = bundleContext.getProperty(Constants.FRAMEWORK_BOOTDELEGATION);
bootDelegation = (bootDelegation == null) ? "java.*" : bootDelegation + ",java.*";
StringTokenizer st = new StringTokenizer(bootDelegation, " ,");
bootPkgs = new String[st.countTokens()];
bootPkgWildcards = new boolean[bootPkgs.length];
for (int i = 0; i < bootPkgs.length; i++) {
bootDelegation = st.nextToken();
if (bootDelegation.endsWith("*")) {
bootPkgWildcards[i] = true;
bootDelegation = bootDelegation.substring(0, bootDelegation.length() - 1);
}
bootPkgs[i] = bootDelegation;
}
Hashtable props = new Hashtable();
props.put(WebConsoleConstants.CONFIG_PRINTER_MODES, new String[] { ConfigurationPrinter.MODE_TXT, ConfigurationPrinter.MODE_ZIP });
configurationPrinter = bundleContext.registerService(ConfigurationPrinter.SERVICE, this, props);
}
use of org.osgi.util.tracker.ServiceTracker in project felix by apache.
the class Activator method start.
/**
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
public final void start(BundleContext context) throws Exception {
this.context = context;
this.tracker = new ServiceTracker(context, DeploymentAdmin.class.getName(), this);
this.tracker.open();
}
use of org.osgi.util.tracker.ServiceTracker in project felix by apache.
the class Activator method start.
/**
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
public final void start(BundleContext context) throws Exception {
this.context = context;
Filter filter = context.createFilter(// $NON-NLS-1$
"(|" + '(' + OBJECTCLASS + // $NON-NLS-1$
"=org.osgi.service.obr.RepositoryAdmin)" + '(' + OBJECTCLASS + // $NON-NLS-1$
"=org.apache.felix.bundlerepository.RepositoryAdmin)" + ')');
this.tracker = new ServiceTracker(context, filter, this);
this.tracker.open();
}
use of org.osgi.util.tracker.ServiceTracker in project hale by halestudio.
the class Activator method getBooleanDebugOption.
/**
* Return the debug value of the option if founded otherwise return
* defaultValue.
*
* @param option
* @param defaultValue
* @return
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public static boolean getBooleanDebugOption(String option, boolean defaultValue) {
// 1) search param from JVM
String s = System.getProperty(DEBUG_PROPERTY);
if (!Utils.isEmpty(s)) {
return Utils.isTrue(s, defaultValue);
}
// 2) search param from nonosgiregistry.properties files.
if (nonosgiregistryProps == null) {
nonosgiregistryProps = Utils.load(Activator.class.getClassLoader());
s = nonosgiregistryProps.getProperty(DEBUG_PROPERTY);
if (!Utils.isEmpty(s)) {
return Utils.isTrue(s, defaultValue);
}
}
// 3) Search param from OSGi options
Activator activator = getDefault();
if (activator == null)
// No OSGi context
return defaultValue;
BundleContext myBundleContext = activator.bundleContext;
if (myBundleContext == null)
return defaultValue;
// Search the DebugOptions OSGi service
if (getDefault().debugTracker == null) {
getDefault().debugTracker = new ServiceTracker(getDefault().bundleContext, DebugOptions.class.getName(), null);
getDefault().debugTracker.open();
}
DebugOptions options = (DebugOptions) getDefault().debugTracker.getService();
if (options != null) {
// get the value of the option by using OSGi service DebugOptions
return Utils.isTrue(options.getOption(option), defaultValue);
}
return defaultValue;
}
Aggregations