You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by jaredmac <jm...@mathworks.com> on 2008/03/12 20:06:26 UTC

Best practice for non-bundle code to access bundles?

I have an application in which non-bundle code would like to access
registered services/bundles loaded by Felix. For example, I have Bundle X
whose activate() method gets a reference to all the currently registered
implementers of Interface Y. Can other non-bundle parts of the application
code get that list of implementers from Bundle X? 

The trivial approach wherein Bundle X puts the list of implementors in some
static variable does not work because Bundle X is loaded via a separate
classloader from the application. 

What is the best practice, short of having every part of the application be
a bundle, for non-bundles to get at the bundles?

Thanks,
Jared
-- 
View this message in context: http://www.nabble.com/Best-practice-for-non-bundle-code-to-access-bundles--tp16012389p16012389.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Best practice for non-bundle code to access bundles?

Posted by "Richard S. Hall" <he...@ungoverned.org>.
Did you read the "launching and embedding document for the framework"? 
This will give you some ideas.

I would give you a pointer, but the web site/wiki seems to be acting up 
right now.

-> richard

jaredmac wrote:
> I have an application in which non-bundle code would like to access
> registered services/bundles loaded by Felix. For example, I have Bundle X
> whose activate() method gets a reference to all the currently registered
> implementers of Interface Y. Can other non-bundle parts of the application
> code get that list of implementers from Bundle X? 
>
> The trivial approach wherein Bundle X puts the list of implementors in some
> static variable does not work because Bundle X is loaded via a separate
> classloader from the application. 
>
> What is the best practice, short of having every part of the application be
> a bundle, for non-bundles to get at the bundles?
>
> Thanks,
> Jared
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Best practice for non-bundle code to access bundles?

Posted by jaredmac <jm...@mathworks.com>.

Richard S. Hall wrote:
> 
> Here is the link:
> 
>    
> http://cwiki.apache.org/FELIX/launching-and-embedding-apache-felix.html
> 
> -> richard
> 

Thanks. That is, of course, exactly what I was looking for (and I already
had it bookmarked in my browser, no less!). I've now moved on to bigger and
better issues, but will struggle with them for a while before posting. :) 

-- 
View this message in context: http://www.nabble.com/Best-practice-for-non-bundle-code-to-access-bundles--tp16012389p16037376.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Best practice for non-bundle code to access bundles?

Posted by "Richard S. Hall" <he...@ungoverned.org>.
Jeremy,

I included a link to your project in the embedding document, assuming it 
is okay with you.

-> richard

Jeremy Wales wrote:
> In addition to grabbing the list of implementors (which the given link
> should help with) I'm guessing you may have problems using the services
> outside the framework you've grabbed them from, because of the ClassLoader
> isolation involved. If that's not the case then great :-) But if it is then
> give Transloader <http://code.google.com/p/transloader/> a try. I've been
> developing it for just this purpose.
>
> Jeremy
>
> On Thu, Mar 13, 2008 at 5:35 AM, Richard S. Hall <he...@ungoverned.org>
> wrote:
>
>   
>> Here is the link:
>>
>>    http://cwiki.apache.org/FELIX/launching-and-embedding-apache-felix.html
>>
>> -> richard
>>
>> jaredmac wrote:
>>     
>>> I have an application in which non-bundle code would like to access
>>> registered services/bundles loaded by Felix. For example, I have Bundle
>>>       
>> X
>>     
>>> whose activate() method gets a reference to all the currently registered
>>> implementers of Interface Y. Can other non-bundle parts of the
>>>       
>> application
>>     
>>> code get that list of implementers from Bundle X?
>>>
>>> The trivial approach wherein Bundle X puts the list of implementors in
>>>       
>> some
>>     
>>> static variable does not work because Bundle X is loaded via a separate
>>> classloader from the application.
>>>
>>> What is the best practice, short of having every part of the application
>>>       
>> be
>>     
>>> a bundle, for non-bundles to get at the bundles?
>>>
>>> Thanks,
>>> Jared
>>>
>>>       
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>>
>>     
>
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Best practice for non-bundle code to access bundles?

Posted by Jeremy Wales <je...@gmail.com>.
In addition to grabbing the list of implementors (which the given link
should help with) I'm guessing you may have problems using the services
outside the framework you've grabbed them from, because of the ClassLoader
isolation involved. If that's not the case then great :-) But if it is then
give Transloader <http://code.google.com/p/transloader/> a try. I've been
developing it for just this purpose.

Jeremy

On Thu, Mar 13, 2008 at 5:35 AM, Richard S. Hall <he...@ungoverned.org>
wrote:

> Here is the link:
>
>    http://cwiki.apache.org/FELIX/launching-and-embedding-apache-felix.html
>
> -> richard
>
> jaredmac wrote:
> > I have an application in which non-bundle code would like to access
> > registered services/bundles loaded by Felix. For example, I have Bundle
> X
> > whose activate() method gets a reference to all the currently registered
> > implementers of Interface Y. Can other non-bundle parts of the
> application
> > code get that list of implementers from Bundle X?
> >
> > The trivial approach wherein Bundle X puts the list of implementors in
> some
> > static variable does not work because Bundle X is loaded via a separate
> > classloader from the application.
> >
> > What is the best practice, short of having every part of the application
> be
> > a bundle, for non-bundles to get at the bundles?
> >
> > Thanks,
> > Jared
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

Re: Best practice for non-bundle code to access bundles?

Posted by "Richard S. Hall" <he...@ungoverned.org>.
Here is the link:

    http://cwiki.apache.org/FELIX/launching-and-embedding-apache-felix.html

-> richard

jaredmac wrote:
> I have an application in which non-bundle code would like to access
> registered services/bundles loaded by Felix. For example, I have Bundle X
> whose activate() method gets a reference to all the currently registered
> implementers of Interface Y. Can other non-bundle parts of the application
> code get that list of implementers from Bundle X? 
>
> The trivial approach wherein Bundle X puts the list of implementors in some
> static variable does not work because Bundle X is loaded via a separate
> classloader from the application. 
>
> What is the best practice, short of having every part of the application be
> a bundle, for non-bundles to get at the bundles?
>
> Thanks,
> Jared
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org