| Summary: | Need IRequestor API for class being injected | ||
|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Gunnar Wagenknecht <gunnar> |
| Component: | Runtime | Assignee: | Oleg Besedin <ob1.eclipse> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P3 | CC: | ob1.eclipse, pwebster |
| Version: | 4.2 | ||
| Target Milestone: | 4.2 M3 | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
| Bug Depends on: | |||
| Bug Blocks: | 357460 | ||
|
Description
Gunnar Wagenknecht
BTW, here is what I'm doing now:
private BundleContext getBundleContext(final IRequestor requestor) {
Bundle bundle = null;
final Object requestingObject = requestor.getRequestingObject();
if (null != requestingObject) {
bundle = FrameworkUtil.getBundle(requestingObject.getClass());
}
if (null == bundle) {
// ConstructorRequestor
// FIXME: https://bugs.eclipse.org/357865
try {
final Field field = requestor.getClass().getDeclaredField("constructor");
if (!field.isAccessible()) {
field.setAccessible(true);
}
bundle = FrameworkUtil.getBundle(
((Constructor<?>) field.get(requestor)).getDeclaringClass());
} catch (final Exception e) {
LOG.debug("exception accessing data in requestor {}", requestor, e);
}
}
if (null != bundle) {
return bundle.getBundleContext();
}
// give up
return null;
}
Added IRequestor#getRequestingObjectClass() - as requested :-). http://git.eclipse.org/c/platform/eclipse.platform.runtime.git/commit/?id=b9f758ea70fc19eb822897008912fb8ec7b9e707 . |