Bug 172969 - Allow EclipseStarter to make the system BundleContext available (patch included)
Summary: Allow EclipseStarter to make the system BundleContext available (patch included)
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: Framework (show other bugs)
Version: 3.3   Edit
Hardware: All All
: P3 enhancement with 1 vote (vote)
Target Milestone: 3.3 M6   Edit
Assignee: Thomas Watson CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2007-02-05 19:22 EST by Alex Blewitt CLA
Modified: 2007-03-19 03:37 EDT (History)
1 user (show)

See Also:


Attachments
Provides EclipseStarter.getSystemBundleContext() (1.21 KB, patch)
2007-02-05 19:23 EST, Alex Blewitt CLA
no flags Details | Diff
Patch to provide context.getBundle().getBundleContext() as requested (650 bytes, patch)
2007-02-06 18:25 EST, Alex Blewitt CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Blewitt CLA 2007-02-05 19:22:13 EST
I was trying to embed Equinox into a larger Java application, and ideally wanted to expose the functionality to start/stop and install bundles into the Java app. Although the EclipseStarter holds a reference to the OSGi, and the startup() method has a reference to the BundleContext, it's not possible to obtain if just invoking main() to bring the framework up.
Comment 1 Alex Blewitt CLA 2007-02-05 19:23:26 EST
Created attachment 58301 [details]
Provides EclipseStarter.getSystemBundleContext()

This adds EclipseStarter.getSystemBundleContext() to allow access to this from other applications.
Comment 2 Thomas Watson CLA 2007-02-06 10:21:56 EST
We have discussed this before.  In the past we have been reluctant to add a public static method to get the system bundle context because of the security issues.

I'm not sure this is such a big security issue any more now that OSGi R4.1 is adding the Bundle.getBundleContext method with a permission check.  If we decide to do this then we should probably use the proper calls to cause a permission check if the security manager is enabled ...

context.getBundle().getBundleContext()
Comment 3 Alex Blewitt CLA 2007-02-06 17:53:21 EST
Note that you can already get it via the return result from the startup() call, and also if you supply a subclass of Console then the OSGi gets passed in as a constructor arg anyway which can be overridden (or cached). It's just it would be nice if the class provided a mechanism for clients who want to interact with the system to do so, without having to resort to workaround/hacks like this.

Not having the method doesn't really change much with what can be done, but it does make it easier for the use case of embedding Equinox in an existing Java system. And note also that the Servlet stuff also goes around great hacks to provide public access to the OSGi context too.

But yeah, having context.getBundle().getBundleContext() would also work :-)

Alex.
Comment 4 Alex Blewitt CLA 2007-02-06 18:25:51 EST
Created attachment 58389 [details]
Patch to provide context.getBundle().getBundleContext() as requested

Attempt II ... the first time it failed (so if there's multiple attachments, that explains why)
Comment 5 Thomas Watson CLA 2007-02-08 12:53:16 EST
Consider for M6.  Need Jeff's approval for new API.
Comment 6 Jeff McAffer CLA 2007-03-14 10:07:48 EDT
+1
Comment 7 John Arthorne CLA 2007-03-14 10:18:02 EDT
Note the copyright statement should be updated if Alex's contribution is being used.
Comment 8 Thomas Watson CLA 2007-03-14 10:28:09 EDT
I'm having a hard time getting Alex's patch to apply.  Eclipse keeps saying the patch file does not contain a valid patch.  I was just going to do it manually.  But I would like to add Alex to the copyright.  Alex, do you want me to add you as a contributor?  If so what text would you like me to use for you?
Comment 9 Thomas Watson CLA 2007-03-16 15:59:52 EDT
Fix released to HEAD.  Alex I added your name to the copyright.  Let me know if you want something else besides your name in the copyright.
Comment 10 Alex Blewitt CLA 2007-03-19 03:37:22 EDT
Thanks, Tom. My name's fine in the copyright.

Alex.