aspose file tools*
The moose likes Spring and the fly likes spring AOP doesn't work Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "spring AOP doesn Watch "spring AOP doesn New topic
Author

spring AOP doesn't work

Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
Edited to correct spelling of AOP in subject. Proofreading the subject, at least, is a good idea.

this is my Audiance.java class


this is my AudianceAdvice.java class


this is main.xml class
code]
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

<bean id="FoodService" class="com.aruna.Dog">
<property name="food" value="Chickenn" />
</bean>

<bean id="audiance" class="com.aruna.Audience"></bean>

<bean id="audienceAdvice" class="com.aruna.AudienceAdvice">
<property name="audience" ref="audience" />
</bean>

<bean id="performancePointcut" class="org.springframework.aop.support.JdkRegexpMethodPointcut">
<property name="pattern" value=".*perform" />
</bean>

<bean id="audienceAdvisor" class="org.springframework.aop.support.DefaultPointcutAdvisor">
<property name="advice" ref="audienceAdvice" />
<property name="pointcut" ref="performancePointcut" />
</bean>

</beans>[/code]

this is main class


but it gives me only
CLAP CLAP CLAP CLAP CLAP as a output.
why the AOP doesn't working??
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Because the regex "*.perform" appears nowhere but in your regex?
Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
I don't understand what are you saying.Can you explaing little bit more?
Actually i am new to Spring AOP .I am try to run this example.
can you please tell me the error ?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

What does the "pattern" property mean in a JdkRegexpMethodPointcut?
Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
ok
which class i need to include perform method?
Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
I change my classes.
now main class is here


main.xml is here


juggler class here


Audience class here


AudienceAdvice is here

now when i run main class it just gives
JUGGLING 3 BEANBAGS
why still not running AOP ?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I think you're focusing too narrowly here: take a step back. What's the difference between what you're doing and what the configuration you're using is doing? Can you think of a way to make it work without adding a method matching ".*perform"? Or, if you're dead-set on using that regex, where do *you* think you'd need to add a method ending with "perform"?
Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
I change the classes as above.Still No good results.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Please, *please* try to work through what's happening here.

Answer these questions (here, in the forum):

- What are you attempting to use AOP on?
- What objects do you instantiate?
- What methods do you call on which objects?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: spring AOP doesn't work