I use the first option as you said, and it works.
Thanks again,Brice!  :-)


2007/1/1, Brice Ruth <[EMAIL PROTECTED]>:

Ah, OK - I think you have two options.

   1. The serviceBean you provide to XFireExporter should be the bean
   you create with the ProxyFactoryBean - rename echoBean to echoTarget and
   rename LoggingAOPProxy to echoBean
   2. Use one of Spring's 'in place' proxy factories - like
   BeanNameProxyFactory (look at the Spring docs for the exact name) which will
   replace the echoBean in the Spring context with the proxied bean, so no
   unproxied bean should be available for XFire to grab.

Either of those options should get you on the road to success. Good luck!

Brice

On 12/31/06, yongguang zhao < [EMAIL PROTECTED]> wrote:
>
> Thanks for your reply,Brice!
> Actually, my app is almost the same as the spring example in the
> xfire-distribution-1.2.3.zip,  what I want is just to put spring aop
> into work.
> as in the xfire-servlet.xml:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" 
"http://www.springframework.org/dtd/spring-beans.dtd
> ">
> <beans>
>     <!-- START SNIPPET: xfire -->
>     <bean class="
> org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
>         <property name="urlMap">
>             <map>
>                 <entry key="/EchoService">
>                     <ref bean="echo"/>
>                 </entry>
>             </map>
>         </property>
>     </bean>
>
>     <!-- Declare a parent bean with all properties common to both
> services -->
>     <bean id="echo" class="
> org.codehaus.xfire.spring.remoting.XFireExporter">
>         <property name="serviceFactory">
>             <ref bean="xfire.serviceFactory"/>
>         </property>
>         <property name="xfire">
>             <ref bean="xfire"/>
>         </property>
>         <property name="serviceBean">
>             <ref bean="echoBean"/>
>         </property>
>         <property name="serviceClass">
>             <value>org.codehaus.xfire.spring.example.Echo</value>
>         </property>
>     </bean>
>     <!-- END SNIPPET: xfire -->
> </beans>
> I think that XFireExporter takes control of "echoBean" and make some
> proxy beans using it , which handle http request.
> While my spring advice only intercept "echoBean", so there is no effect.
> Is it right? And what should I do to make it works?
>
>
> 2006/12/31, Brice Ruth <[EMAIL PROTECTED]>:
> >
> > I'm not sure about the xfire-servlet mechanism, but when we first
> > started using Spring AOP with XFire + JSR-181 + Jsr181BeanPostProcessor, we
> > found that the Jsr181BeanPostProcessor was grabbing the service bean before
> > the AOP advice had been wrapped around it. Order is very important, since
> > the advice is applied at runtime to an object (by creating a proxy) - not to
> > the class, which is how many folks learn to use AOP. With Spring AOP, you
> > can easily have an object with and without the advice you've created, which
> > isn't the case with compile-time weaving.
> >
> > xfire-servlet is either not looking at your Spring context bean at all
> > (its instantiating it purely from some configuration), or its grabbing your
> > Spring context bean before its been advised. I can't really tell w/o know
> > more about how xfire-servlet configuration works and what else you have in
> > your Spring context related to XFire.
> >
> > Cheers,
> > Brice
> >
> > On 12/31/06, yongguang zhao <[EMAIL PROTECTED] > wrote:
> > >
> > > Hi,
> > > I want to add some logging functionality to the XFire spring
> > > example--Echo,
> > > that is, after some client invokes the Echo service, I want to log
> > > something.
> > > I think Spring AOP is the best choice,
> > > here is my applicationContext.xml:
> > >
> > > <?xml version="1.0" encoding="UTF-8"?>
> > > <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" 
"http://www.springframework.org/dtd/spring-beans.dtd
> > > ">
> > > <beans>
> > >     <bean id="echoBean" class="
> > > org.codehaus.xfire.spring.example.EchoImpl"/>
> > >     <bean id="LoggingInterceptor" class="com.xyz.LoggingAdvice"/>
> > >
> > >     <bean id="LoggingPointcutAdvisor" class="
> > > org.springframework.aop.support.DefaultPointcutAdvisor ">
> > >         <property name="advice">
> > >             <ref local="LoggingInterceptor"/>
> > >         </property>
> > >         <property name="pointcut">
> > >             <bean class="
> > > org.springframework.aop.support.JdkRegexpMethodPointcut">
> > >                 <property name="pattern">
> > >                     <value>.*</value>
> > >                 </property>
> > >             </bean>
> > >         </property>
> > >  </bean>
> > >  <bean id="LoggingAOPProxy" class="
> > > org.springframework.aop.framework.ProxyFactoryBean">
> > >   <property name="target">
> > >    <ref local="echoBean" />
> > >   </property>
> > >   <property name="interceptorNames">
> > >    <list>
> > >     <value>LoggingPointcutAdvisor</value>
> > >    </list>
> > >   </property>
> > >  </bean>
> > > </beans>
> > > the LoggingAdvice mentioned before is simple:
> > >
> > > package com.xyz;
> > >
> > > import java.lang.reflect.Method;
> > >
> > > import org.apache.commons.logging.Log;
> > > import org.apache.commons.logging.LogFactory;
> > > import org.apache.log4j.Logger;
> > > import org.springframework.aop.AfterReturningAdvice;
> > > import org.springframework.aop.MethodBeforeAdvice ;
> > >
> > > public class LoggingAdvice implements MethodBeforeAdvice,
> > > AfterReturningAdvice {
> > >  private static Log log = LogFactory.getLog(LoggingAdvice.class);
> > >
> > >  public void before(Method method, Object[] args, Object target)
> > >    throws Throwable {
> > >   log.debug("before");
> > >  }
> > >
> > >  public void afterReturning(Object retuVal, Method method, Object[]
> > > args,
> > >    Object target) throws Throwable {
> > >   log.debug("afterReturning");
> > >  }
> > > }
> > > while xfire-servlet.xml is the same as in the example.
> > >
> > > However the interceptor just does not work,
> > > can anyone please help me?
> > >
> > > thanks.
> > >
> > >
> >
> >
> >
> > --
> > Brice Ruth
> > Software Engineer, Madison WI
>
>
>


--
Brice Ruth
Software Engineer, Madison WI

Reply via email to