1 17 18 package org.objectweb.jac.aspects.distrans.persistence; 19 20 import org.enhydra.jdbc.standard.StandardXADataSource; 21 22 import org.objectweb.jac.core.AspectComponent; 23 import org.objectweb.jac.core.Interaction; 24 import org.objectweb.jac.core.NameRepository; 25 import org.objectweb.jac.core.Wrapper; 26 import org.objectweb.jac.util.Repository; 27 28 import org.aopalliance.intercept.ConstructorInvocation; 29 import org.aopalliance.intercept.MethodInvocation; 30 31 42 public class ReadWrapper extends Wrapper { 43 44 48 private PersistenceItf storage; 49 50 54 private StandardXADataSource ds; 55 56 62 public ReadWrapper( 63 AspectComponent ac, PersistenceItf storage, StandardXADataSource ds ) { 64 65 super(ac); 66 this.storage = storage; 67 this.ds = ds; 68 } 69 70 78 public Object invoke(MethodInvocation invocation) throws Throwable { 79 80 Interaction interaction = (Interaction) invocation; 81 82 Object wrappee = interaction.wrappee; 83 String wrappeeName = names.getName(wrappee); 84 85 try { 86 storage.load(wrappee,wrappeeName,ds); 87 } catch (Exception e) { 88 e.printStackTrace(); 89 System.exit(1); 90 } 91 92 return proceed(interaction); 93 } 94 95 96 100 private Repository names = NameRepository.get(); 101 102 public Object construct(ConstructorInvocation invocation) 103 throws Throwable { 104 throw new Exception ("This wrapper does not support constructor wrapping"); 105 } 106 } 107 | Popular Tags |