1 22 package org.jboss.aspects.asynch; 23 24 import java.io.Externalizable ; 25 import java.io.IOException ; 26 import java.io.ObjectInput ; 27 import java.io.ObjectOutput ; 28 29 35 public class AsynchMixin implements FutureHolder, AsynchProvider, Externalizable 36 { 37 private static final long serialVersionUID = 3408652015381364191L; 38 39 private transient ThreadLocal currentFuture = new ThreadLocal (); 40 41 public AsynchMixin() 42 { 43 } 44 45 public void setFuture(Future future) 46 { 47 Future oldFuture = (Future) currentFuture.get(); 48 try 49 { 50 if (oldFuture != null) oldFuture.release(); 51 } 52 catch (Exception e) 53 { 54 } 56 currentFuture.set(future); 57 } 58 59 public Future getFuture() 60 { 61 Future future = (Future) currentFuture.get(); 62 currentFuture.set(null); 63 return future; 64 } 65 66 public void writeExternal(ObjectOutput out) throws IOException 67 { 68 69 } 70 71 public void readExternal(ObjectInput in) throws IOException , ClassNotFoundException 72 { 73 currentFuture = new ThreadLocal (); 74 } 75 } 76 | Popular Tags |