Hi
I'm seeing a strange behavior on felix 1.4 for
BundleContext.registerService(String[], Object,Properties).
I'm trying to install my own ShellService with this kind of code:
        // Grab the default shell
        mFelixShell =
mContext.getServiceReference(ShellService.class.getName());
        // Register ourself as the highest ranking service, so that we
bypass Felix shell.
        Properties props = new Properties();
        props.put(Constants.SERVICE_RANKING, Integer.MAX_VALUE);
        // Register as both a Command and a ShellService so that the Felix
shell gets a command to switch to this one
        mShellReg = mContext.registerService(new String[] {
ShellService.class.getName(),Command.class.getName() }, this, props);
And my autostart is

felix.auto.start.1= \
 file:repository/org.apache.felix.shell-1.0.2.jar \
 file:repository/myownshell.jar \
 file:repository/org.apache.felix.shell.tui-1.0.2.jar \
 file:repository/org.apache.felix.shell.remote-1.0.2.jar

so that TUI and remote get my shell service.

If I do this I see that:
- 'services' on my install bundle does NOT list the Command or ShellService
class. So my own shell doesn't seem to
be listed as exported.
- The Shell TUI module properly gets my own shell implementation (though
it's not listed as exported !)
- The remote shell TUI doesn't get it - looking at the code, it's using a
listener that seem to assume only one shell is ever registered.
The 'services -u' command on the remote shell shows that only the felix
shell service is used.

Now, even stranger, if I register my services in two steps, using:
        mShellReg = mContext.registerService(new String[] {
ShellService.class.getName()}, this, props);
        mShellReg = mContext.registerService(new String[] {
Command.class.getName()}, this, props);

Then both ShellTUI and Remote Shell now get my shell service. The 'services'
command works for the ShellService - the
Command service is still not listed as exported by my own bundle nor used by
the felix shell bundle - but the command is
there ! I.e. it does work, so the shell bundle must have found it...

Any ideas ?
Thanks
                 /jog

Reply via email to