Hi
Okay for the time being it is okay ,
what i did i save as the aop.xsd and save in my local computer
but after i test . i didnt see any interceptor lines
here is my output
Code:
0 [main] INFO xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [SpringAop.xml]
889 [main] INFO xml.DefaultNamespaceHandlerResolver - Ignoring handler [org.springframework.scripting.config.LangNamespaceHandler]: class not found
889 [main] INFO xml.DefaultNamespaceHandlerResolver - Ignoring handler [org.springframework.ejb.config.JeeNamespaceHandler]: class not found
920 [main] INFO support.ClassPathXmlApplicationContext - Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext;hashCode=18468004]: org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [fooService,profiler,org.springframework.aop.config.internalAutoProxyCreator,theExecutionOfSomeFooServiceMethod]; root of BeanFactory hierarchy
936 [main] INFO support.ClassPathXmlApplicationContext - 4 beans defined in application context [org.springframework.context.support.ClassPathXmlApplicationContext;hashCode=18468004]
951 [main] INFO core.CollectionFactory - JDK 1.4+ collections available
967 [main] INFO core.CollectionFactory - Commons Collections 3.x available
1107 [main] INFO framework.DefaultAopProxyFactory - CGLIB2 available: proxyTargetClass feature enabled
1201 [main] INFO support.ClassPathXmlApplicationContext - Bean 'org.springframework.aop.config.internalAutoProxyCreator' is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
1201 [main] INFO support.ClassPathXmlApplicationContext - Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMessageSource@cbf30e]
1216 [main] INFO support.ClassPathXmlApplicationContext - Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicationEventMulticaster@12bb7e0]
1216 [main] INFO support.DefaultListableBeanFactory - Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [fooService,profiler,org.springframework.aop.config.internalAutoProxyCreator,theExecutionOfSomeFooServiceMethod]; root of BeanFactory hierarchy]
NAME +++>Pengo
my Foo Service as below
Code:
interface FooService {
String getFoo(String fooName, int age);
}
public class DefaultFooService implements FooService {
public String getFoo(String name, int age) {
System.out.println("NAME +++>"+name);
return "1";
}
}
My Profiles is as below
Code:
import org.aspectj.lang.ProceedingJoinPoint;
import org.springframework.util.StopWatch;
public class SimpleProfiler {
public Object profile(ProceedingJoinPoint call, String name, int age) throws Throwable {
StopWatch clock = new StopWatch(
"Profiling for '" + name + "' and '" + age + "'");
System.out.println("PROFILING for "+name);
try {
clock.start(call.toShortString());
return call.proceed();
} finally {
clock.stop();
System.out.println(clock.prettyPrint());
}
}
}
Anything wrong with my code??
By right if this one works , i should be able to see "PROFILING" String
here is my SpringAop.xml
Code:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/aop C:\aop.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<!-- this is the object that will be proxied by Spring's AOP infrastructure -->
<bean id="fooService" class="biz.DefaultFooService"/>
<!-- this is the actual advice itself -->
<bean id="profiler" class="biz.SimpleProfiler"/>
<aop:config>
<aop:aspect ref="profiler">
<aop:pointcut id="theExecutionOfSomeFooServiceMethod"
expression="execution(* biz.FooService.getFoo(String,int))
and args(name, age)"/>
<aop:around pointcut-ref="theExecutionOfSomeFooServiceMethod"
method="profile"/>
</aop:aspect>
</aop:config>
</beans>