Uploaded image for project: 'Karaf'
  1. Karaf
  2. KARAF-4118

Command service declaration doesn't work

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 4.0.2, 4.0.3
    • 4.0.4
    • karaf
    • None

    Description

      Before Karaf 4, it was possible to define command by "declaration".

      For instance, having a simple class like this:

      package net.nanthrax.test.shell;
      
      public class HelloCommand {
      
          public String hello() {
              return "hello";
          }
      
      }
      

      It was possible to "declare" a command (for instance using blueprint):

      <?xml version="1.0" encoding="UTF-8"?>
      <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
      
          <bean id="helloCommand" class="net.nanthrax.test.shell.HelloCommand"/>
      
          <service ref="helloCommand" auto-export="class-hierarchy">
              <service-properties>
                  <entry key="osgi.command.scope" value="hello"/>
                  <entry key="osgi.command.function">
                      <array>
                          <value>hello</value>
                      </array>
                  </entry>
              </service-properties>
          </service>
      
      </blueprint>
      

      However, in Karaf 4, the command is not found.

      The cause comes from the org.apache.karaf.shell.compat.CommandTracker: if the class doesn't implement one of the two interfaces (org.apache.karaf.shell.commands.CommandWithAction or org.apache.felix.gogo.commands.CommandWithAction interface), the command is not register.

      So basically, I gonna add the case where the class doesn't implement any interface

      Attachments

        Issue Links

          Activity

            People

              jbonofre Jean-Baptiste Onofré
              jbonofre Jean-Baptiste Onofré
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: