Announcement Announcement Module
Collapse
No announcement yet.
Pointcut does not matching Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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, 02:04 PM.

  • #2
    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).

    Comment

    Working...
    X