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

  • ThreadLocalTargetSource

    Hello.

    I'm trying to use the ThreadLocalTargetSource but I'm having some problems.

    My beans definitions:

    <bean id="businessEngineContext" class="org.springframework.aop.framework.ProxyFact oryBean">
    <property name="targetSource" ref="threadLocalBusinessEnginecontext"/>
    <property name="proxyInterfaces">
    <list>
    <value>br.tabajara.dunha.foundation.context.Busine ssEngineContext</value>
    </list>
    </property>
    </bean>

    <bean id="threadLocalBusinessEnginecontext" class="org.springframework.aop.target.ThreadLocalT argetSource" singleton="false">
    <property name="targetBeanName"> <idref local="businessEngineContextTarget"/> </property>
    </bean>

    <bean id="businessEngineContextTarget" singleton="false" class="br.tabajara.dunha.foundation.context.Busine ssEngineContextImpl"/>


    Whe I try to get an instance of businessEngineContext, I get:
    org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy0] to required type [pt.ptinovacao.be.foundation.context.BusinessEngine ContextImpl] for property 'context'

    What is wrong with my definition?

    Thanks

  • #2
    Sounds like the old problem of JDK dynamic proxies vs. CGLib class proxies. Personally I'd prefer dynamic proxies, which implement the interfaces (and so you can't convert BusinessEngineContextImpl, but only to BusinessEngineContext). You'll get CGLib proxies by specifying the property "proxyTargetClass" on the ProxyFactoryBean and set it to true.

    Jörg

    Comment

    Working...
    X