2016-02-03 10:20:22 +00:00
|
|
|
<!--
|
|
|
|
~ Copyright 2016 Red Hat, Inc. and/or its affiliates
|
|
|
|
~ and other contributors as indicated by the @author tags.
|
|
|
|
~
|
|
|
|
~ Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
~ you may not use this file except in compliance with the License.
|
|
|
|
~ You may obtain a copy of the License at
|
|
|
|
~
|
|
|
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
~
|
|
|
|
~ Unless required by applicable law or agreed to in writing, software
|
|
|
|
~ distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
~ See the License for the specific language governing permissions and
|
|
|
|
~ limitations under the License.
|
|
|
|
-->
|
|
|
|
|
2015-09-18 12:27:28 +00:00
|
|
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
|
|
|
xmlns:xalan="http://xml.apache.org/xalan"
|
|
|
|
version="2.0"
|
2016-09-02 11:55:49 +00:00
|
|
|
exclude-result-prefixes="xalan">
|
2015-09-18 12:27:28 +00:00
|
|
|
|
|
|
|
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" xalan:indent-amount="4" standalone="no"/>
|
|
|
|
<xsl:strip-space elements="*"/>
|
|
|
|
|
|
|
|
|
|
|
|
<xsl:variable name="nsDS" select="'urn:jboss:domain:datasources:'"/>
|
|
|
|
|
|
|
|
<!-- Remove keycloak datasource definition. -->
|
|
|
|
<xsl:template match="//*[local-name()='subsystem' and starts-with(namespace-uri(), $nsDS)]
|
|
|
|
/*[local-name()='datasources' and starts-with(namespace-uri(), $nsDS)]
|
2016-10-18 10:12:41 +00:00
|
|
|
/*[local-name()='datasource' and starts-with(namespace-uri(), $nsDS) and @pool-name='KeycloakDS']">
|
2015-09-18 12:27:28 +00:00
|
|
|
</xsl:template>
|
|
|
|
|
2016-09-27 10:22:27 +00:00
|
|
|
<xsl:param name="db.jdbc_url"/>
|
|
|
|
<xsl:param name="driver"/>
|
2016-10-18 10:12:41 +00:00
|
|
|
|
|
|
|
<xsl:param name="min.poolsize" select="'10'"/>
|
|
|
|
<xsl:param name="max.poolsize" select="'50'"/>
|
|
|
|
<xsl:param name="pool.prefill" select="'true'"/>
|
2015-09-18 12:27:28 +00:00
|
|
|
|
2016-09-27 10:22:27 +00:00
|
|
|
<xsl:param name="username"/>
|
|
|
|
<xsl:param name="password"/>
|
2015-09-18 12:27:28 +00:00
|
|
|
|
|
|
|
<xsl:variable name="newDatasourceDefinition">
|
2016-10-18 10:12:41 +00:00
|
|
|
<datasource jndi-name="java:jboss/datasources/KeycloakDS" pool-name="KeycloakDS" use-java-context="true">
|
|
|
|
<connection-url>
|
|
|
|
<xsl:value-of select="$db.jdbc_url"/>
|
|
|
|
</connection-url>
|
2015-09-18 12:27:28 +00:00
|
|
|
<driver>
|
|
|
|
<xsl:value-of select="$driver"/>
|
|
|
|
</driver>
|
|
|
|
<security>
|
|
|
|
<user-name>
|
|
|
|
<xsl:value-of select="$username"/>
|
|
|
|
</user-name>
|
|
|
|
<password>
|
|
|
|
<xsl:value-of select="$password"/>
|
|
|
|
</password>
|
|
|
|
</security>
|
2016-10-18 10:12:41 +00:00
|
|
|
<pool>
|
|
|
|
<min-pool-size>
|
|
|
|
<xsl:value-of select="$min.poolsize"/>
|
|
|
|
</min-pool-size>
|
|
|
|
<max-pool-size>
|
|
|
|
<xsl:value-of select="$max.poolsize"/>
|
|
|
|
</max-pool-size>
|
|
|
|
<prefill>
|
|
|
|
<xsl:value-of select="$pool.prefill"/>
|
|
|
|
</prefill>
|
|
|
|
</pool>
|
|
|
|
</datasource>
|
2015-09-18 12:27:28 +00:00
|
|
|
</xsl:variable>
|
|
|
|
|
|
|
|
<xsl:variable name="newDriverDefinition">
|
|
|
|
<xsl:if test="$driver != 'h2'">
|
2016-10-18 10:12:41 +00:00
|
|
|
<driver name="{$driver}" module="com.{$driver}" />
|
2015-09-18 12:27:28 +00:00
|
|
|
</xsl:if>
|
|
|
|
</xsl:variable>
|
|
|
|
|
|
|
|
<!-- Add new datasource definition. -->
|
|
|
|
<xsl:template match="//*[local-name()='subsystem' and starts-with(namespace-uri(), $nsDS)]
|
|
|
|
/*[local-name()='datasources' and starts-with(namespace-uri(), $nsDS)]">
|
|
|
|
<xsl:copy>
|
|
|
|
<xsl:copy-of select="$newDatasourceDefinition"/>
|
|
|
|
<xsl:apply-templates select="@* | node()" />
|
|
|
|
</xsl:copy>
|
|
|
|
</xsl:template>
|
|
|
|
|
|
|
|
<!-- Add new driver definition. -->
|
|
|
|
<xsl:template match="//*[local-name()='subsystem' and starts-with(namespace-uri(), $nsDS)]
|
|
|
|
/*[local-name()='datasources' and starts-with(namespace-uri(), $nsDS)]
|
|
|
|
/*[local-name()='drivers' and starts-with(namespace-uri(), $nsDS)]">
|
|
|
|
<xsl:copy>
|
|
|
|
<xsl:copy-of select="$newDriverDefinition"/>
|
|
|
|
<xsl:apply-templates select="@* | node()" />
|
|
|
|
</xsl:copy>
|
|
|
|
</xsl:template>
|
|
|
|
|
|
|
|
<!-- Copy everything else. -->
|
|
|
|
<xsl:template match="@*|node()">
|
|
|
|
<xsl:copy>
|
|
|
|
<xsl:apply-templates select="@*|node()" />
|
|
|
|
</xsl:copy>
|
|
|
|
</xsl:template>
|
|
|
|
|
|
|
|
</xsl:stylesheet>
|