[jboss-as7-dev] another approach to cli commands / operations
Alexey Loubyansky
alexey.loubyansky at redhat.com
Fri Jun 17 09:44:23 EDT 2011
Up until now I've been writing commands and handlers manually. It is
justified in some cases like deploy for example. But I realized it's too
much redundant work for commands to e.g. manage datasources, etc.
What I mean is I wrote add-data-source, remove-data-source,
modify-data-source. Then there could be enable, disable, flush
connections, etc. So instead, I wrote one command that I called data-source.
Now it looks like this (it's tab-completion)
[standalone at localhost:9999 /] data-source java:/H2DS
add disable enable
flush-all-connection-in-pool
flush-idle-connection-in-pool read-attribute
read-children-names read-children-resources
read-children-types read-operation-description
read-operation-names read-resource
read-resource-description remove
test-connection-in-pool write-attribute
So you can choose whatever operation you want, e.g.
data-source java:/H2DS flush-all-connection-in-pool
or whatever. If there are properties, it could look like
data-source java:/H2DS my-operation --prop1=val1 --prop2=val2
or to modify properties of the data source
data-source java:/H2DS --min-pool-size=10 --max-pool-size=100
At the end, this will save the total number of the commands, avoid
possible inconsistency between commands and operations (like supported
properties and even operations), the changes in operations and
properties will be immediately exposed through the cli w/o
changing/introducing new cli commands.
In addition, this data-source thing is actually no more than an alias to
the node path, i.e. /subsystem=datasources/data-source. So, actually,
this can be done for any component in a generic way, e.g. jms, etc. And
even it could be customized by the user at runtime.
Again, that's not for everything. For things like deploy, we could keep
hand-written command handlers but for the majority of the managed
components this could work (although there are some operations that
don't make much sense to expose, e.g. write-attribute or add as an
operation on a specific data source but these could be filtered somehow).
So, if anybody has suggestions or objections, please, let me know.
Otherwise, I intend to do it this way. Not for CR1 though.
Thanks,
Alexey
More information about the jboss-as7-dev
mailing list