Announcement Announcement Module
No announcement yet.
Passing hardcoded spring value to advice method as parameter Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Passing hardcoded spring value to advice method as parameter


    I am trying AOP parametrization for the first time. I would really appreciate if somebody could help me clear the following doubt.

    I have a advice method around a given Business logic method. Is it possible to add a new parameter to my advice method and pass the value hard coded in the xml configuration?

    For example
    <bean id="myAspect" class="com.mypackage.MyAspect" />
    		<aop:aspect ref="myAspect">
    			<aop:pointcut id="businessLogic"
    				expression="execution(* com.mypackage.businessLogic(..))" />
    			<aop:after-returning pointcut-ref="businessLogic"
    				method="doApectWork" returning="myObject" />
    Apect Method being
     public void doApectWork(JoinPoint jp, Object myObject)
    Here i want my method to take one more parameter
    public void doApectWork(JoinPoint jp, Object myObject, myStaticParam)
    and pass the same at deploy time through my xml configuration.

    Basically, what I am trying to achieve here is that if I have 2 Business Logic methods for the first one I want to apply an aspect with a static parameter and another aspect for the second business logic method with another static parameter and invoke the same method.

    I cannot make this into two different methods as the parameter values play a role further in the code.

    If this is not possible through aspect, is there any other way I can achieve the same using Spring.

    Thanks in advance