library/roles/tomcat-multiple-instances/templates/tomcat-context.xml.j2: Support more than one db target in the jndi configuration.

This commit is contained in:
Andrea Dell'Amico 2018-02-27 16:52:33 +01:00
parent f8cbd7ad17
commit 09c9c0bcdb
1 changed files with 26 additions and 1 deletions

View File

@ -32,6 +32,29 @@
<Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
-->
{% if tomcat_m_jndi_pool %}
{% if tomcat_jndi_pool_databases is defined %}
{% for pool in tomcat_jndi_pool_databases %}
<Resource name="{{ pool. jndi_resource_name | default('jdbc/postgres') }}"
auth="Container"
type="{{ pool.jndi_resource_type | default('javax.sql.DataSource') }}"
driverClassName="{{ pool.jndi_class_name | default('org.postgresql.Driver') }}"
url="jdbc:postgresql://{{ pool. jndi_db_host }}:{{ pool.jndi_db_port | default (5432) }}/{{ pool.jndi_db_name }}"
username="{{ pool.jndi_db_user }}" password="{{ pool.jndi_db_pwd }}"
maxActive="20"
initialSize="0"
minIdle="0"
maxIdle="8"
maxWait="10000"
timeBetweenEvictionRunsMillis="30000"
minEvictableIdleTimeMillis="60000"
testWhileIdle="true"
validationQuery="SELECT 1"
maxAge="600000"
rollbackOnReturn="true"
/>
{% endfor %}
{% else %}
<Resource name="jdbc/postgres"
auth="Container"
type="javax.sql.DataSource"
@ -49,6 +72,8 @@
validationQuery="SELECT 1"
maxAge="600000"
rollbackOnReturn="true"
{% endif %}
/>
{% endif %}
{% endif %}
</Context>