public class CommandCatalog
extends java.lang.Object
Commands are implementations of TextBuiltin
,
with an optional Command
class annotation to
insert additional documentation or override the default command name (which
is guessed from the class name).
Commands may be registered by adding them to a services file in the same JAR
(or classes directory) as the command implementation. The service file name
is META-INF/services/org.eclipse.jgit.pgm.TextBuiltin
and it
contains one concrete implementation class name per line.
Command registration is identical to Java 6's services, however the catalog uses a lightweight wrapper to delay creating a command instance as much as possible. This avoids initializing the AWT or SWT GUI toolkits even if the command's constructor might require them.
Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.String,CommandRef> |
commands |
private static CommandCatalog |
INSTANCE |
private java.lang.ClassLoader |
ldr |
Modifier | Constructor and Description |
---|---|
private |
CommandCatalog() |
Modifier and Type | Method and Description |
---|---|
static CommandRef[] |
all()
Get all commands sorted by their name
|
private java.util.Enumeration<java.net.URL> |
catalogs() |
static CommandRef[] |
common()
Get all common commands sorted by their name
|
static CommandRef |
get(java.lang.String name)
Locate a single command by its user friendly name.
|
private void |
load(java.lang.String cn) |
private void |
scan(java.net.URL cUrl) |
private static CommandRef[] |
toSortedArray(java.util.Collection<CommandRef> c) |
private static final CommandCatalog INSTANCE
private final java.lang.ClassLoader ldr
private final java.util.Map<java.lang.String,CommandRef> commands
public static CommandRef get(java.lang.String name)
name
- name of the command. Typically in dash-lower-case-form, which
was derived from the DashLowerCaseForm class name.public static CommandRef[] all()
public static CommandRef[] common()
private static CommandRef[] toSortedArray(java.util.Collection<CommandRef> c)
private java.util.Enumeration<java.net.URL> catalogs()
private void scan(java.net.URL cUrl)
private void load(java.lang.String cn)