I successfully created custom command for Karaf shell. Now I would like to
create multiple commends and shrink them into one Java file and xml. I
tested this example but it's not working:

<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";>
    <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0";>
        <command>
            <action class="org.apache.karaf.demos.command.MyCommand"/>
            <completers>
                <ref component-id="myCompleter"/>
                <null/>
            </completers>
        </command>
        <command>
            <action class="org.apache.karaf.demos.command.MyCommandSec"/>
            <completers>
                <ref component-id="myCompleterSec"/>
                <null/>
            </completers>
        </command>
    </command-bundle>
    <bean id="myCompleter"
class="org.apache.karaf.demos.command.MyCompleter"/>
    <bean id="myCompleterSec"
class="org.apache.karaf.demos.command.MyCommandSec"/>
</blueprint>

import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.apache.karaf.shell.console.OsgiCommandSupport;

@Command(scope = "kernel", name = "create", description="Says hello")
public class MyCommand extends OsgiCommandSupport {

    @Argument(index = 0, name = "arg", description = "The command argument",
required = false, multiValued = false)
    String arg = null;

    @Override
    protected Object doExecute() throws Exception {
        System.out.println("Executing My Command Demo");
        return null;
    }
}


This in not working, I get exception. Can you tell me what is the proper way
to do this?




--
View this message in context: 
http://karaf.922171.n3.nabble.com/Configure-multiple-custom-commands-in-Karaf-tp4035524.html
Sent from the Karaf - Dev mailing list archive at Nabble.com.

Reply via email to