public abstract class AbstractShellCommand extends Object implements org.apache.karaf.shell.api.action.Action, org.onosproject.codec.CodecContext
| Modifier and Type | Field and Description |
|---|---|
protected static org.slf4j.Logger |
log |
| Constructor and Description |
|---|
AbstractShellCommand() |
| Modifier and Type | Method and Description |
|---|---|
static String |
annotations(org.onosproject.net.Annotations annotations)
Produces a string image of the specified key/value annotations.
|
static String |
annotations(org.onosproject.net.Annotations annotations,
Set<String> excludedKeys)
Produces a string image of the specified key/value annotations.
|
static com.fasterxml.jackson.databind.node.ObjectNode |
annotations(com.fasterxml.jackson.databind.ObjectMapper mapper,
org.onosproject.net.Annotations annotations)
Produces a JSON object from the specified key/value annotations.
|
protected org.onosproject.core.ApplicationId |
appId()
Returns application ID for the CLI.
|
<T> org.onosproject.codec.JsonCodec<T> |
codec(Class<T> entityClass) |
protected abstract void |
doExecute()
Body of the shell command.
|
void |
error(String format,
Object... args)
Prints the arguments using the specified format to error stream.
|
Object |
execute() |
static <T> T |
get(Class<T> serviceClass)
Returns the reference to the implementation of the specified service.
|
<T> T |
getService(Class<T> serviceClass) |
<T> com.fasterxml.jackson.databind.node.ObjectNode |
jsonForEntity(T entity,
Class<T> entityClass)
Generates a Json representation of an object.
|
com.fasterxml.jackson.databind.ObjectMapper |
mapper() |
protected boolean |
outputJson()
Indicates whether JSON format should be output.
|
void |
print(String format,
Object... args)
Prints the arguments using the specified format.
|
public static <T> T get(Class<T> serviceClass)
T - type of serviceserviceClass - service classorg.onlab.osgi.ServiceNotFoundException - if service is unavailableprotected org.onosproject.core.ApplicationId appId()
public void print(String format, Object... args)
format - format string; see String.format(java.lang.String, java.lang.Object...)args - argumentspublic void error(String format, Object... args)
format - format string; see String.format(java.lang.String, java.lang.Object...)args - argumentspublic static String annotations(org.onosproject.net.Annotations annotations)
annotations - key/value annotationspublic static String annotations(org.onosproject.net.Annotations annotations, Set<String> excludedKeys)
annotations - key/value annotationsexcludedKeys - keys not to add in the resulting stringpublic static com.fasterxml.jackson.databind.node.ObjectNode annotations(com.fasterxml.jackson.databind.ObjectMapper mapper,
org.onosproject.net.Annotations annotations)
mapper - ObjectMapper to use while converting to JSONannotations - key/value annotationsprotected boolean outputJson()
public final Object execute() throws Exception
execute in interface org.apache.karaf.shell.api.action.ActionExceptionprotected abstract void doExecute()
throws Exception
Exception - thrown when problem is encounteredpublic com.fasterxml.jackson.databind.ObjectMapper mapper()
mapper in interface org.onosproject.codec.CodecContextpublic <T> org.onosproject.codec.JsonCodec<T> codec(Class<T> entityClass)
codec in interface org.onosproject.codec.CodecContextpublic <T> T getService(Class<T> serviceClass)
getService in interface org.onosproject.codec.CodecContextpublic <T> com.fasterxml.jackson.databind.node.ObjectNode jsonForEntity(T entity,
Class<T> entityClass)
T - Type of the object being formattedentity - object to generate JSON forentityClass - class to format with - this chooses which codec to use