very useful to determine bottlenecks on application and find the impacted component. It provides too statistics on calls ( between the start and the end of monitors ).
This tool can be download at the following url:
http://sourceforge.net/project/showfiles.php?group_id=96550
and you can find its documentations on these sites:
http://jamonapi.sourceforge.net/
http://www.javaperformancetuning.com/tools/jamon/index.shtml
To install it in your application, only JAMon.jar must be in your classpath.
Spring already has an aop interceptor to measure performance of application components based on commons-logging. The idea is to provide a simple JAMon interceptor to start monitor before the call and end it after the call.
It provides too facilities to name the JAMon monitor with class and method names.
The method getMonitorName determines the monitor name:
protected String getMonitorName(MethodInvocation invocation) {
StringBuffer monitorName=new StringBuffer();
monitorName.append(
invocation.getMethod().getDeclaringClass().getName());
monitorName.append(" ( ");
monitorName.append(invocation.getMethod().getName());
monitorName.append(" )");
return monitorName.toString();
}
The Spring AOP interceptor is simple:
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import com.jamonapi.Monitor;
import com.jamonapi.MonitorFactory;
public class PerfIntercepteur implements MethodInterceptor {
protected String getMonitorName(MethodInvocation invocation) {
StringBuffer monitorName=new StringBuffer();
monitorName.append(
invocation.getMethod().getDeclaringClass().getName());
monitorName.append(" ( ");
monitorName.append(invocation.getMethod().getName());
monitorName.append(" )");
return monitorName.toString();
}
public Object invoke(MethodInvocation invocation) throws Throwable {
Monitor mon=MonitorFactory.start(getMonitorName(invocation));
Object rval=invocation.proceed();
mon.stop();
return rval;
}
}
and you can configure it in this way:
<!DOCTYPE beans PUBLIC
"-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
...
<bean id="perfInterceptor" class="aop.PerfIntercepteur"/>
<bean id="autoProxyCreator" class="org.springframework.aop.framework.
autoproxy.BeanNameAutoProxyCreator">
<property name="interceptorNames">
<list>
<idref local="perfInterceptor" />
</list>
</property>
<property name="beanNames">
<list>
<idref local="service" />
</list>
</property>
</bean>
</beans>
The aim is to plug the JAMon interceptor on the component of the application layer to identifity the component that has performance problem ( from presentation layer to dao layer ).
2 comments:
Dimitry,
I'm really glad that you have added to the Spring Core!!
Thanks to tell me this.
Thierry
If you want a good jamon visit Spanishtaste shop www.spanishtaste.es
Post a Comment