blob: 89a2824f34a11e4d6f5fdf9c0cb28b890c226636 [file] [log] [blame]
/**
*
* Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation
*
*/
package org.eclipse.osbp.ecview.extension.presentation.tests;
import org.knowhowlab.osgi.testing.assertions.BundleAssert;
import org.knowhowlab.osgi.testing.assertions.ServiceAssert;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
public class Activator implements BundleActivator {
static BundleContext context;
static BundleContext getContext() {
return context;
}
/**
* Returns the bundle with the given id.
*
* @param id
* @return
*/
public static Bundle findBundle(String id) {
for (Bundle bundle : context.getBundles()) {
if (bundle.getSymbolicName().equals(id)) {
return bundle;
}
}
return null;
}
/*
* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext bundleContext) throws Exception {
Activator.context = bundleContext;
BundleAssert.setDefaultBundleContext(context);
ServiceAssert.setDefaultBundleContext(context);
BundleHelper.ensureNeededBundlesAvailable();
BundleHelper.ensureNeededServicesAvailable();
}
/*
* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext bundleContext) throws Exception {
Activator.context = null;
}
}