1 17 18 package org.objectweb.jac.aspects.distrans; 19 20 21 import java.lang.reflect.InvocationTargetException ; 22 import org.objectweb.jac.aspects.distrans.persistence.PersistenceAC; 23 import org.objectweb.jac.core.ACManager; 24 import org.objectweb.jac.core.AspectComponent; 25 import org.objectweb.jac.core.NameRepository; 26 import org.objectweb.jac.core.Wrapper; 27 import org.objectweb.jac.core.rtti.ClassItem; 28 import org.objectweb.jac.core.rtti.ClassRepository; 29 import org.objectweb.jac.util.Log; 30 import org.objectweb.jac.util.Repository; 31 32 44 public class DisTransAC extends AspectComponent { 45 46 47 private PersistenceAC persistenceAC; 48 49 public DisTransAC() { 50 51 57 persistenceAC = null; 58 59 ACManager acm = ACManager.getACM(); 60 Object [] acs = acm.getObjects(); 61 for (int i = 0; i < acs.length; i++) { 62 if ( acs[i] instanceof PersistenceAC ) 63 persistenceAC = (PersistenceAC)acs[i]; 64 } 65 66 if ( persistenceAC == null ) 67 throw new RuntimeException ( 68 "An AC implementing jac.aspects.distrans.persistence.PersistenceItf is mandatory for DisTransAC to work" 69 ); 70 } 71 72 73 91 public void delimitTransaction( 92 String txid, 93 String beginCNE, String beginONE, String beginMNE, 94 String endCNE, String endONE, String endMNE, 95 String decisionClassName ) { 96 97 BeginTransactionWrapper beginwrapper = 98 new BeginTransactionWrapper(this); 99 100 ClassItem cl = classes.getClass(decisionClassName); 101 102 Wrapper endwrapper = null; 103 try { 104 endwrapper = (Wrapper) 105 cl.newInstance( 106 new Class []{AspectComponent.class}, 107 new Object []{this} 108 ); 109 } catch (Exception e) { 110 Log.error("delimitTransaction: Failed to instanciate endwrapper "+decisionClassName); 111 e.printStackTrace(); 112 } 113 pointcut(beginONE, beginCNE, beginMNE, beginwrapper, null); 114 pointcut(endONE, endCNE, endMNE, endwrapper, null); 115 } 116 117 118 122 private Repository names = NameRepository.get(); 123 124 127 private ClassRepository classes = ClassRepository.get(); 128 } 129 | Popular Tags |