Tuesday, September 19, 2017

Dependency Injection in Spring

Below example shows how one bean is depended on other beans.


      
<bean id="fawryadslBillTxn"
           class="com.btsl.reports.action.FawryADSLBillReportAction"
           scope="session">
           <property name="partyDAO" ref="partyDAO" />
           <property name="domainDaoI" ref="domainDAO" />
           <property name="commonDAO" ref="commonDAO" />
      </bean>


-----------------------------------------------------------------------------

<bean id="partyDAO" class="com.btsl.party.dao.hibernate.
PartyDAO">
            <property name="sessionFactory" ref="sessionFactory1" />
      </bean>

-----------------------------------------------------------------------------

<bean id="sessionFactory1" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
   <property name="dataSource">
      <ref local="dataSource1" />
   </property>
   <property name="mappingResources">
      <list>
         <value>com/btsl/common/model/entities.xml</value>
         <value>com/btsl/FT/party/model/entities.xml</value>
         <value>com/btsl/party/model/party.hbm.xml</value>
         <value>com/btsl/mmoney/model/entities.xml</value>
         <value>com/btsl/transaction/transaction.hbm.xml</value>
         <value>com/btsl/payment/model/payment.hbm.xml</value>
         <value>com/btsl/party/model/servicecharge.hbm.xml</value>
         <value>com/btsl/kpi/model/kpi.hbm.xml</value>
         <value>application/hibernate/billpayQueries.xml</value>
         <value>com/btsl/party/servicechargeprofile.hbm.xml</value>
         <value>com/btsl/payroll/model/payroll.hbm.xml</value>
         <value>com/btsl/party/model/SentSmsDTO.hbm.xml</value>
      </list>
   </property>
   <property name="hibernateProperties">
      <props>
         <prop   key="hibernate.dialect">
                  org.hibernate.dialect.Oracle9Dialect</prop>
         <prop key="show_sql">true</prop>
         <prop key="hibernate.cache.provider_class">
                   net.sf.ehcache.hibernate.EhCacheProvider</prop>
         <prop key="hibernate.connection.provider_class">
                    org.hibernate.C3P0ConnectionProvider</prop>
         <prop key="hibernate.auto_close_session">true</prop>
         <prop key="hibernate.transaction.flush_before_completion">
                    true</prop>
      </props>
   </property>
</bean>


---------------------------------------------------------------------------

<bean id="dataSource1" class="com.btsl.common.SecureDataSource" destroy-method="close">
   <property name="driverClass">
      <value>oracle.jdbc.driver.OracleDriver</value>
   </property>
   <property name="jdbcUrl">
      <value>jdbc:oracle:thin:@172.16.7.236:20300:prtp</value>
   </property>
   <property name="user">
      <value>MOBINIL_INTEROPERABILITY</value>
   </property>
   <property name="password">
      <value>6aa91ac81b3b1e763a0048a7b4880fe134dc7</value>
   </property>
   <property name="initialPoolSize">
      <value>15</value>
   </property>
   <property name="minPoolSize">
      <value>15</value>
   </property>
   <property name="maxPoolSize">
      <value>300</value>
   </property>
   <property name="maxIdleTime">
      <value>60</value>
   </property>
   <property name="idleConnectionTestPeriod">
      <value>30</value>
   </property>
   <property name="acquireIncrement">
      <value>1</value>
   </property>
   <property name="unreturnedConnectionTimeout">
      <value>300</value>
   </property>
</bean>

No comments:

Post a Comment