1 23 24 package org.apache.slide.event; 25 26 import java.util.EventListener ; 27 import java.util.EventObject ; 28 29 34 public class TransactionEvent extends EventObject { 35 public final static Begin BEGIN = new Begin(); 36 public final static Rollback ROLLBACK = new Rollback(); 37 public final static Commit COMMIT = new Commit(); 38 public final static Commited COMMITED = new Commited(); 39 40 public final static String GROUP = "transaction"; 41 public final static AbstractEventMethod[] methods = new AbstractEventMethod[] { BEGIN, ROLLBACK, COMMIT, COMMITED }; 42 43 public TransactionEvent(Object source) { 44 super(source); 45 } 46 47 public static class Begin extends EventMethod { 48 public Begin() { 49 super(GROUP, "begin"); 50 } 51 52 public void fireEvent(EventListener listener, EventObject event) { 53 if ( listener instanceof TransactionListener ) ((TransactionListener)listener).begin((TransactionEvent)event); 54 } 55 } 56 57 public static class Commit extends VetoableEventMethod { 58 public Commit() { 59 super(GROUP, "commit"); 60 } 61 62 public void fireVetaoableEvent(EventListener listener, EventObject event) throws VetoException { 63 if ( listener instanceof TransactionListener ) ((TransactionListener)listener).commit((TransactionEvent)event); 64 } 65 } 66 67 public static class Commited extends EventMethod { 68 public Commited() { 69 super(GROUP, "commited"); 70 } 71 72 public void fireEvent(EventListener listener, EventObject event) { 73 if ( listener instanceof TransactionListener ) ((TransactionListener)listener).commited((TransactionEvent)event); 74 } 75 } 76 77 public static class Rollback extends EventMethod { 78 public Rollback() { 79 super(GROUP, "rollback"); 80 } 81 82 public void fireEvent(EventListener listener, EventObject event) { 83 if ( listener instanceof TransactionListener ) ((TransactionListener)listener).rollback((TransactionEvent)event); 84 } 85 } 86 } | Popular Tags |