You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "Wolf, Chris (IT)" <Ch...@morganstanley.com> on 2008/06/05 20:40:51 UTC

RE: Using AOP in CXF service impl

Ian,

Thanks for the "advice" ;)  Your suggestion helped me fix the problem,
in fact, I don't even need to bother with targetClass since the 
ServiceCallPointcut is associated with only that class (actually, 
object instance) via the ProxyFactory.addAdvisor call.

ProxyFactory factory = new ProxyFactory(svc);
factory.addAdvisor(new DefaultPointcutAdvisor(new ServiceCallPointcut(),
new AuthenticationChecker()));

   -Chris


-----Original Message-----
From: Ian Roberts [mailto:i.roberts@dcs.shef.ac.uk]
Sent: Sun 25/05/2008 12:08 PM
To: users@cxf.apache.org
Subject: Re: Using AOP in CXF service impl
 
Wolf, Chris (IT) wrote:
>   static class ServiceCallPointcut extends StaticMethodMatcherPointcut
{
>       public boolean matches(Method m, Class targetClass) {
>           return (targetClass == this.getClass() &&
> m.getName().matches("(add.*)|(delete.*)|(fetch.*)|(login.*)"));
>       }
>   }

I'm suspicious of the targetClass == this.getClass() - this is only true

if the targetClass is a ServiceCallPointcut...  Did you mean something 
like MyServiceImpl.this.getClass()?

As for the "wrong" targetClass issue, if you're only using this advice 
with a single instance of MyServiceImpl you could always store the impl 
object in a field of the AuthenticationChecker, then you can always get 
at the "real" object even if Spring passes a proxy to the before method.

Ian

-- 
Ian Roberts               | Department of Computer Science
i.roberts@dcs.shef.ac.uk  | University of Sheffield, UK
--------------------------------------------------------

NOTICE: If received in error, please destroy and notify sender. Sender does not intend to waive confidentiality or privilege. Use of this email is prohibited when received in error.