I'd like to use iPojo to extend the karaf shell with my own commands.

With blueprint there's:

<shell:command-bundle>
        <shell:command name="uim/info">
            <shell:action class="eu.europeana.uim.command.UIMInfo"/>
        </shell:command>
</shell:command-bundle>

It allows to use the org.apache.felix.gogo.commands.* Annotations as @Command, 
@Option, @Action to define the shell-extension

@Component(name="eu sample.addons.api.command.KarafSampleTUI")
@Provides 
@Command(name = "info", scope = "uim")
public class KarafSampleTUI implements Function, Action, SampleTUI 


-> Is there a way on handling this with iPojo?

Thanks,
Kr Andrew


>That's not really a bug, it's a feature ;-)
>
>Completion only displays commands that inherit the 
>>org.apache.felix.gogo.commands.basic.AbstractCommand (which is now defined 
>>in Karaf, but the package hasn't been renamed in case your wonder about the 
>>name).  You'd usually implement 
>>org.apache.karaf.shell.console.CompletableFunction too in order to provide 
>>argument completers and also use the annotations defined in 
>>org.apache.felix.gogo.commands in order to have argument conversion.
>
>>On Thu, Mar 17, 2011 at 14:02, Lindley Andrew <[email protected]> 
>>>>wrote:
>> Ah! Thanks for clarification. As the command didn't show up in the 
>> >>completion I was expecting that it didn't came up properly.
>>
>> Why exactly doesn't it appear in the completion or how could I fix that?
>>
>> Tnx
>> Kr Andrew
>>

-----Original Message-----
From: Lindley Andrew [mailto:[email protected]] 
Sent: Thursday, March 17, 2011 1:50 PM
To: [email protected]
Subject: karaf shell extension with iPojo

Dear all,

I am using Karaf 2.1.0 and want to extend the shell with my own shell-commands.
There's a great tutorial showing how to do this with blueprint.
http://karaf.apache.org/manual/2.1.99-SNAPSHOT/developers-guide/extending-console.html

I was trying to do this with iPojo but did not succeed. That's the sample I was 
trying to run.

public interface SampleTUI {

      // the supported operations on the shell we're extending
      String FUNCTION_STR = "[list]";

      // will be used in the activator to define the namespace within the shell
      String SCOPE = "preserv";

      public void list();

}

@Component(name="sample.addons.api.command.KarafSampleTUI")
@Provides
public class KarafSampleTUI implements SampleTUI {

      // the supported operations on the shell we're extending
      @ServiceProperty(name="osgi.command.function", 
value=ServiceRegistryTUI.FUNCTION_STR)
      public String[] functions;
      // will be used in the activator to define the namespace within the shell
      @ServiceProperty(name="osgi.command.scope", 
value=ServiceRegistryTUI.SCOPE)
      public String scope;

      //these fields are injected
      //@Requires
      //private MyUtils mu;


      @Descriptor("some sample description")
      public void list() {
            System.out.println("testing list");
      }
}

<ipojo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
      xsi:schemaLocation="org.apache.felix.ipojo 
http://felix.apache.org/ipojo/schemas/CURRENT/core.xsd
          org.apache.felix.ipojo.extender 
http://felix.apache.org/ipojo/schemas/CURRENT/extender-pattern.xsd";
      xmlns="org.apache.felix.ipojo">

      <instance component="sample.addons.api.command.KarafSampleTUI"/>
</ipojo>

It perfectly runs within Felix using gogo, but not in karaf (using Felix). Is 
this specific to gogo?
I also had a look at apache\felix\ipojo\arch\ and apache\felix\ipojo\arch\gogo 
but both aren't working in karaf as well.

Thanks for your support,
Kr Andrew


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to