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

  • Passing hardcoded spring value to advice method as parameter

    Hi,

    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
    Code:
    <bean id="myAspect" class="com.mypackage.MyAspect" />
    	<aop:config>
    		<aop:aspect ref="myAspect">
    			<aop:pointcut id="businessLogic"
    				expression="execution(* com.mypackage.businessLogic(..))" />
    			<aop:after-returning pointcut-ref="businessLogic"
    				method="doApectWork" returning="myObject" />
    		</aop:aspect>
    	</aop:config>
    
    Apect Method being
     public void doApectWork(JoinPoint jp, Object myObject)
    Here i want my method to take one more parameter
    Code:
     
    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
    Paddy
Working...
X