1 17 18 package org.objectweb.jac.aspects.hibernate; 19 20 import java.util.ArrayList ; 21 import java.util.List ; 22 23 import net.sf.hibernate.HibernateException; 24 import net.sf.hibernate.MappingException; 25 26 import org.objectweb.jac.core.AspectComponent; 27 import org.objectweb.jac.core.rtti.ClassItem; 28 import org.objectweb.jac.core.rtti.ClassRepository; 29 30 36 public class HibernateAC extends AspectComponent { 37 public HibernateAC() {} 38 39 40 private HibernateHelper hh = HibernateHelper.get(); 41 42 47 public void registerPersistentClass( String className ) { 48 49 ClassItem cli = cr.getClass(className); 50 Class cl = cli.getActualClass(); 51 52 try { 53 hh.addClass(cl); 54 } catch (MappingException e) { 55 e.printStackTrace(); 56 System.exit(1); 57 } 58 } 59 60 private ClassRepository cr = ClassRepository.get(); 61 62 63 66 public void initStorage() { 67 try { 68 hh.schemaExport(); 69 } catch (HibernateException e) { 70 e.printStackTrace(); 71 System.exit(1); 72 } 73 } 74 75 76 77 private List persistentObjects = new ArrayList (); 78 List getPersistentObjects() { return persistentObjects; } 79 80 90 public void registerPersistentObject( String objectNameExpression ) { 91 persistentObjects.add(objectNameExpression); 92 } 93 94 95 109 public void delimitPersistentSession( 110 String sessionid, 111 String beginCNE, String beginONE, String beginMNE, 112 String endCNE, String endONE, String endMNE ) { 113 114 BeginPersistentSessionWrapper beginwrapper = 115 new BeginPersistentSessionWrapper(this); 116 117 EndPersistentSessionWrapper endwrapper = 118 new EndPersistentSessionWrapper(this); 119 120 pointcut( beginONE, beginCNE, beginMNE, beginwrapper, null ); 121 pointcut( endONE, endCNE, endMNE, endwrapper, null ); 122 } 123 124 } 125 | Popular Tags |