Package org.onosproject.cli
Class AbstractShellCommand
- java.lang.Object
- 
- org.onosproject.cli.AbstractShellCommand
 
- 
- All Implemented Interfaces:
- org.apache.karaf.shell.api.action.Action,- CodecContext
 - Direct Known Subclasses:
- AddProtectedTransportIntentCommand,- AddTestFlowsCommand,- AllocationsCommand,- AnnotateDeviceCommand,- AnnotateHostCommand,- AnnotateLinkCommand,- AnnotatePortCommand,- ApplicationCommand,- ApplicationIdListCommand,- ApplicationsListCommand,- BalanceMastersCommand,- ComponentConfigCommand,- ConfigureLinkCommand,- ConnectivityIntentCommand,- CounterCommand,- CountersListCommand,- DeviceControllersCommand,- DeviceDriversCommand,- DeviceInterfaceAddCommand,- DeviceInterfaceRemoveCommand,- DeviceKeyAddCommand,- DeviceKeyListCommand,- DeviceKeyRemoveCommand,- DevicePortsRemoveCommand,- DevicePortStateCommand,- DevicePortStatsCommand,- DeviceRebootCommand,- DeviceRemoveCommand,- DeviceRoleCommand,- DeviceSetControllersCommand,- DevicesListCommand,- DeviceTimeCommand,- DriverProvidersListCommand,- DriversListCommand,- EdgePortsListCommand,- FlowObjectiveCompositionCommand,- FlowObjectiveNextListCommand,- FlowObjectivePendingNextCommand,- FlowObjectiveQueueClearCommand,- FlowObjectiveQueueListCommand,- FlowsListCommand,- GetDomainsCommand,- GetFlowStatisticsCommand,- GetStatisticsCommand,- GroupsListCommand,- HostRemoveCommand,- HostsListCommand,- IntentCycleCommand,- IntentDetailsCommand,- IntentListCompilers,- IntentListInstallers,- IntentPurgeCommand,- IntentPushTestCommand,- IntentRemoveCommand,- IntentsDiagnosisCommand,- IntentsListCommand,- InterfaceAddCommand,- InterfaceRemoveCommand,- InterfacesListCommand,- IssuCommand,- LayoutAddCommand,- LayoutListCommand,- LeaderCommand,- LinksListCommand,- MapsListCommand,- MarkCommand,- MastersListCommand,- McastDeleteCommand,- McastJoinCommand,- McastRoutesListCommand,- McastShowCommand,- MembershipsListCommand,- MeterAddCommand,- MeterRemoveCommand,- MetersListCommand,- MetricsListCommand,- NeighbourHandlersListCommand,- NetworkConfigCommand,- NetworkConfigRegistryCommand,- NodesListCommand,- PacketProcessorsListCommand,- PacketRequestsListCommand,- PartitionsListCommand,- PipeconfCommand,- PortQueryVlansCommand,- PowerConfigCommand,- PrettyJson,- PrettyXml,- QueuesListCommand,- RandomIntentCommand,- RegionAddCommand,- RegionAddDevicesCommand,- RegionAddPeerLocCommand,- RegionListCommand,- RegionRemoveCommand,- RegionRemoveDevicesCommand,- RegionUpdateCommand,- ResourcesCommand,- ReviewCommand,- RolesCommand,- ScrListCommand,- StorageNodesListCommand,- SummaryCommand,- TableStatisticsCommand,- TestAllocateResource,- TestProtectionEndpointIntentCommand,- TopologyCommand,- TransactionsCommand,- WipeOutCommand
 
 public abstract class AbstractShellCommand extends java.lang.Object implements org.apache.karaf.shell.api.action.Action, CodecContext Base abstraction of Karaf shell commands.
- 
- 
Field SummaryFields Modifier and Type Field Description protected static org.slf4j.Loggerlog
 - 
Constructor SummaryConstructors Constructor Description AbstractShellCommand()
 - 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static com.fasterxml.jackson.databind.node.ObjectNodeannotations(com.fasterxml.jackson.databind.ObjectMapper mapper, Annotations annotations)Produces a JSON object from the specified key/value annotations.static java.lang.Stringannotations(Annotations annotations)Produces a string image of the specified key/value annotations.static java.lang.Stringannotations(Annotations annotations, java.util.Set<java.lang.String> excludedKeys)Produces a string image of the specified key/value annotations.protected ApplicationIdappId()Returns application ID for the CLI.<T> JsonCodec<T>codec(java.lang.Class<T> entityClass)Returns the JSON codec for the specified entity class.protected abstract voiddoExecute()Body of the shell command.voiderror(java.lang.String format, java.lang.Object... args)Prints the arguments using the specified format to error stream.java.lang.Objectexecute()static <T> Tget(java.lang.Class<T> serviceClass)Returns the reference to the implementation of the specified service.<T> TgetService(java.lang.Class<T> serviceClass)Returns reference to the specified service implementation.<T> com.fasterxml.jackson.databind.node.ObjectNodejsonForEntity(T entity, java.lang.Class<T> entityClass)Generates a Json representation of an object.com.fasterxml.jackson.databind.ObjectMappermapper()Returns the JSON object mapper.protected booleanoutputJson()Indicates whether JSON format should be output.voidprint(java.lang.String format, java.lang.Object... args)Prints the arguments using the specified format.- 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.onosproject.codec.CodecContextdecode, encode
 
- 
 
- 
- 
- 
Method Detail- 
getpublic static <T> T get(java.lang.Class<T> serviceClass) Returns the reference to the implementation of the specified service.- Type Parameters:
- T- type of service
- Parameters:
- serviceClass- service class
- Returns:
- service implementation
- Throws:
- ServiceNotFoundException- if service is unavailable
 
 - 
appIdprotected ApplicationId appId() Returns application ID for the CLI.- Returns:
- command-line application identifier
 
 - 
printpublic void print(java.lang.String format, java.lang.Object... args)Prints the arguments using the specified format.- Parameters:
- format- format string; see- String.format(java.lang.String, java.lang.Object...)
- args- arguments
 
 - 
errorpublic void error(java.lang.String format, java.lang.Object... args)Prints the arguments using the specified format to error stream.- Parameters:
- format- format string; see- String.format(java.lang.String, java.lang.Object...)
- args- arguments
 
 - 
annotationspublic static java.lang.String annotations(Annotations annotations) Produces a string image of the specified key/value annotations.- Parameters:
- annotations- key/value annotations
- Returns:
- string image with ", k1=v1, k2=v2, ..." pairs
 
 - 
annotationspublic static java.lang.String annotations(Annotations annotations, java.util.Set<java.lang.String> excludedKeys) Produces a string image of the specified key/value annotations. Excludes the keys in the given Set.- Parameters:
- annotations- key/value annotations
- excludedKeys- keys not to add in the resulting string
- Returns:
- string image with ", k1=v1, k2=v2, ..." pairs
 
 - 
annotationspublic static com.fasterxml.jackson.databind.node.ObjectNode annotations(com.fasterxml.jackson.databind.ObjectMapper mapper, Annotations annotations)Produces a JSON object from the specified key/value annotations.- Parameters:
- mapper- ObjectMapper to use while converting to JSON
- annotations- key/value annotations
- Returns:
- JSON object
 
 - 
outputJsonprotected boolean outputJson() Indicates whether JSON format should be output.- Returns:
- true if JSON is requested
 
 - 
executepublic final java.lang.Object execute() throws java.lang.Exception- Specified by:
- executein interface- org.apache.karaf.shell.api.action.Action
- Throws:
- java.lang.Exception
 
 - 
doExecuteprotected abstract void doExecute() throws java.lang.ExceptionBody of the shell command.- Throws:
- java.lang.Exception- thrown when problem is encountered
 
 - 
mapperpublic com.fasterxml.jackson.databind.ObjectMapper mapper() Description copied from interface:CodecContextReturns the JSON object mapper.- Specified by:
- mapperin interface- CodecContext
- Returns:
- object mapper
 
 - 
codecpublic <T> JsonCodec<T> codec(java.lang.Class<T> entityClass) Description copied from interface:CodecContextReturns the JSON codec for the specified entity class.- Specified by:
- codecin interface- CodecContext
- Type Parameters:
- T- entity type
- Parameters:
- entityClass- entity class
- Returns:
- JSON codec; null if no codec available for the class
 
 - 
getServicepublic <T> T getService(java.lang.Class<T> serviceClass) Description copied from interface:CodecContextReturns reference to the specified service implementation.- Specified by:
- getServicein interface- CodecContext
- Type Parameters:
- T- service type
- Parameters:
- serviceClass- service class
- Returns:
- service implementation; null if no implementation available for the class
 
 - 
jsonForEntitypublic <T> com.fasterxml.jackson.databind.node.ObjectNode jsonForEntity(T entity, java.lang.Class<T> entityClass)Generates a Json representation of an object.- Type Parameters:
- T- Type of the object being formatted
- Parameters:
- entity- object to generate JSON for
- entityClass- class to format with - this chooses which codec to use
- Returns:
- JSON object representation
 
 
- 
 
-