Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Apache Felix Shell Service

Anchor
overview
overview

Overview

...

The remainder of this document describes how the shell service works and how to create custom commands for it. This document does not describe how to use the command shell, nor does it describe the text-based or GUI-based user interfaces that are available for the shell.

Anchor
service
service

How the Shell Service Works

...

Notice that there is no method to add commands to the shell service interface. This is because commands are implemented as OSGi services and the shell service listens for service events and when a command service registers/unregisters it automatically updates its list of commands accordingly.

Anchor
commands
commands

How Commands Work

All commands available in the shell service are implemented as OSGi services. The advantage of this approach is two-fold: the shell service can leverage OSGi service events to maintain its list of available commands and the set available commands is dynamically extendable by installed bundles. The command service interface is defined as follows:

...

  • getName() - returns the name of the command; this must not contain whitespace and must be unique.
  • getUsage() - returns the usage string of the command; this should be one line and as short as possible (this is used for generating the help command output).
  • getShortDescription() - returns a short description of the command; this should be one line and as short as possible (this is used for generating the help command output).
  • execute() - executes the command's functionality using supplied command line and print streams.

Anchor
creating
creating

Creating a Command

The following example creates a simple version of the start command.

...

This command creates a JAR file using the manifest you created and includes all of the classes in the test directory inside of the c:\classes directory. Once the bundle JAR file is created, you are ready to add the command service to the shell service; simply start Felix and install and start the bundle created by the above command. By doing so, the new mystart command is made available via the shell service.

Anchor
security
security

Security and the Shell Service

The shell service security handling is quite simple, all security is handled by the standard OSGi framework mechanisms. For example, if a bundle should not be able to register a shell service, then it should not be given the corresponding service permission. Security handling may change in future release after some experience is gained through usage.

Anchor
feedback
feedback

Feedback

Subscribe to the Felix mailing list by sending a message to users-subscribe@felix.apache.org; after subscribing, email questions or feedback to users@felix.apache.org.