Richard S. Hall | 930fecc | 2005-08-16 18:33:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2005 The Apache Software Foundation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | * |
| 16 | */ |
| 17 | package org.ungoverned.osgi.service.shell; |
| 18 | |
| 19 | import java.io.PrintStream; |
| 20 | |
| 21 | import org.osgi.framework.ServiceReference; |
| 22 | |
| 23 | /** |
Richard S. Hall | 5a03159 | 2005-08-19 19:53:58 +0000 | [diff] [blame] | 24 | * This interface defines the Felix impl service. The impl service |
| 25 | * is an extensible, user interface neutral impl for controlling and |
| 26 | * interacting with the framework. In general, the impl service assumes that |
Richard S. Hall | 930fecc | 2005-08-16 18:33:34 +0000 | [diff] [blame] | 27 | * it is operating in a command line fashion, i.e., it receives a |
| 28 | * complete command line, parses it, and executes the corresponding |
| 29 | * command, but graphical interfaces are also possible. |
| 30 | * <p> |
Richard S. Hall | 5a03159 | 2005-08-19 19:53:58 +0000 | [diff] [blame] | 31 | * All commands in the impl service are actually implemented as OSGi |
Richard S. Hall | 930fecc | 2005-08-16 18:33:34 +0000 | [diff] [blame] | 32 | * services; these services implement the <tt>Command</tt> service |
| 33 | * interface. Any bundle can implement custom commands by creating |
| 34 | * command services and registering them with the OSGi framework. |
| 35 | **/ |
| 36 | public interface ShellService |
| 37 | { |
| 38 | /** |
Richard S. Hall | 5a03159 | 2005-08-19 19:53:58 +0000 | [diff] [blame] | 39 | * Returns an array of command names available in the impl service. |
Richard S. Hall | 930fecc | 2005-08-16 18:33:34 +0000 | [diff] [blame] | 40 | * @return an array of available command names or an empty array. |
| 41 | **/ |
| 42 | public String[] getCommands(); |
| 43 | |
| 44 | /** |
| 45 | * Returns the usage string associated with the specified command name. |
| 46 | * @param name the name of the target command. |
| 47 | * @return the usage string of the specified command or null. |
| 48 | **/ |
| 49 | public String getCommandUsage(String name); |
| 50 | |
| 51 | /** |
| 52 | * Returns the description associated with the specified command name. |
| 53 | * @param name the name of the target command. |
| 54 | * @return the description of the specified command or null. |
| 55 | **/ |
| 56 | public String getCommandDescription(String name); |
| 57 | |
| 58 | /** |
| 59 | * Returns the service reference associated with the specified |
| 60 | * command name. |
| 61 | * @param name the name of the target command. |
| 62 | * @return the description of the specified command or null. |
| 63 | **/ |
| 64 | public ServiceReference getCommandReference(String name); |
| 65 | |
| 66 | /** |
| 67 | * |
| 68 | * This method executes the supplied command line using the |
| 69 | * supplied output and error print stream. The assumption of |
| 70 | * this method is that a command line will be typed by the user |
| 71 | * (or perhaps constructed by a GUI) and passed into it for |
| 72 | * execution. The command line is interpretted in a very |
| 73 | * simplistic fashion; it takes the leading string of characters |
| 74 | * terminated by a space character (not including it) and |
| 75 | * assumes that this leading token is the command name. For an |
| 76 | * example, consider the following command line: |
| 77 | * </p> |
| 78 | * <pre> |
| 79 | * update 3 http://www.foo.com/bar.jar |
| 80 | * </pre> |
| 81 | * <p> |
| 82 | * This is interpretted as an <tt>update</tt> command; as a |
| 83 | * result, the entire command line (include command name) is |
| 84 | * passed into the <tt>execute()</tt> method of the command |
| 85 | * service with the name <tt>update</tt> if one exists. If the |
| 86 | * corresponding command service is not found, then an error |
| 87 | * message is printed to the error print stream. |
| 88 | * @param commandLine the command line to execute. |
| 89 | * @param out the standard output print stream. |
| 90 | * @param err the standard error print stream. |
| 91 | **/ |
| 92 | public void executeCommand( |
| 93 | String commandLine, PrintStream out, PrintStream err) |
| 94 | throws Exception; |
| 95 | } |