felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dean Schulze <dean.w.schu...@gmail.com>
Subject Re: Loading a class from a different bundle dynamically
Date Fri, 12 Dec 2014 18:06:41 GMT
I don't know what you mean when you say instantiate the class in the
Activator.  The Activator runs after the @Reference classes have been
injected.  I tried to load the test classes dynamically in the Activator,
but I got a ClassNotFoundException.

In order to get the implementation below to work the production module
depends on the test module, but the test module depends on the production
module, which won't work.

This approach probably can't be made to work.

As an alternative I can move the test classes into their own package in the
production module and have maven exclude that package from the production

@Service { .....}
public class ProductionClass implements ... {

private @Reference ITestClass testClass;

public void activate() {



On Fri, Dec 12, 2014 at 7:41 AM, Christian Schneider <
chris@die-schneider.net> wrote:
> I also recommend to use a service for this.
> Simply put your test class into a separate bundle. In the activator
> instantiate the test class and publish it as a service using the test
> interface you provide.
> The production bundle would then listen for services implementing the test
> interface e.g. using a service tracker and call them.
> This has the advantage that you do not need any system property and class
> loading specialities. Another advantage is that you can start the test by
> deploying the test bundle and stop it again by removing it.
> So no restart required.
> Christian
> On 12.12.2014 15:31, Achim Nierbeck wrote:
>> Dynamic Import?
>> Add a manifest header or dynamically importing your testclass in case it's
>> available,
>> but I would actually work with a service tracker that waits for the
>> "testservice" to be available and trigger the "test" then.
>> regards, Achim
> --
> Christian Schneider
> http://www.liquid-reality.de
> Open Source Architect
> http://www.talend.com
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message