cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Kulp <dk...@apache.org>
Subject Re: CXF With Spring AOP is not working.
Date Wed, 13 Mar 2013 21:05:12 GMT

On Mar 13, 2013, at 2:35 PM, Rajagopal Chowdary Yendluri <rajagopal.yendluri@gmail.com>
wrote:

>> Thanks Dan,
>> 
>> But if you look at UserServiceImpl  class, it is annotated with @Service,
>> so it participates in context component scan and spring creates this bean,
>> right?

Well, spring may create an instance of it, but that may not be the bean that is being passed
into CXF to actually publish.   How are you publishing the endpoint?   That's the important
thing to look at.

Dan




>> 
>> Let me know if i am not making you clear on this.
>> 
>> FYI.. i am using SOAPUI client to invoke this webservice (UserServiceImpl
>> ) for testing.
>> 
>> Raj
>> 
>> 
>> On Wed, Mar 13, 2013 at 11:25 PM, Daniel Kulp <dkulp@apache.org> wrote:
>> 
>>> 
>>> 
>>> How are you creating the UserServiceImpl instance?   AKA: how are you
>>> publishing the endpoint?
>>> 
>>> For the aspects to work, spring has to create the bean.   If you just
>>> pass a classname into CXF, we'll just do a "newInstance" on it and get a
>>> basic object.   Thus, you would need to have spring create it (<bean
>>> class="…" id="name"/>) and then reference that spring created bean.
>>> 
>>> Hope that helps.
>>> 
>>> Dan
>>> 
>>> 
>>> 
>>> On Mar 13, 2013, at 11:50 AM, Rajagopal Chowdary Yendluri <
>>> rajagopal.yendluri@gmail.com> wrote:
>>> 
>>>> Hi,
>>>> 
>>>> 
>>>> Here is the scenario i am trying.
>>>> 
>>>> 1. when an exception thrown from a web service i want to invoke an
>>> aspect
>>>> which is sending a mail to a mailing list.
>>>> 
>>>> Here is the steps which i tried.
>>>> 
>>>> 1. Added AspectJ support in applicaiton context by adding the following
>>>> line.
>>>> 
>>>>             *<aop:aspectj-autoproxy/>*
>>>> 
>>>> 2.  Written a new Aspect as following:
>>>> 
>>>> 
>>>> @Aspect
>>>> @Component
>>>> public class ExceptionMailer{
>>>> 
>>>> @AfterThrowing(pointcut="execution(* com.mycompany.*..impl.*.*(..))",
>>>> throwing ="ex")
>>>> public void sendExceptionMail(JoinPoint joinPoint) {
>>>> System.out.println(" Sending Email .....................again ");
>>>> }
>>>> }
>>>> 
>>>> 
>>>> 3. Here is my WebService class.
>>>> 
>>>> package com.mycompany.common.services.impl;
>>>> @WebService(endpointInterface =
>>>> "com.mycompnay.common.services.UserService",serviceName="UserDetails")
>>>> @Service
>>>> public class UserServiceImpl implements UserService {
>>>> 
>>>> public List<User> getUserDetails(String userId) throwsException {
>>>> 
>>>> try {
>>>>                       throw new Exception("Msg Exception ....");
>>>> } catch (Exception e) {
>>>> throw new Exception("xcepiton");
>>>> }
>>>> }
>>>> @PostConstruct
>>>> public void init() {
>>>> 
>>> SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
>>>> }
>>>> }
>>>> 
>>>> When i create a seperate project  with the same pointcout and with the
>>> same
>>>> package structure it is working good, but not with CXF.
>>>> 
>>>> Is there any way / we need to tell CXF, that i am using AspectJ AOP.
>>>> It is not throwing any exception, it is silently ignoring the Aspect.
>>>> 
>>>> 
>>>> --
>>>> Regards,
>>>> Rajagopal Yendluri(Raj)
>>> 
>>> --
>>> Daniel Kulp
>>> dkulp@apache.org - http://dankulp.com/blog
>>> Talend Community Coder - http://coders.talend.com
>>> 
>>> 
>> 
>> 
>> --
>> Regards,
>> Rajagopal Yendluri(Raj)
>> 
> 
> 
> 
> -- 
> Regards,
> Rajagopal Yendluri(Raj)

-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com


Mime
View raw message