Announcement Announcement Module
Collapse
No announcement yet.
BeanNameAutoProxyCreator and ProxyFactoryBean don't work on same target Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • BeanNameAutoProxyCreator and ProxyFactoryBean don't work on same target

    I have a large group of beans which I run through a couple BeanNameAutoProxyCreator for various things including logging and Transaction management. If I try to then create a ProxyFactoryBean using this same bean as the target I get an error.

    So for instance i will follow my patientChartMgr bean through this problem.
    Code:
    <bean id="patientChartMgr" class="com.mbs.model.service.implementations.clinical.PatientChartMGR">
            <property name="patientChartDao">
                <ref bean="patientChartDao"/>
            </property>
            <property name="securityDao">
                <ref local="securityDao"/>
            </property>
        </bean>
    Here is my config for a transaction auto proxy which works great:
    Code:
    <bean id="serviceTransactionAutoProxy" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
            <property name="interceptorNames">
                <value>serviceTransactionInterceptor</value>
            </property>
            <property name="beanNames">
                <list>
                    <value>securityMgr</value>
                    <value>patientChartMgr</value>
                    <value>priceScheduleMgr</value>
                    <value>authorizationMgr</value>
    etc
                </list>
            </property>
        </bean>
    Then i have these application event handlers that i build in declaritively on a bean by bean basis. This one is applied to the patientChartMgr:

    Code:
    <bean id="patientChartMgrTreatmentCourseApplicationEventFirer" class="org.springframework.aop.support.DefaultPointcutAdvisor">
            <property name="pointcut">
                <bean class="org.springframework.aop.support.JdkRegexpMethodPointcut">
                    <property name="patterns">
                        <list>
    <value>.*(save|update|create|delete|process|generate|assign)TreatmentCourse.*</value>
                        </list>
                    </property>
                </bean>
            </property>
            <property name="advice">
                <bean class="com.mbs.util.event.applicationevent.ApplicationMethodInterceptorEventFirer">
                    <property name="applicationEventService">
                        <ref bean="applicationEventMgr"></ref>
                    </property>
                    <property name="eventNamesToFire">
                        <list>
                            <value>TREATMENT_COURSE_DATA_CHANGED</value>
                        </list>
                    </property>
                </bean>
            </property>
        </bean>
    
        <bean id="patientChartMgrEventCatcher" class="org.springframework.aop.framework.ProxyFactoryBean">
            <property name="interceptorNames">
                <list>
                    <value>patientChartMgrTreatmentCourseApplicationEventFirer</value>
                </list>
            </property>
            <property name="proxyTargetClass">
                <value>true</value>
            </property>
            <property name="target">
                <ref bean="patientChartMgr"/>
            </property>
            <property name="proxyInterfaces">
                <value>com.mbs.model.service.interfaces.clinical.PatientChartMgr</value>
            </property>
        </bean>
    When I start the app like this it gives me this error:
    Code:
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'patientChartMgrEventCatcher' defined in file [/home/ryan/documents/work/mbs/cvs/MBS/conf/server/ServerApplicationEvents_SpringCtx.xml]: Initialization of bean failed; nested exception is org.aopalliance.aop.AspectException: null
    If i change the ProxyFactoryBean declartion to be a BeanNameAutoProxyCreator, see below, it works. Can anyone Explain that?

    Code:
        <bean id="patientChartMgrEventCatcher" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
            <property name="interceptorNames">
                <list>
                    <value>patientChartMgrTreatmentCourseApplicationEventFirer</value>
                </list>
            </property>
            <property name="beanNames">
                <list>
                    <value>patientChartMgr</value>
                </list>
            </property>
        </bean>

  • #2
    Hello,
    did you already solved your problem? when you did - who does is work? :-)

    greetings
    martin

    Comment

    Working...
    X