FileDocCategorySizeDatePackage
LoggingAround.javaAPI DocExample1237Mon Apr 25 07:28:34 BST 2005com.springbook.interceptors

LoggingAround

public class LoggingAround extends Object implements MethodInterceptor

Fields Summary
private net.sf.hibernate.SessionFactory
factory
Constructors Summary
Methods Summary
public net.sf.hibernate.SessionFactorygetFactory()

      return factory;
   
public java.lang.Objectinvoke(org.aopalliance.intercept.MethodInvocation methodInvocation)

      System.out.println("JBG: In invoke");
      final String methodName = methodInvocation.getMethod().getName();
      logEvent(methodName, "Entering call.");
      Object result = methodInvocation.proceed();
      logEvent(methodName, "Leaving call.");
      return result;
   
private voidlogEvent(java.lang.String methodName, java.lang.String message)

      LogEvent le = new LogEvent(methodName, new Date(), message);
      Session s = null;
      try {
         s = factory.openSession();
         s.save(le);
      } catch (Exception ex) {
         // log the exception
      } finally {
         s.close();
      }
   
public voidsetFactory(net.sf.hibernate.SessionFactory factory)

      this.factory = factory;