Skip to content

Instantly share code, notes, and snippets.

@rwngwn
Created July 7, 2015 13:45
Show Gist options
  • Save rwngwn/cc2834a2ac4384fdcd4a to your computer and use it in GitHub Desktop.
Save rwngwn/cc2834a2ac4384fdcd4a to your computer and use it in GitHub Desktop.
function generate_tx_datasource() {
ds=" <datasource jta=\"false\" jndi-name=\"${2}ObjectStore\" pool-name=\"${1}ObjectStorePool\" enabled=\"true\">
<connection-url>jdbc:${8}://${5}:${6}/${7}</connection-url>
<driver>${8}</driver>"
if [ -n "$tx_isolation" ]; then
ds="$ds
<transaction-isolation>$tx_isolation</transaction-isolation>"
fi
if [ -n "$min_pool_size" ] || [ -n "$max_pool_size" ]; then
ds="$ds
<pool>"
if [ -n "$min_pool_size" ]; then
ds="$ds
<min-pool-size>$min_pool_size</min-pool-size>"
fi
if [ -n "$max_pool_size" ]; then
ds="$ds
<max-pool-size>$max_pool_size</max-pool-size>"
fi
ds="$ds
</pool>"
fi
ds="$ds
<security>
<user-name>${3}</user-name>
<password>${4}</password>
</security>
</datasource>"
echo $ds | sed ':a;N;$!ba;s|\n|\\n|g'
}
def _create_tx_datasource(self, name, jndi_name, driver, username, password, host, port, database, tx_isolation=None, max_pool_size=None, min_pool_size=None):
command = "data-source add "
command += "--name=%s " %name
command += "--jndi-name=%s " %jndi_name
command += "--driver-name=%s " %driver
command += "--user-name=%s " %username
command += "--password=%s " %password
command += "--connection-url jdbc:%s://%s:%s/%s" %(driver, host, port, database )
if tx_isolation:
command += "--transaction-isolation=%s " %tx_isolation
if max_pool_size:
command += "--max-pool-size " %max_pool_size
if min_pool_size:
command += "--min-pool-size %s" %min_pool_size
self._run_jboss_cli(command)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment