AnsweredAssumed Answered

Intercept WebScript via AOP

Question asked by ghernando on Sep 28, 2011
I'd like to be able to use AOP to intercept a web script's operations.
For example, the download operation.
The web script that I would like to monitor, for the download example, is:

I've added to a *-context.xml file the following:

   <bean id="interceptedDownloadMethod"  class="com.alfresco.test.IntDownload " />
   <bean id="[b]interceptedDownload[/b]" class="org.springframework.aop.framework.ProxyFactoryBean">
        <property name="target">
            <ref bean="" />
        <property name="interceptorNames">

com.alfresco.test.IntDownload looks something like:

public class IntDownload implements MethodInterceptor {
   private final Log logger = LogFactory.getLog(IntDownload .class);
  public Object invoke(MethodInvocation methodInvocation) throws Throwable {
    Object result = null;
       logger.error("Invoking download");
       result = methodInvocation.proceed();
    catch (Exception ex)
         logger.error("Error while interceptingDownload");
         throw new AlfrescoRuntimeException("Error on download intercept: ", ex);
    return result;
Based on the log file output, this seems to get loaded.
I don't see any errors.
In fact, I see something like:

DEBUG [com.alfresco.test.IntDownload]  preRegister called. Server=com.sun.jmx.mbeanserver.JmxMBeanServer@152544e,

Which is encouraging since it seems to have been registered.
The download happens, but it doesn't seem to get into the Interceptor method.

I've tried commenting out the proceed(), but there is no effect.  The download still occurs.
I think that the interceptor invoke() method isn't getting called, but I don't know why.