2 Replies Latest reply on Oct 8, 2010 5:35 PM by Stuart Douglas

    Constructor Injection in SEAM XML Configuration

    Franck Garcia Newbie

      I'm using SEAM XML extension in a WELD SE project in order to declare and configure 3rd party classes.
      I don't know how to proceed with constructor injection:




      <beans xmlns="http://java.sun.com/xml/ns/javaee" 
           xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://jboss.org/schema/cdi/beans_1_0.xsd" 
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:s="urn:java:seam:core" 
          xmlns:dbcp="urn:java:org.apache.commons.dbcp"
          xmlns:dbutils="urn:java:org.apache.commons.dbutils"
          >
      
           <dbcp:BasicDataSource>
               <dbcp:driverClassName>
                   <s:value>com.ibm.as400.access.AS400JDBCDriver</s:value>
               </dbcp:driverClassName>
               <dbcp:url>
                   <s:value>jdbc:as400://mysys;naming=system;data truncation=false</s:value>
               </dbcp:url>
               <dbcp:username>
                   <s:value>myuser</s:value>
               </dbcp:username>
               <dbcp:password>
                   <s:value>xxxxx</s:value>
               </dbcp:password>
           </dbcp:BasicDataSource>
           
           <dbutils:QueryRunner> <!-- constructor Injection?? how -->
                <s:Inject/>
              </dbutils:QueryRunner>
      
      </beans>



      QueryRunner is taking a DataSource in one version of its constructors...
      I tried injecting into the private field but this one is private so I can't.
      My only option is to use the constructor, In the doc but I only find explanation on field and methods not on constructor, any help of course is appreciated.
      thx



        • 1. Re: Constructor Injection in SEAM XML Configuration
          Franck Garcia Newbie

          ....for the record, I found it!




          <beans xmlns="http://java.sun.com/xml/ns/javaee" 
               xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://jboss.org/schema/cdi/beans_1_0.xsd" 
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xmlns:s="urn:java:seam:core" 
              xmlns:dbcp="urn:java:org.apache.commons.dbcp"
              xmlns:dbutils="urn:java:org.apache.commons.dbutils"
              xmlns:ds="urn:java:javax.sql"
              >
          
               <dbcp:BasicDataSource>
                   <dbcp:driverClassName>
                       <s:value>com.ibm.as400.access.AS400JDBCDriver</s:value>
                   </dbcp:driverClassName>
                   <dbcp:url>
                       <s:value>jdbc:as400://dev_caas400.planet.ftn.fedex.com;naming=system;data truncation=false</s:value>
                   </dbcp:url>
                   <dbcp:username>
                       <s:value>jboss</s:value>
                   </dbcp:username>
                   <dbcp:password>
                       <s:value>jboss</s:value>
                   </dbcp:password>
               </dbcp:BasicDataSource>
          
               <dbutils:QueryRunner>
                    <s:parameters>
                         <ds:DataSource>
                              <s:Inject/>
                         </ds:DataSource>
                    </s:parameters>
               </dbutils:QueryRunner>
          </beans>



          • 2. Re: Constructor Injection in SEAM XML Configuration
            Stuart Douglas Master

            Sorry, that was an oversight in the docs, I will fix it up.