Announcement Announcement Module
Collapse
No announcement yet.
SpringEJB with SpringDAO Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SpringEJB with SpringDAO

    Hi All,

    I'm new to the Forum and to the World OF Spring Also. Currently I'm exploring the best suitable DataAccess needed to support my business.So for that I need to know about the transaction management in Spring..After I explored I came to know that there are some points like
    1) usage of Transaction manager (preferably JtaTransactionManager)
    2) use either CMT or BMT for Your Support..I came to know that my Appserver which is weblogic supports both CMT and BMT in corrdination with the Spring Transaction.

    I have seen a Sample Spring Project in which it shows the Spring Bean with the SpringDAO. I have not seen any Sample Implementation of springEJB + SpringDAO..

    So I have to know two things..\
    1) Context.xml which shows all the Stuff like Service, JNDI Template,DataSource,etc.,
    2) beans.xml which will be in my business folder shows the Service and itz implementation Class needa to be Invoked..and also Shows the list of DAOImpl
    which needs to be invoked..

    I'm placing the Code over here..
    Context.xml

    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

    <beans>
    <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate" >
    <property name="dataSource" ref="dataSource"></property>
    <property name="nativeJdbcExtractor" ref="simpleNativeJdbcExtractor"/>
    </bean>

    <bean id="simpleNativeJdbcExtractor" class="org.springframework.jdbc.support.nativejdbc .SimpleNativeJdbcExtractor">
    <property name="nativeConnectionNecessaryForNativeCallableSt atements" value="true"/>
    </bean>

    <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryB ean">
    <property name="jndiName">
    <value>com.ftindia.dbConnection</value>
    </property>
    <property name="resourceRef">
    <value>true</value>
    </property>
    </bean>

    <bean id="jndiTemplate"
    class="org.springframework.jndi.JndiTemplate" >
    <property name="jndiEnvironment">
    <props>
    <prop key = "java.naming.factory.initial">weblogic.jndi.WLInit ialContextFactory</prop>
    <prop key = "java.naming.provider.url">t3://localhost:7001</prop>
    <prop key = "java.naming.factory.url.pkgs">weblogic.jndi.facto ries:weblogic.corba.j2ee.naming.url</prop>
    </props>
    </property>
    </bean>

    <bean id="txProxyTemplate" abstract="true" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
    <property name="transactionManager">
    <ref bean="transactionManager"/>
    </property>
    <property name="transactionAttributes">
    <props>
    <prop key="add*">PROPAGATION_REQUIRED</prop>
    <prop key="mod*">PROPAGATION_REQUIRED</prop>
    <prop key="del*">PROPAGATION_REQUIRED</prop>
    <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
    </props>
    </property>
    </bean>

    <!-- Spring's transaction manager delegates to
    WebLogic Server's transaction manager -->
    <bean id="transactionManager"
    class="org.springframework.transaction.jta.Weblogi cJtaTransactionManager">
    </bean>

    <bean id="redemptionService"
    class="org.springframework.ejb.access.SimpleRemote StatelessSessionProxyFactoryBean">

    <property name="jndiName" value="RedemptionWork1" />
    <property name="jndiTemplate" ref="jndiTemplate"/>
    <property name="businessInterface" value="com.ftindia.redemption.interfaces.Redemptio nManager" ref="redemptionManager"/>
    <property name="redemRegDAOImpl" ref="RedemRegDAOImpl"></property>
    </bean>

    <bean id="redemptionManager" parent="txProxyTemplate">
    <property name="target">
    <bean id="RedmptionManagerImpl" class="com.ftindia.redemption.interfaces.impl.Redm ptionManagerImpl">
    </bean>
    </property>
    </bean>

    </beans>


    CODE for beans.xml :


    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
    <beans>
    <bean id="redemptionService" class="com.ftindia.redemption.interfaces.impl.Redm ptionManagerImpl">
    <property name="redemRegDAOImpl" ref="RedemRegDAOImpl"></property>
    </bean>

    <bean id="RedemRegDAOImpl" class="com.ftindia.redemption.dao.impl.RedemRegDAO Impl">
    <property name="dataSource" ref="dataSource"/>
    </bean>
    </beans>


    __________________________________________________ _____________

    Kindly Suggest me the best Configuration need to be involved here..

    Chandru..
Working...
X