Results 1 to 4 of 4

Thread: Inherit Multiple advice interface

  1. #1
    Join Date
    Apr 2012
    Posts
    2

    Default Inherit Multiple advice interface

    Hi,

    Why is this not possible to inherit multiple advice interface on a single advice? (Sorry it's possible but the behavior is not as expected)

    For example if I want to get this:
    Code:
     public class MethodAdvice : IMethodBeforeAdvice, IAfterReturningAdvice , IThrowsAdvice 
        {
             private static readonly ILog Logger = LogManager.GetLogger(Assembly.GetExecutingAssembly().GetType());
    
            public void Before(System.Reflection.MethodInfo method, object[] args, object target)
            {
                  Logger.Info("Before call");
            }
    
            public void AfterReturning(object returnValue, System.Reflection.MethodInfo method, object[] args, object target)
            {
                 Logger.Info("After call");
            }
    
            public void AfterThrowing(ApplicationException aex)
            {
                Logger.Info("Exception");
            }
    
         
        }
    It will fire only the first interface found, in this case IMethodBeforeAdvice.

    For to solve this i used IMethodInterceptor instead of the Advice interfaces

    But Is there a way to use only the advice interfaces?

  2. #2
    Join Date
    Jul 2010
    Posts
    245

    Default

    Can you post a copy of the xml config that drives this behavior (e.g., are you using DefaultAdvisorAutoproxyCreator, etc.)? I'd like to experiment with it on my side a bit.

    Thanks,
    -Steve B.

  3. #3
    Join Date
    Apr 2012
    Posts
    2

    Default

    Hi,

    Sorry for the delay.
    Just for information i work with asp MVC and i want to plug AOP on controler's method decorate.

    Here My Interceptor:
    I declare which decorator to watch
    and the device class to use.

    HTML Code:
    <object id="MyInterceptor" type="Spring.Aop.Support.AttributeMatchMethodPointcutAdvisor, Spring.Aop">
    	<property name="Advice">
    		<object type="Samp.Utilities.MethodAdvice, Samp.Utilities" />
    	</property>
    	<property name="Attribute" value="Samp.Utilities.MethodAdviceAttribute, Samp.Utilities" />
    </object>
    the proxy to handle all controller with my interceptor

    HTML Code:
    <object type="Spring.Aop.Framework.AutoProxy.InheritanceBasedAopConfigurer, Spring.Aop">
    		<property name="ObjectNames">
    			<list>
    				<value>*Controller#*</value>
    			</list>
    		</property>
    		<property name="InterceptorNames">
    			<list>
    				<value>MyInterceptor</value>
    			</list>
    		</property>
    </object>
    For testing, if my Advice inherit of IMethodBeforeAdvice (no matter the order) it always fire his method (Before) and the AfterReturning method is not fire.

    If I remove the IMethodBeforeAdvice interface. The IAfterReturningAdvice's method (AfterReturning) is fire.

  4. #4
    Join Date
    Jul 2010
    Posts
    245

    Default

    Confirmed this is an issue in SPRNET 1.3.2. JIRA opened here https://jira.springsource.org/browse/SPRNET-1506 to track progress on this.

    Thanks,
    -Steve B.

Tags for this Thread

Posting Permissions

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