public abstract class AbstractShellCommand
extends org.apache.karaf.shell.console.AbstractAction
implements org.onosproject.codec.CodecContext
| 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 Object |
doExecute() |
void |
error(String format,
Object... args)
Prints the arguments using the specified format to error stream.
|
protected abstract void |
execute()
Executes this command.
|
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 abstract void execute()
protected boolean outputJson()
protected Object doExecute() throws Exception
doExecute in class org.apache.karaf.shell.console.AbstractActionExceptionpublic 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