Announcement Announcement Module
Collapse
No announcement yet.
How to inject service into another Service? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to inject service into another Service?

    Hi,
    I have few Services defined in the context file for example

    <bean id="RevenueOptimizationServiceTarget" class="com.uprr.app.itr.springs.services.revenueop timization.RevenueOptimizationServiceImpl">

    <bean id="revenueOptimizationService" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
    <property name="transactionManager" ref="txManager"/>
    <property name="target" ref="RevenueOptimizationServiceTarget"/>
    <property name="transactionAttributeSource" ref="noTxAttributeSource" />
    </bean>


    If I want to inject another service into this.
    Is it a right way. if so how can i do this.

  • #2
    Doesn't the RevenueOptimizationServiceImpl have fields you can use? Or am I missing something?

    Code:
    <bean id="RevenueOptimizationServiceTarget" class="com.uprr.app.itr.springs.services.revenueop timization.RevenueOptimizationServiceImpl">
    
    <bean id="revenueOptimizationService" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
    <property name="transactionManager" ref="txManager"/>
    <property name="target" ref="RevenueOptimizationServiceTarget"/>
    <property name="transactionAttributeSource" ref="noTxAttributeSource" />
    </bean>
    
    <property name="theService" ref="theService" />
    </bean>

    Comment

    Working...
    X