there's something about the web…
testting google-code-prettify
import javax.ejb.Stateful;
import javax.interceptor.AroundInvoke;
import javax.interceptor.InvocationContext;
@Stateful
public class EmployeeBean implements EmployeeServiceLocal, EmployeeServiceRemote {
public EmployeeBean() {
}
public void doAction() {
System.out.println("Processing...");
}
@AroundInvoke
public Object TimerLog(InvocationContext ctx) throws Exception {
String beanClassName = ctx.getClass().getName();
String businessMethodName = ctx.getMethod().getName();
String target = beanClassName + "." + businessMethodName;
long startTime = System.currentTimeMillis();
System.out.println("Invoking " + target);
try {
return ctx.proceed();
} finally {
System.out.println("Exiting " + target);
long totalTime = System.currentTimeMillis() - startTime;
System.out.println("Business method " + businessMethodName + "in " + beanClassName + "takes "
+ totalTime + "ms to execute");
}
}
}
| Print article | This entry was posted by narven on 27/01/2010 at 04:16, and is filed under Uncategorized. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |