org.osgi.framework.BundleActivator Java Examples
The following examples show how to use
org.osgi.framework.BundleActivator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SystemBundle.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * If the extension has an extension activator header process it. * * @param extension the extension bundle to process. */ private BundleActivator handleExtensionActivator(final BundleGeneration extension) throws BundleException { String extActivatorName = extension.archive.getAttribute(Constants.EXTENSION_BUNDLE_ACTIVATOR); extActivatorName = null!=extActivatorName ? extActivatorName.trim() : null; if (null != extActivatorName && extActivatorName.length() > 0) { fwCtx.log("Create bundle activator for extension: " + extension.symbolicName + ":" +extension.version + " using: " +extActivatorName); try { final Class<BundleActivator> c = (Class<BundleActivator>)Class.forName(extActivatorName); return c.newInstance(); } catch (Throwable t) { final String msg = "Failed to instanciate extension activator " + extActivatorName + ", " + extension.bundle; fwCtx.log(msg, t); throw new BundleException(msg, BundleException.ACTIVATOR_ERROR, t); } } return null; }
Example #2
Source File: SystemBundle.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void extensionCallStop() { BundleImpl[] bs = extensions.keySet().toArray(new BundleImpl[extensions.size()]); for (int i = bs.length - 1; i >= 0; i--) { if (fwCtx.debug.framework) { fwCtx.debug.println("Call extension bundle stop: " + bs[i]); } BundleActivator ba = extensions.get(bs[i]); if (ba != null) { try { ba.stop(bundleContext); } catch (final Throwable t) { final String msg = "Failed to stop framework extension, " + bs[i]; fwCtx.frameworkError(bs[i], new BundleException(msg, BundleException.ACTIVATOR_ERROR, t)); } } } extensions.clear(); }
Example #3
Source File: SystemBundle.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void callBundleActivatorStart(BundleImpl b) { BundleActivator ba = extensions.get(b); if (ba != null) { if (fwCtx.debug.framework) { fwCtx.debug.println("Call extension bundle start: " + b); } try { ba.start(bundleContext); } catch (final Throwable t) { extensions.put(b, null); final String msg = "Failed to start framework extension, " + b; fwCtx.frameworkError(b, new BundleException(msg, BundleException.ACTIVATOR_ERROR, t)); } } }
Example #4
Source File: DynamicWorkingSetStartupPDETest.java From eclipse-extras with Eclipse Public License 1.0 | 5 votes |
@Test public void testStartupExtension() { Extension extension = getEarlyStartup(); IStartup startup = extension.createExecutableExtension( "class", IStartup.class ); assertThat( startup ).isInstanceOf( DynamicWorkingSetStartup.class ); assertThat( startup ).isNotInstanceOf( BundleActivator.class ); }
Example #5
Source File: LaunchExtrasStartupPDETest.java From eclipse-extras with Eclipse Public License 1.0 | 5 votes |
@Test public void testStartupExtension() { Extension extension = getEarlyStartup(); IStartup startup = extension.createExecutableExtension( "class", IStartup.class ); assertThat( startup ).isInstanceOf( LaunchExtrasStartup.class ); assertThat( startup ).isNotInstanceOf( BundleActivator.class ); }
Example #6
Source File: BundleImpl.java From AtlasForAndroid with MIT License | 5 votes |
public synchronized void startBundle() throws BundleException { if (this.state == 1) { throw new IllegalStateException("Cannot start uninstalled bundle " + toString()); } else if (this.state != 32) { if (this.state == 2) { resolveBundle(true); } this.state = 8; try { this.context.isValid = true; if (!(this.classloader.activatorClassName == null || StringUtils.isBlank(this.classloader.activatorClassName))) { Class loadClass = this.classloader.loadClass(this.classloader.activatorClassName); if (loadClass == null) { throw new ClassNotFoundException(this.classloader.activatorClassName); } this.classloader.activator = (BundleActivator) loadClass.newInstance(); this.classloader.activator.start(this.context); } this.state = 32; Framework.notifyBundleListeners(2, this); if (Framework.DEBUG_BUNDLES && log.isInfoEnabled()) { log.info("Framework: Bundle " + toString() + " started."); } } catch (Throwable th) { Throwable th2 = th; Framework.clearBundleTrace(this); this.state = 4; String str = "Error starting bundle " + toString(); if (th2.getCause() != null) { th2 = th2.getCause(); } BundleException bundleException = new BundleException(str, th2); } } }
Example #7
Source File: HostApplication.java From SimpleFlatMapper with MIT License | 5 votes |
public HostApplication() throws IOException { // Create a configuration property map. Map<String, Object> config = new HashMap<String, Object>(); // Create host activator; m_activator = new HostActivator(); List<BundleActivator> list = new ArrayList<BundleActivator>(); list.add(m_activator); config.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP, list); config.put(FelixConstants.FRAMEWORK_STORAGE, "target/felix"); config.put(FelixConstants.LOG_LEVEL_PROP, "5"); cleanUp("target/felix"); try { // Now create an instance of the framework with // our configuration properties. m_felix = new Felix(config); // Now start Felix instance. m_felix.start(); } catch (Exception ex) { System.err.println("Could not create framework: " + ex); ex.printStackTrace(); } }
Example #8
Source File: BundleImpl.java From concierge with Eclipse Public License 1.0 | 4 votes |
private void install() throws BundleException { // register bundle with framework: synchronized (framework) { framework.bundles.add(this); framework.bundleID_bundles.put(new Long(getBundleId()), this); framework.symbolicName_bundles .insert(currentRevision.getSymbolicName(), this); framework.location_bundles.put(location, this); } this.state = Bundle.INSTALLED; // resolve if it is a framework extension if (currentRevision.isExtensionBundle()) { if(currentRevision.resolve(false)){ // call start for extension activator before notifying framework of resolve if(currentRevision.extActivatorClassName != null){ try { @SuppressWarnings("unchecked") final Class<BundleActivator> activatorClass = (Class<BundleActivator>) framework.systemBundleClassLoader.loadClass(currentRevision.extActivatorClassName); if (activatorClass == null) { throw new ClassNotFoundException(currentRevision.extActivatorClassName); } currentRevision.extActivatorInstance = activatorClass.newInstance(); currentRevision.extActivatorInstance.start(framework.context); } catch(Throwable err){ currentRevision.extActivatorInstance = null; framework.notifyFrameworkListeners(FrameworkEvent.ERROR, BundleImpl.this, new BundleException("Error calling extension bundle start(): " + this.toString(), BundleException.ACTIVATOR_ERROR, err)); } } } } // we are just installing the bundle, if it is // possible, resolve it, if not, wait until the // exports are really needed (i.e., they become critical) // if (!currentRevision.isFragment()) { // currentRevision.resolve(false); // } }