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 WriteWrapper extends Wrapper { 43 44 48 private PersistenceItf storage; 49 50 54 private StandardXADataSource ds; 55 56 62 public WriteWrapper( 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 83 Object ret = proceed(interaction); 84 85 Object wrappee = interaction.wrappee; 86 String wrappeeName = names.getName(wrappee); 87 88 try { 89 storage.store(wrappee,wrappeeName,ds); 90 } catch (Exception e) { 91 e.printStackTrace(); 92 System.exit(1); 93 } 94 95 return ret; 96 } 97 98 99 103 private Repository names = NameRepository.get(); 104 105 public Object construct(ConstructorInvocation invocation) 106 throws Throwable { 107 throw new Exception ("This wrapper does not support constructor wrapping"); 108 } 109 } 110 | Popular Tags |