Versions Compared

Key

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

Apache Felix Shell

...

Anchor
overview
overview

Overview

In order to interact with Felix it is necessary to have some sort of interactive shell that allows you to issue commands to the framework and to obtain information from it. The OSGi specification does not define how an OSGi framework should provide this interactivity. Felix defines a shell service for creating and executing arbitrary commands. The shell service does not define a user interface, only a service API.

...

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

The Felix shell service is intended to be a simple, but extensible shell service that can have multiple user interface implementations, all of which are independent from the Felix framework. The shell service is currently not intended to be sophisticated, rather it is just a mechanism to execute commands. The shell service maintains a list of command services, each of which have a unique command name. The shell service is defined by the following service interface:

...

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 users mailing list by sending a message to users-subscribe@felix.apache.org; after subscribing, email questions or feedback to users@felix.apache.org.