1 Reply Latest reply on Feb 21, 2008 3:05 PM by peterj

    how to add custom properties to xml?

    shawnsmsu

      We're currently using a standard configuration file to allow users to choose their datasource and whatnot when running JBoss 4.0.5. Obviously, the properties in this file get passed into the web application but I cannot find how.

      I'd like to add a custom property to the xml file that will be accessible by the web app at runtime. Can someone please explain what I need to do to add a tag and read it in on the application side?

      Here's our standard config xml:

      <?xml version="1.0" encoding="UTF-8"?>
      <datasources>
       <!-- Microsoft SQL Server 2000 Database configuration -->
       <local-tx-datasource>
       <jndi-name>jdbc/LEDataSource</jndi-name>
       <connection-url>jdbc:jtds:sqlserver://localhost:1433/test;prepareSQL=1</connection-url>
       <driver-class>net.sourceforge.jtds.jdbc.Driver</driver-class>
       <user-name>user</user-name>
       <password>password</password>
      
       <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
      
       <min-pool-size>4</min-pool-size>
       <max-pool-size>20</max-pool-size>
       <idle-timeout-minutes>30</idle-timeout-minutes>
       </local-tx-datasource>
      </datasources>
      


      I would like to add one property that the web app could read:

       <support-email>a@b.com</support-email>
      


      Thanks!

        • 1. Re: how to add custom properties to xml?
          peterj

          The *-ds.xml file is used as a template to generate several (3-6, if I recall correctly) MBeans. Once the MBeans are generated, the *-ds.xml file is ignored. Apps get at the data source by looking up the name (jdbc/LEDataSource in your example) in JNDI which yields one of the MBeans.

          For web app properties, those are usually best placed into a properties file accessible by the web app (for example, located in WEB-INF/classes), or you could use the properties service - see the properties-service.xml file.