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

  • ProxyFactoryBean doesnt intercept calls.

    hi everybody, i`m building a demo which integrates myfaces, spring 2.0.6 and tiles, i want to spring manages the bean proxy between the view and the controller, also, I need that the invocations to the methods of the service are intercepted by the ProxyFactoryBean, I have tried this configuration in the applicationContext:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
    "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
    <beans>
    <!-- Bean that takes charge of parsing xml and storing in an object -->
    <bean id="ParserSAX" class="es.yell.frontlite.parser.ParserPrincipalHan dler"/>

    <!-- Bean that takes charge forming the url. It can be singleton-->
    <bean id="Controller" class="es.yell.frontlite.servlets.Controller"/>
    <!-- Bean that takes charge managing the requests POST that the clients do.
    It has injected the service that provides the functionality to access to the backend
    .-->
    <bean id="yellProxy" class="es.yell.frontlite.servlets.YellProxy">
    <property name="servicio">
    <ref bean="srvBusquedaNoxtrumServiceTarget"/>
    </property>
    </bean>
    <!-- Service Implementation. -->
    <bean id="srvBusquedaNoxtrumServiceTarget" class="es.yell.frontlite.service.impl.SrvBusquedaN oxtrumServiceImpl">
    <property name="parserSAX"><ref bean="ParserSAX"/></property>
    <property name="controlador"><ref bean="Controller"/></property>
    </bean>

    <!--advices definition -->
    <bean id="eventoBeforeAdvice" class="es.yell.frontlite.spring.EventoBeforeAdvice "/>

    <bean id="eventoAroundAdvice" class="es.yell.frontlite.spring.EventoAroundAdvice "/>

    <bean id="eventoAfterAdvice" class="es.yell.frontlite.spring.EventoAfterAdvice"/>

    <!-- pointcuts definition-->
    <bean id = "beforePointCutAdvisor" class="org.springframework.aop.support.RegexpMetho dPointcutAdvisor">

    <property name="pattern">
    <value>.*obtener.*</value>
    </property>
    <property name="advice">
    <ref bean="eventoBeforeAdvice"/>
    </property>
    </bean>

    <bean id = "aroundPointCutAdvisor" class="org.springframework.aop.support.RegexpMetho dPointcutAdvisor">

    <property name="pattern">
    <value>.*obtener.*</value>
    </property>
    <property name="advice">
    <ref bean="eventoAroundAdvice"/>
    </property>
    </bean>

    <bean id = "afterPointCutAdvisor" class="org.springframework.aop.support.RegexpMetho dPointcutAdvisor">
    <property name="pattern">
    <value>.*obtener.*</value>
    </property>
    <property name="advice">
    <ref bean="eventoAfterAdvice"/>
    </property>
    </bean>

    <bean id="srvBusquedaNoxtrumService" class="org.springframework.aop.framework.ProxyFact oryBean">
    <property name="proxyInterfaces">
    <value>es.yell.frontlite.service.SrvBusquedaNoxtru mService</value>
    </property>

    <property name="interceptorNames">
    <list>
    <value>aroundPointCutAdvisor</value>
    </list>
    </property>

    <property name="target">
    <ref bean="srvBusquedaNoxtrumServiceTarget"/>
    </property>

    </bean>
    </beans>

    The case is that it seems that it does not intercept nothing at all.

    I put a trace in the method
    public Object invoke(MethodInvocation methodInvocation) throws Throwable
    of EventoAroundAdvice class and It never manages to execute.

    pls, i need help, Any help will be well received.

  • #2
    Did you try the config where you specify the target bean directly inside instead of the ref bean?

    Try to replace:

    <property name="target">
    <ref bean="srvBusquedaNoxtrumServiceTarget"/>
    </property>

    with

    <property name="target">
    <bean class="es.yell.frontlite.service.impl.SrvBusquedaN oxtrumServiceImpl"/>
    </property>

    Comment


    • #3
      thx for response, but it didnt work!

      i`ll keep trying

      Comment


      • #4
        yea! fixed the problem!

        applicationContext.xml

        <?xml version="1.0" encoding="UTF-8"?>
        <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
        "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
        <beans>
        <!-- bean que se encarga de parsear y de almacenar en un objeto el xml que nos devuelve la BBDD.
        No puede ser singleton-->
        <bean id="ParserSAX" class="es.yell.frontlite.parser.ParserPrincipalHan dler"/>

        <!-- bean que se encarga de formar la url.Puede ser singleton-->
        <bean id="Controller" class="es.yell.frontlite.servlets.Controller"/>
        <!-- bean que se encarga de gestionar las peticiones POST que hacen los clientes.
        Tiene inyectado el servicio que provee la funcionalidad para acceder al backend.-->
        <bean id="yellProxy" class="es.yell.frontlite.servlets.YellProxy">
        <property name="servicio">
        <ref bean="srvBusquedaNoxtrumService"/>
        </property>
        </bean>
        <!-- Implementacion del servicio. -->
        <bean id="srvBusquedaNoxtrumServiceTarget" class="es.yell.frontlite.service.impl.SrvBusquedaN oxtrumServiceImpl">
        <property name="parserSAX"><ref bean="ParserSAX"/></property>
        <property name="controlador"><ref bean="Controller"/></property>
        </bean>

        <!-- definicion de advices-->
        <bean id="eventoBeforeAdvice" class="es.yell.frontlite.spring.EventoBeforeAdvice "/>

        <bean id="eventoAroundAdvice" class="es.yell.frontlite.spring.EventoAroundAdvice "/>

        <bean id="eventoAfterAdvice" class="es.yell.frontlite.spring.EventoAfterAdvice"/>

        <!-- definicion de pointcuts-->
        <bean id = "beforePointCutAdvisor" class="org.springframework.aop.support.RegexpMetho dPointcutAdvisor">

        <property name="pattern">
        <value>.*obtener.*</value>
        </property>
        <property name="advice">
        <ref bean="eventoBeforeAdvice"/>
        </property>
        </bean>

        <bean id = "aroundPointCutAdvisor" class="org.springframework.aop.support.RegexpMetho dPointcutAdvisor">

        <property name="pattern">
        <value>.*obtener.*</value>
        </property>
        <property name="advice">
        <ref bean="eventoAroundAdvice"/>
        </property>
        </bean>

        <bean id = "afterPointCutAdvisor" class="org.springframework.aop.support.RegexpMetho dPointcutAdvisor">
        <property name="pattern">
        <value>.*obtener.*</value>
        </property>
        <property name="advice">
        <ref bean="eventoAfterAdvice"/>
        </property>
        </bean>

        <bean id="srvBusquedaNoxtrumService" class="org.springframework.aop.framework.ProxyFact oryBean">
        <property name="proxyInterfaces">
        <value>es.yell.frontlite.service.SrvBusquedaNoxtru mService</value>
        </property>

        <property name="interceptorNames">
        <list>
        <value>aroundPointCutAdvisor</value>
        <value>beforePointCutAdvisor</value>
        <value>afterPointCutAdvisor</value>
        </list>
        </property>

        <property name="target">
        <ref bean="srvBusquedaNoxtrumServiceTarget"/>
        </property>

        </bean>
        </beans>

        YellProxy.java

        public class YellProxy {

        //this is an interface!!
        private es.yell.frontlite.service.SrvBusquedaNoxtrumServic e servicio;

        getters, setters....

        thx a lot!

        Comment

        Working...
        X