Announcement Announcement Module
Collapse
No announcement yet.
want to use multipal Transactionproxyfactory Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • want to use multipal Transactionproxyfactory

    hi,
    will this work. if not then why.

    <bean id="txProxy" lazy-init="true"
    class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
    <property name="transactionManager"><ref bean="transactionManager"/></property>
    <property name="transactionAttributes">
    <props>
    <prop key="*">PROPAGATION_REQUIRED</prop>
    </props>
    </property>
    </bean>

    <bean id="storeServices" parent="txProxy">
    <property name="target">
    <ref bean="storeProductDao"/>
    </property>
    </bean>

    <bean id="store1Services" parent="txProxy">
    <property name="target">
    <ref bean="storeProductDao1"/>
    </property>
    </bean>

    actually i am try to create tow different business service.
    i am using struts,spring and hibernate. i am getting this bean in my struts application code using the following code.

    WebApplicationContext waContext = WebApplicationContextUtils.getRequiredWebApplicati onContext(servletContext);
    return (BusinessServices) waContext.getBean("storeServices");


    is there any other way to solve this problem.

    thanks & regards
    Ajay

  • #2
    You'll need to add abstract="true" to your txProxy bean definition. Also your target for your service proxy beans should be a service bean with references to your Daos.

    Something like this:
    Code:
    <bean abstract="true" id="txProxy"  lazy-init="true"
    class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
        <property name="transactionManager"><ref bean="transactionManager"/></property>
        <property name="transactionAttributes">
            <props>
                <prop key="*">PROPAGATION_REQUIRED</prop>
            </props>
        </property>
    </bean>
    
    <bean id="storeServicesTarget" class="xxxxxxxxxxxx">
        <property name="storeProductDao"><ref bean="storeProductDao"></property>
    </bean>
    
    <bean id="storeServices" parent="txProxy">
       <property name="target">
            <ref bean="storeServicesTarget"/>
        </property>
    </bean>
    
    &#91;repeat same process for store1Services&#93;
    Hopefully I didn't forget anything.

    Comment

    Working...
    X