1 17 18 package org.objectweb.jac.aspects.hibernate; 19 20 import net.sf.hibernate.HibernateException; 21 import net.sf.hibernate.Transaction; 22 23 import org.aopalliance.intercept.ConstructorInvocation; 24 import org.aopalliance.intercept.MethodInvocation; 25 import org.objectweb.jac.core.AspectComponent; 26 import org.objectweb.jac.core.Interaction; 27 import org.objectweb.jac.core.Wrapper; 28 29 35 public class EndPersistentSessionWrapper extends Wrapper { 36 37 38 private HibernateHelper hh = HibernateHelper.get(); 39 40 public EndPersistentSessionWrapper( AspectComponent ac ) { 41 super(ac); 42 } 43 44 48 public Object invoke( MethodInvocation invocation ) { 49 Interaction interaction = (Interaction) invocation; 50 51 Object ret = proceed(interaction); 52 53 try { 54 Transaction tx = hh.getTx(); 55 tx.commit(); 56 return ret; 57 } catch (HibernateException e1) { 58 e1.printStackTrace(); 59 System.exit(1); 60 } 61 return null; 62 } 63 64 public Object construct(ConstructorInvocation invocation) 65 throws Throwable { 66 throw new Exception ("This wrapper does not support constructor wrapping"); 67 } 68 } 69 | Popular Tags |