<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Generic type CLI commands
</h3>
<span style="margin-bottom: 10px;">
    modified by <a href="http://community.jboss.org/people/aloubyansky">Alexey Loubyansky</a> in <i>JBoss AS7 Development</i> - <a href="http://community.jboss.org/docs/DOC-16981">View the full document</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>A type generic command is a command that is assigned to a specific node type and which allows to perform any operation and/or modify any of the properties exposed by the type on any existing instance of that type.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>For example, suppose there is a generic type command assigned to type /subsystem=datasources/data-source which is named data-source. Now using data-source command we can invoke any operation available for children of /subsystem=datasources/data-source and modify any of their properties (that have access-type read-write). The only thing left is to identify the target datasource we want to apply the action to. This is done by choosing one of the properties of the type as the identifying property. In case of this example, for datasources it could be, e.g., the jndi-name.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Now you can invoke operations on data sources like this</p><pre class="jive-pre"><code class="jive-code">
[standalone@localhost:9999 /] data-source flush-all-connection-in-pool --jndi-name=myds</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>flush-all-connection-in-pool is an operation name which is exposed by the management model for all datasources and jndi-name argument identifies the datasource flush-all-connection-in-pool should be performed on.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>If the operation we want to perform requires properties, the properties can be added as command line arguments, i.e. here is an example of adding a new datasource</p><pre class="jive-pre"><code class="jive-code">
[standalone@localhost:9999 /] data-source add --jndi-name=myds --driver-name=h2 --pool-name=myds-pool --connection-url=curl</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>add is an operation name and the argument names match the operation property names prefixed with '--'.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Node properties can be modified in a similar way. Property names prefixed with '--' become arguments names. Except here we don't need an operation name, just the identifying property, i.e. the jndi-name in our case (which is a read-only property). E.g.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code">[standalone@localhost:9999 /] data-source --jndi-name=myds --min-pool-size=11 --max-pool-size=22</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The examples above are actually for standalone mode. In domain mode, for the commands above to work they need one more argument - --profile. E.g.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code">[standalone@localhost:9999 /] data-source --profile=default --jndi-name=myds --min-pool-size=11 --max-pool-size=22</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h3>Getting help</h3><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Generic type commands support --help option. The help content is fetched from the management model and is based on the description of the node type, operations and properties it exposes. E.g. the following will print the description of the type</p><pre class="jive-pre"><code class="jive-code">
[standalone@localhost:9999 /] data-source --help
A jdbc data-source configuration</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The following wil list all the properties and their descriptions (datasources hava lots of properties, so I'll paste only an exerpt here)</p><pre class="jive-pre"><code class="jive-code">
[standalone@localhost:9999 /] data-source --help --properties

 connection-url&#160;&#160;&#160;&#160;&#160;&#160;&#160; - (required) The JDBC driver connection URL

 driver-class&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; - (required) The fully qualifed name of the JDBC driver class

 jndi-name&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; - (required) Specifies the JNDI name for the datasource

 new-connection-sql - (optional) Specifies an SQL statement to execute whenever a connection is added to the connection pool.</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>And this is how to list the operations that can be invoked on an instance of the type (btw, this list excludes some operations like </p><p>read-attribute, read-children-names, read-children-resources, read-children-types, read-operation-description, read-operation-names, read-resource, read-resource-description, validate-address, write-attribute)</p><pre class="jive-pre"><code class="jive-code">
[standalone@localhost:9999 /] data-source --help --commands
add
disable
enable
flush-all-connection-in-pool
flush-idle-connection-in-pool
remove
test-connection-in-pool
To read the description of a specific command execute 'data-source command_name --help'.</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Here is an example of add operation description (again, it accepts a lot of properties, most of which are optional, so I paste only an exerpt of the complete description here)</p><pre class="jive-pre"><code class="jive-code">
[standalone@localhost:9999 /] data-source add --help 
Operation description:

&#160;&#160;&#160; Adds a new data-source

Properties:

 --connection-url&#160;&#160;&#160;&#160;&#160; - (STRING,required) The JDBC driver connection URL

 --driver-class&#160;&#160;&#160;&#160;&#160;&#160;&#160; - (STRING,required) The fully qualifed name of the JDBC driver class

 --jndi-name&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; - (STRING,required) Specifies the JNDI name for the datasource

 --driver-name&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; - (STRING,required) Defines the JDBC driver the datasource should use. It is a symbolic name matching the the name of installed driver. In case the driver is deployed as jar, the name is the name of deployment unit

 --new-connection-sql&#160; - (STRING,optional) Specifies an SQL statement to execute whenever a connection is added to the connection pool.</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h3>Managing commands</h3><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Generic type commands can be added and removed at runtime. There is a command called 'command' which can add new, list and remove existing generic type commands (but not other commands). For example</p><pre class="jive-pre"><code class="jive-code">
[standalone@localhost:9999 /] command list
data-source</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>To add a new command, you need to identify the node type, choose the identifying property and the name for the command. E.g.</p><pre class="jive-pre"><code class="jive-code">
[standalone@localhost:9999 /] command add --node-type=subsystem=resource-adapters/resource-adapter --property-id=archive --command-name=resource-adapter
[standalone@localhost:9999 /] command list
data-source&#160;&#160;&#160;&#160;&#160;&#160;&#160; resource-adapter</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Now there is resource-adapter command which can be used as any other CLI command, e.g.</p><pre class="jive-pre"><code class="jive-code">
[standalone@localhost:9999 /] resource-adapter --help --commands
add
flush-all-connection-in-pool
flush-idle-connection-in-pool
remove
test-connection-in-pool
To read the description of a specific command execute 'resource-adapter command_name --help'.</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The command can be remove like this</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code">
[standalone@localhost:9999 /] command remove --command-name=resource-adapter
[standalone@localhost:9999 /] command list&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 
data-source</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>NOTE: chnages made to generic type commands don't survive CLI restart yet.</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Comment by <a href="http://community.jboss.org/docs/DOC-16981">going to Community</a></p>

        <p style="margin: 0;">Create a new document in JBoss AS7 Development at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=102&containerType=14&container=2225">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>