Package org.jboss.as.cli.handlers
Class GenericTypeOperationHandler
- java.lang.Object
-
- org.jboss.as.cli.handlers.CommandHandlerWithArguments
-
- org.jboss.as.cli.handlers.CommandHandlerWithHelp
-
- org.jboss.as.cli.handlers.BaseOperationCommand
-
- org.jboss.as.cli.handlers.BatchModeCommandHandler
-
- org.jboss.as.cli.handlers.GenericTypeOperationHandler
-
- All Implemented Interfaces:
CliEventListener,CommandHandler,OperationCommand
public class GenericTypeOperationHandler extends BatchModeCommandHandler
- Author:
- Alexey Loubyansky
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.jboss.as.cli.OperationCommand
OperationCommand.HandledRequest
-
-
Field Summary
Fields Modifier and Type Field Description protected StringcommandNameprotected Set<String>excludedOpsprotected ArgumentWithoutValuehelpCommandsprotected ArgumentWithoutValuehelpPropertiesprotected StringidPropertyprotected ArgumentWithValuenameprotected StringnodeTypeprotected ArgumentWithValueoperationprotected ArgumentWithValueprofile-
Fields inherited from class org.jboss.as.cli.handlers.BaseOperationCommand
accessRequirement, headers, params, requiredAddress
-
Fields inherited from class org.jboss.as.cli.handlers.CommandHandlerWithHelp
helpArg
-
-
Constructor Summary
Constructors Constructor Description GenericTypeOperationHandler(String commandName, CommandContext ctx, String nodeType, String idProperty)Generic command constructor.GenericTypeOperationHandler(String commandName, CommandContext ctx, String nodeType, String idProperty, boolean isChildNode)Generic command constructor.GenericTypeOperationHandler(String commandName, CommandContext ctx, String nodeType, String idProperty, boolean isChildNode, String... excludeOperations)Generic command constructor.GenericTypeOperationHandler(String commandName, CommandContext ctx, String nodeType, String idProperty, String... excludeOperations)Generic command constructor.GenericTypeOperationHandler(CommandContext ctx, String nodeType, String idProperty)Generic command constructor.GenericTypeOperationHandler(CommandContext ctx, String nodeType, String idProperty, String... excludeOperations)Generic command constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddArgument(CommandArgument arg)voidaddHandler(String name, OperationCommandWithDescription handler)voidaddValueCompleter(String propertyName, CommandLineCompleter completer)voidaddValueConverter(String propertyName, ArgumentValueConverter converter)protected org.jboss.dmr.ModelTypeasType(org.jboss.dmr.ModelNode type)org.jboss.dmr.ModelNodebuildRequestWithoutHeaders(CommandContext ctx)voidcliEvent(CliEvent event, CommandContext ctx)protected voidformatProperty(CommandContext ctx, String argName, CharSequence descr)protected StringBuilderformatResponse(CommandContext ctx, org.jboss.dmr.ModelNode opResponse, boolean composite, StringBuilder buf)protected voidformatText(CommandContext ctx, CharSequence text, int offset)CommandArgumentgetArgument(CommandContext ctx, String name)Returns command argument declared by the command handler corresponding to the argument name.Collection<CommandArgument>getArguments(CommandContext ctx)Returns a collection of the command arguments the handler supports in the current context.protected Iterator<org.jboss.as.cli.handlers.GenericTypeOperationHandler.AttributeDescription>getAttributeIterator(List<org.jboss.dmr.Property> props, org.jboss.dmr.ModelNode accessControl)StringgetCommandName()protected Iterator<org.jboss.as.cli.handlers.GenericTypeOperationHandler.AttributeDescription>getNodeProperties(CommandContext ctx)protected org.jboss.dmr.ModelNodegetOperationDescription(CommandContext ctx, String operationName)protected List<String>getSupportedCommands(CommandContext ctx)protected voidhandleResponse(CommandContext ctx, org.jboss.dmr.ModelNode opResponse, boolean composite)booleanhasArgument(CommandContext ctx, int index)Checks whether the command handler accepts an argument with the specified index.booleanhasArgument(CommandContext ctx, String name)Checks whether the command handler recognizes the argument by the name.protected org.jboss.dmr.ModelNodeinitRequest(CommandContext ctx)voidprintDescription(CommandContext ctx)protected voidprintHelp(CommandContext ctx)protected voidprintNodeDescription(CommandContext ctx)protected voidprintProperties(CommandContext ctx, Iterator<org.jboss.as.cli.handlers.GenericTypeOperationHandler.AttributeDescription> props)protected voidprintSupportedCommands(CommandContext ctx)protected voidrecognizeArguments(CommandContext ctx)-
Methods inherited from class org.jboss.as.cli.handlers.BatchModeCommandHandler
isBatchMode
-
Methods inherited from class org.jboss.as.cli.handlers.BaseOperationCommand
addHeaders, addRequiredPath, addRequiredPath, buildRequest, buildRequestWOValidation, displayResponseHeaders, doHandle, getAttachments, getRequiredAddress, getRequiredType, handleAttachedFile, handleResponse, isAddressValid, isAvailable, isDependsOnProfile, setParams, setupAccessRequirement
-
Methods inherited from class org.jboss.as.cli.handlers.CommandHandlerWithHelp
displayHelp, handle, printList
-
Methods inherited from class org.jboss.as.cli.handlers.CommandHandlerWithArguments
getArgumentsMap
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jboss.as.cli.CommandHandler
handle
-
Methods inherited from interface org.jboss.as.cli.OperationCommand
buildHandledRequest, buildRequest
-
-
-
-
Field Detail
-
commandName
protected final String commandName
-
idProperty
protected final String idProperty
-
nodeType
protected final String nodeType
-
profile
protected final ArgumentWithValue profile
-
name
protected final ArgumentWithValue name
-
operation
protected final ArgumentWithValue operation
-
helpProperties
protected final ArgumentWithoutValue helpProperties
-
helpCommands
protected final ArgumentWithoutValue helpCommands
-
-
Constructor Detail
-
GenericTypeOperationHandler
public GenericTypeOperationHandler(CommandContext ctx, String nodeType, String idProperty)
Generic command constructor.- Parameters:
ctx- The CommandContext.nodeType- The resource type. This type is used to name the command.idProperty- The property name that identify the resource.
-
GenericTypeOperationHandler
public GenericTypeOperationHandler(String commandName, CommandContext ctx, String nodeType, String idProperty)
Generic command constructor.- Parameters:
commandName- The name of the command. If null, nodeType is used.ctx- The CommandContext.nodeType- The resource type.idProperty- The property name that identify the resource.
-
GenericTypeOperationHandler
public GenericTypeOperationHandler(String commandName, CommandContext ctx, String nodeType, String idProperty, boolean isChildNode)
Generic command constructor.- Parameters:
commandName- The name of the command. If null, nodeType is used.ctx- The CommandContext.nodeType- The resource type.idProperty- The property name that identify the resource.isChildNode- True is the path references a child node, false if the path references a type node.
-
GenericTypeOperationHandler
public GenericTypeOperationHandler(CommandContext ctx, String nodeType, String idProperty, String... excludeOperations)
Generic command constructor.- Parameters:
ctx- The CommandContext.nodeType- The resource type. This type is used to name the command.idProperty- The property name that identify the resource.excludeOperations- The list of operations to exclude.
-
GenericTypeOperationHandler
public GenericTypeOperationHandler(String commandName, CommandContext ctx, String nodeType, String idProperty, String... excludeOperations)
Generic command constructor.- Parameters:
commandName- The name of the command. If null, nodeType is used.ctx- The CommandContext.nodeType- The resource type.idProperty- The property name that identify the resource.excludeOperations- The list of operations to exclude.
-
GenericTypeOperationHandler
public GenericTypeOperationHandler(String commandName, CommandContext ctx, String nodeType, String idProperty, boolean isChildNode, String... excludeOperations)
Generic command constructor.- Parameters:
commandName- The name of the command. If null, nodeType is used.ctx- The CommandContext.nodeType- The resource type.isChildNode- True is the path references a child node, false if the path references a type node.idProperty- The property name that identify the resource.excludeOperations- The list of operations to exclude.
-
-
Method Detail
-
getCommandName
public String getCommandName()
-
addValueConverter
public void addValueConverter(String propertyName, ArgumentValueConverter converter)
-
addValueCompleter
public void addValueCompleter(String propertyName, CommandLineCompleter completer)
-
addHandler
public void addHandler(String name, OperationCommandWithDescription handler)
-
getArgument
public CommandArgument getArgument(CommandContext ctx, String name)
Description copied from interface:CommandHandlerReturns command argument declared by the command handler corresponding to the argument name. Or null if the argument wasn't found among the accepted arguments.- Specified by:
getArgumentin interfaceCommandHandler- Overrides:
getArgumentin classCommandHandlerWithArguments- Parameters:
ctx- the current contextname- the name of the argument- Returns:
- command argument corresponding to the argument name or null if the argument name wasn't recognized.
-
getArguments
public Collection<CommandArgument> getArguments(CommandContext ctx)
Description copied from interface:CommandHandlerReturns a collection of the command arguments the handler supports in the current context.- Specified by:
getArgumentsin interfaceCommandHandler- Overrides:
getArgumentsin classCommandHandlerWithArguments- Parameters:
ctx- current command line context- Returns:
- list of the command arguments supported in the current context
-
asType
protected org.jboss.dmr.ModelType asType(org.jboss.dmr.ModelNode type)
-
hasArgument
public boolean hasArgument(CommandContext ctx, String name)
Description copied from interface:CommandHandlerChecks whether the command handler recognizes the argument by the name.- Specified by:
hasArgumentin interfaceCommandHandler- Overrides:
hasArgumentin classCommandHandlerWithArguments- Parameters:
ctx- the current contextname- argument name to check- Returns:
- true if the handler recognizes the argument, otherwise - false.
-
hasArgument
public boolean hasArgument(CommandContext ctx, int index)
Description copied from interface:CommandHandlerChecks whether the command handler accepts an argument with the specified index.- Specified by:
hasArgumentin interfaceCommandHandler- Overrides:
hasArgumentin classCommandHandlerWithArguments- Parameters:
ctx- the current contextindex- argument index to check- Returns:
- true if the handler accepts an argument with the specified index, otherwise - false.
-
addArgument
public void addArgument(CommandArgument arg)
- Overrides:
addArgumentin classBaseOperationCommand
-
recognizeArguments
protected void recognizeArguments(CommandContext ctx) throws CommandFormatException
- Overrides:
recognizeArgumentsin classCommandHandlerWithArguments- Throws:
CommandFormatException
-
buildRequestWithoutHeaders
public org.jboss.dmr.ModelNode buildRequestWithoutHeaders(CommandContext ctx) throws CommandFormatException
- Specified by:
buildRequestWithoutHeadersin classBaseOperationCommand- Throws:
CommandFormatException
-
cliEvent
public void cliEvent(CliEvent event, CommandContext ctx)
- Specified by:
cliEventin interfaceCliEventListener- Overrides:
cliEventin classBaseOperationCommand
-
handleResponse
protected void handleResponse(CommandContext ctx, org.jboss.dmr.ModelNode opResponse, boolean composite) throws CommandFormatException
- Overrides:
handleResponsein classBaseOperationCommand- Throws:
CommandFormatException
-
formatResponse
protected StringBuilder formatResponse(CommandContext ctx, org.jboss.dmr.ModelNode opResponse, boolean composite, StringBuilder buf) throws CommandFormatException
- Throws:
CommandFormatException
-
printHelp
protected void printHelp(CommandContext ctx) throws CommandLineException
- Overrides:
printHelpin classCommandHandlerWithHelp- Throws:
CommandLineException
-
printProperties
protected void printProperties(CommandContext ctx, Iterator<org.jboss.as.cli.handlers.GenericTypeOperationHandler.AttributeDescription> props)
-
printDescription
public void printDescription(CommandContext ctx) throws CommandFormatException
- Throws:
CommandFormatException
-
printNodeDescription
protected void printNodeDescription(CommandContext ctx) throws CommandFormatException
- Throws:
CommandFormatException
-
formatText
protected void formatText(CommandContext ctx, CharSequence text, int offset)
-
formatProperty
protected void formatProperty(CommandContext ctx, String argName, CharSequence descr)
-
printSupportedCommands
protected void printSupportedCommands(CommandContext ctx) throws CommandLineException
- Throws:
CommandLineException
-
getSupportedCommands
protected List<String> getSupportedCommands(CommandContext ctx) throws CommandLineException
- Throws:
CommandLineException
-
getNodeProperties
protected Iterator<org.jboss.as.cli.handlers.GenericTypeOperationHandler.AttributeDescription> getNodeProperties(CommandContext ctx) throws CommandLineException
- Throws:
CommandLineException
-
getAttributeIterator
protected Iterator<org.jboss.as.cli.handlers.GenericTypeOperationHandler.AttributeDescription> getAttributeIterator(List<org.jboss.dmr.Property> props, org.jboss.dmr.ModelNode accessControl)
-
getOperationDescription
protected org.jboss.dmr.ModelNode getOperationDescription(CommandContext ctx, String operationName) throws CommandLineException
- Throws:
CommandLineException
-
initRequest
protected org.jboss.dmr.ModelNode initRequest(CommandContext ctx) throws CommandFormatException
- Throws:
CommandFormatException
-
-