1 23 24 package org.apache.slide.event; 25 26 import java.util.EventObject ; 27 28 33 public class TransientEventCollector implements GlobalListener { 34 private static ThreadLocal eventCollection = new ThreadLocal (); 35 36 public void vetoableEventFired(VetoableEventMethod method, EventObject event) throws VetoException { 37 if ( eventCollection.get() != null ) { 38 ((EventCollection)eventCollection.get()).addEvent(method, event); 39 } 40 } 41 42 public void eventFired(EventMethod method, EventObject event) { 43 if ( method == TransactionEvent.BEGIN ) { 44 eventCollection.set(new EventCollection(this)); 45 } else if ( method == TransactionEvent.COMMITED ) { 46 final EventCollection collection = (EventCollection)eventCollection.get(); 47 new Thread (new Runnable () { 48 public void run() { 49 if ( EventCollection.COLLECTED.isEnabled() ) EventDispatcher.getInstance().fireEvent(EventCollection.COLLECTED, collection); 50 } 51 }).start(); 52 } else if ( eventCollection.get() != null ) { 53 ((EventCollection)eventCollection.get()).addEvent(method, event); 54 } 55 } 56 } | Popular Tags |