| Injecting a BundleContext [message #835963] |
Tue, 03 April 2012 18:40  |
Elias Volanakis Messages: 26 Registered: July 2009 |
Junior Member |
|
|
Hi folks,
does Eclipse 4.2 support having the current BudleContext injected ? Example:
MyClass.java:
@Inject
public void foo(BundleContext context) {
context.doSomething();
}
The above snippet would be nicer than FrameworkUtil.getBundle(MyClass.class).getBundleContext() -- however it does not seem to work.
Thanks for the input,
Elias.
Elias Volanakis | http://eclipsesource.com
elias (AT) eclipsesource.com | @evolanakis
|
|
|
|
| Re: Injecting a BundleContext [message #841278 is a reply to message #840782] |
Wed, 11 April 2012 01:35  |
Erdal Karaca Messages: 620 Registered: July 2009 |
Senior Member |
|
|
Tom Schindl wrote on Tue, 10 April 2012 09:59
b) You make up your own annotation (@BundleContext) and register it
using DS (i have code in my EclipseCon slides [1]) which would make
your code look like this.
MyClass.java:
@Inject
public void foo(@BundleContext BundleContext context) {
context.doSomething();
}
What about a @Util annotation like this:
Quote:
@Inject
public void foo(@Util BundleContext context) {
context.doSomething();
}
Quote:
@Inject
public void foo(@Util Bundle bundle) {
bundle.doSomething();
}
|
|
|
Powered by
FUDForum. Page generated in 0.09431 seconds