Daniel Dewael wrote:
Hi guys,

First thanks for Felix, this is really a great endeavor and an enabling 
technology that will change a lot of things for us, Java developers.

Thanks. [Comments below...]

I am trying to implement the "Using Services Provided by Bundles" example shown on the 
"Embedding Felix" page and run into problems.

I have packaged an implementation of host.service.command.Command in a bundle, 
which I package with the cool Maven plugin. To load this bundle I have added an 
AutoActivator:

            List list = new ArrayList();
            list.add(new AutoActivator(configMap));
            hostActivator = new HostActivator();
            list.add(hostActivator);

The ServiceTracker sees the command service being added and I can iterate 
through the services it tracks and use reflection to call methods on the 
implementation of Command that comes from the external bundle (CommandImpl).

But I can not cast CommandImpl to Command, as they are in two different class 
loaders (Command is in the bootstrap classloader that loaded HostApplication, 
while CommandImpl is in the classloader of the OSGI bundle).

I am pretty sure my mistake will be easy to spot for you guys. I am looking 
forward your help.

Yes, the documentation says that if you want to share classes between the host and the bundle, then these classes *must* be on the class path. So you should:

  1. Make sure that no bundle contains or exports
     "host.service.command"; they should only import this package.
  2. Modify the configuration property
     "org.osgi.framework.system.packages" property to include the
     package "host.service.command".
  3. Start your application with the "host.service.command" package in
     its class path.

That should do it.

-> richard
Cheers,
Dan


--------------------------------- All new Yahoo! Mail - ---------------------------------
Get a sneak peak at messages with a handy reading pane.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to