Results 1 to 2 of 2

Thread: Pointcut does not matching

Hybrid View

  1. #1
    Join Date
    Apr 2012
    Posts
    1

    Default Pointcut does not matching

    My application uses a library of gwt-dispatch. I'm trying to use AOP for specific purposes, I want to modify the type of exception generated servlet.

    In setting the AOP point out the following:

    Code:
    <bean name="errorsAdviser" class="com.test.app.server.aop.ErrorsAdviser" />
    
    
    <aop:aspectj-autoproxy/>
    <aop:config>
      <aop:aspect id="exceptionCatcher" ref="errorsAdviser">
     	 <aop:pointcut id="exceptionCatcherPointCut" expression="execution(* net.customware.gwt.dispatch.server.spring..*.*(..))"/>
    	 <aop:after-returning method="afterReturning" pointcut-ref="exceptionCatcherPointCut"/>
    </aop:config>


    Pointed Class:
    Code:
    package net.customware.gwt.dispatch.server.spring;
    
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    
    import net.customware.gwt.dispatch.server.Dispatch;
    import net.customware.gwt.dispatch.server.standard.AbstractStandardDispatchServlet;
    
    import org.springframework.beans.factory.BeanFactoryUtils;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.web.context.WebApplicationContext;
    import org.springframework.web.context.support.WebApplicationContextUtils;
    
    public class SpringStandardDispatchServlet extends AbstractStandardDispatchServlet {
        
        @Autowired
        private Dispatch dispatch;
        
        @Override
        public void init(ServletConfig config) throws ServletException {
    
            super.init(config);
            
            WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(config.getServletContext());
            
            dispatch = (Dispatch) BeanFactoryUtils.beanOfType(ctx, Dispatch.class);
        }
     
    
        @Override
        protected Dispatch getDispatch() {
            
            return dispatch;
        }
    }
    Code:
    package net.customware.gwt.dispatch.server.standard;
    
    import net.customware.gwt.dispatch.client.standard.StandardDispatchService;
    import net.customware.gwt.dispatch.server.Dispatch;
    import net.customware.gwt.dispatch.shared.Action;
    import net.customware.gwt.dispatch.shared.DispatchException;
    import net.customware.gwt.dispatch.shared.Result;
    import net.customware.gwt.dispatch.shared.ServiceException;
    
    import com.google.gwt.user.server.rpc.RemoteServiceServlet;
    
    public abstract class AbstractStandardDispatchServlet extends RemoteServiceServlet implements
            StandardDispatchService {
    
        public Result execute( Action<?> action ) throws DispatchException {
            try {
                Dispatch dispatch = getDispatch();
                
                if ( dispatch == null )
                    throw new ServiceException("No dispatch found for servlet '" + getServletName() + "' . Please verify your server-side configuration.");
                
                return dispatch.execute( action );
            } catch ( RuntimeException e ) {
                log( "Exception while executing " + action.getClass().getName() + ": " + e.getMessage(), e );
                throw new ServiceException( e );
            }
        }
    
        /**
         * 
         * @return The Dispatch instance.
         */
        protected abstract Dispatch getDispatch();
    
    }



    However, the match does not occur, although in debugger I can see that the methods are executed.

    In what may be the problem? What am I doing wrong?
    Last edited by zupport; Apr 8th, 2012 at 01:04 PM.

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    Please use the search this question has been answered numerous times before.

    Spring will only intercept beans it knowns (yours is apparently a servlet not under spring control) and next it will only intercept external and not internall method calls (due to the fact spring uses proxies).
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •