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

Unable to have multiple subshells in one bundle

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.0.0
    • 3.0.1, 4.0.0.M3
    • karaf
    • None
    • JDK7, Aries Blueprint, karaf shell schema v1.1.0

    Description

      PROBLEM:
      According to Karaf 3.0.0 release note, Karaf "groups" the commands by scope. Each scope form a subshell. Users should be able to enter subshell directly by typing the subshell name.

      However, if commands with different scopes are packaged in one OSGI bundle, only the scope of the first command in the blueprint xml file will be registered as subshell.

      For example, I have the following three commands in a OSGI bundle

      @Command(scope = "children", name = "boy", description = "boy's command")
      public class BoyCommand extends OsgiCommandSupport {
      }

      @Command(scope = "children", name = "girl", description = "girl's command")
      public class GirlCommand extends OsgiCommandSupport {
      }

      @Command(scope = "pet", name = "dog", description = "dog's command")
      public class DogCommand extends OsgiCommandSupport {
      }

      And they are in blueprint xml file.

      <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" default-activation="lazy">
      <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
      <command>
      <action class="com.test.BoyCommand" />
      </command>
      <command>
      <action class="com.test.GirlCommand" />
      </command>
      <command>
      <action class="com.test.DogCommand" />
      </command>
      </command-bundle>
      </blueprint>

      I can access children subshell directly by type "children" but I cannot acess pet subshell by typing "pet"

      SUGGESTION:
      After looking into the source code of karaf 3.0.0, there is a bug around line 188 in org.apache.karaf.shell.console.commands.NamespaceHandler. If the schema is not SHELL_NAMESPACE_1_0_0 or the action name does not contain the scope name, the variable "scope" will be null and the subShellName will always be ".subshell.null". Therefore, if schema is not 1.0.0, only the scope of the first defined command in the OSGI bundle will be registered as subshell in the if statement.

      A patch is attached. Please review if it is a proper fix to the bug

      Attachments

        1. fixSubshell.patch
          7 kB
          Rebecca Chan

        Activity

          People

            jbonofre Jean-Baptiste Onofré
            binaryatwork Rebecca Chan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: