PageRenderTime 54ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 0ms

/jboss-as-7.1.1.Final/testsuite/integration/src/test/xslt/changeDatabase.xsl

#
Extensible Stylesheet Language Transformations | 94 lines | 82 code | 12 blank | 0 comment | 0 complexity | b31aba32615438785ec4924b252f8e87 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- See http://www.w3.org/TR/xslt -->
  3. <!--
  4. An XSLT style sheet which will change the existing datasource definition to the desired database.
  5. This is done by changing:
  6. <server>
  7. ...
  8. <profile>
  9. ...
  10. <subsystem xmlns="urn:jboss:domain:datasources:1.0">
  11. <datasource jndi-name="java:jboss/datasources/ExampleDS enabled="true" use-java-context="true" pool-name="H2DS"/>
  12. <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url>
  13. <driver>h2</driver>
  14. <pool></pool>
  15. <security>
  16. <user-name>sa</user-name>
  17. <passsword>sa</password>
  18. </datasource>
  19. <drivers>
  20. <driver name="h2" module="com.h2database.h2">
  21. <xa-datasource-class>org.h2.jdcx.JdbcDataSource</xa-datasource-class>
  22. </driver>
  23. </drivers>
  24. </subsystem>
  25. ...
  26. </profile>
  27. ...
  28. </server>
  29. to the following, in which the existing datasource definition is completely removed and replaced by the
  30. new datasource definition (where the driver is deployed into standalone/deployments and not loaded as a
  31. module):
  32. <server>
  33. ...
  34. <profile>
  35. ...
  36. <subsystem xmlns="urn:jboss:domain:datasources:1.0">
  37. <datasource jndi-name="java:jboss/datasources/ExampleDS enabled="true" use-java-context="true" pool-name="H2DS"/>
  38. <connection-url>${ds.jdbc.url}</connection-url>
  39. <driver>${ds.jdbc.driver}</driver>
  40. <pool></pool>
  41. <security>
  42. <user-name>${ds.jdbc.user}</user-name>
  43. <passsword>${ds.jdbc.pass}</password>
  44. </datasource>
  45. </subsystem>
  46. ...
  47. </profile>
  48. ...
  49. </server>
  50. -->
  51. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  52. xmlns:ds="urn:jboss:domain:datasources:1.0">
  53. <xsl:output method="xml" indent="yes"/>
  54. <xsl:param name="ds.jdbc.driver.jar" select="'fred'"/>
  55. <xsl:param name="ds.jdbc.url" select="'wilma'"/>
  56. <xsl:param name="ds.jdbc.user" select="'test'"/>
  57. <xsl:param name="ds.jdbc.pass" select="'test'"/>
  58. <xsl:variable name="newDatasourceDefinition">
  59. <ds:datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExamplePool" enabled="true" jta="true"
  60. use-java-context="true">
  61. <ds:connection-url><xsl:value-of select="$ds.jdbc.url"/></ds:connection-url>
  62. <ds:driver><xsl:value-of select="$ds.jdbc.driver.jar"/></ds:driver>
  63. <ds:security>
  64. <ds:user-name><xsl:value-of select="$ds.jdbc.user"/></ds:user-name>
  65. <ds:password><xsl:value-of select="$ds.jdbc.pass"/></ds:password>
  66. </ds:security>
  67. </ds:datasource>
  68. </xsl:variable>
  69. <!-- Replace the old datasource with the new. -->
  70. <xsl:template match="//ds:subsystem/ds:datasources/ds:datasource[@jndi-name='java:jboss/datasources/ExampleDS']">
  71. <!-- http://docs.jboss.org/ironjacamar/userguide/1.0/en-US/html/deployment.html#deployingds_descriptor -->
  72. <xsl:copy-of select="$newDatasourceDefinition"/>
  73. </xsl:template>
  74. <!-- Get rid of the default driver defs. -->
  75. <xsl:template match="//ds:subsystem/ds:datasources/ds:drivers"/>
  76. <!-- Copy everything else. -->
  77. <xsl:template match="@*|node()">
  78. <xsl:copy>
  79. <xsl:apply-templates select="@*|node()"/>
  80. </xsl:copy>
  81. </xsl:template>
  82. </xsl:stylesheet>