[ 
https://issues.apache.org/jira/browse/FELIX-4842?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14616776#comment-14616776
 ] 

Pierrick commented on FELIX-4842:
---------------------------------

Hello,

I have the same problem when I try to create dynamically some new instance with 
the API :
ComponentInstance instance = myFactory.createComponentInstance(parameters, 
ipojoContext);

The anotation @Context(Context.Source.INSTANCE) doesn't work in my factory, the 
injected context is null.
But I use too @Configuration to create some other instances and in this case 
the bundle context of the instance is correctly injected in my factory.

A workaround is to retrieve the bundle context from the constructor and to cast 
it to an IPojoContext to retrieve the service context that allows to get the 
bundle context of the instance :
((IPojoContext) 
myBundleContext).getServiceContext().getBundle().getBundleContext();

> CONTEXT.Source.INSTANCE cannot work
> -----------------------------------
>
>                 Key: FELIX-4842
>                 URL: https://issues.apache.org/jira/browse/FELIX-4842
>             Project: Felix
>          Issue Type: Bug
>          Components: iPOJO
>    Affects Versions: ipojo-runtime-1.12.1
>            Reporter: armroe
>
> CONTEXT.Source.INSTANCE annotation cannot work. BundleContext cannot be 
> injected and always null.
> there is no problem with CONTEXT.Source.COMPONENT.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to