• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Spring 1.2 AOP, Advice is not executing

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I need some help to get my AOP implementation working. I just want to execute a piece of code before invokation of a method.

Here is the code snippet.

<!-- Advice -->
<bean id="urlTamperingDetectorAdvice" class="com.fun.org.msg.util.UrlTampringDetector" />
<!-- Advisor -->
<bean id="urlTamperingAdvisor" class="org.springframework.aop.support.NameMatchMethodPointcutAdvisor">
<property name="mappedNames" value="getRequestBody" />
<property name="advice" ref="urlTamperingDetectorAdvice" />
</bean>
<!-- Proxy -->
<bean id="fun.org.msg.TaskAProxy" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="target">
<bean class="com.fun.org.msg.requester.WebServiceRequesterTaskA" parent="fun.org.msg.WebServiceRequester">
<property name="suffix" value="/approve" />
<property name="fieldUnpackers">
<list>
<ref bean="fun.org.TaskUnpacker" />
</list>
</property>
</bean>
</property>
<property name="interceptorNames">
<list>
<value>urlTamperingAdvisor</value>
</list>
</property>
</bean>

The class for Advice

public class UrlTampringDetector implements MethodInterceptor
{
public Object invoke(MethodInvocation methodInvocation) throws Throwable
{
ValidateUrl();// some logic here
return methodInvocation.proceed();
}
}

Now how I am expecting this to called

We have some handlers for different kind of activities, that later executes a list of tasks. e.g.

<bean id="myTask..processor.TaskHandler" class="com.myTask.processor.handler.impl.RequestMessageHandlerImpl">
<property name="taskProcessors">
<list>
<ref bean="myTask.FlagInComingParametersTask" />
<ref bean="myTask.SetLocaleSpecificPropertiesTask" />
<ref bean="myTask.Host_Generic_Task" />
</list>
</property>
</bean>

<bean id="myTask.Host_Generic_Task" class="fun.org.msg.HostMappedTaskList">
<property name="taskMap">
<map>
<entry key="hostType1">
<list>
<ref bean="fun.org.msg.TaskAProxy" />
</list>
</entry>
</map>
</property>
</bean>

In fun.org.msg.HostMappedTaskList, it is calling a method of the WebServiceRequesterTaskA class.

In my scenario the method of target class is being executed but my proxy's method is not being executed. I dont know what I am doing wrong.
 
What's that smell? Hey, sniff this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic