1 23 24 package org.apache.slide.event; 25 26 import org.apache.slide.common.SlideToken; 27 import org.apache.slide.common.Uri; 28 import org.apache.slide.common.Namespace; 29 30 import java.util.EventListener ; 31 import java.util.EventObject ; 32 33 38 public class LockEvent extends EventObject { 39 public final static Lock LOCK = new Lock(); 40 public final static Unlock UNLOCK = new Unlock(); 41 public final static Renew RENEW = new Renew(); 42 public final static Kill KILL = new Kill(); 43 44 public final static String GROUP = "lock"; 45 public final static AbstractEventMethod[] methods = new AbstractEventMethod[] { LOCK, UNLOCK, RENEW, KILL }; 46 47 private Uri objectUri; 48 private Namespace namespace; 49 private SlideToken token; 50 51 public LockEvent(Object source, SlideToken token, Namespace namespace, Uri objectUri) { 52 super(source); 53 this.objectUri = objectUri; 54 this.token = token; 55 this.namespace = namespace; 56 } 57 58 public String toString() { 59 StringBuffer buffer = new StringBuffer (256); 60 buffer.append(getClass().getName()).append("[lock uri=").append(objectUri); 61 buffer.append("]"); 62 return buffer.toString(); 63 } 64 65 public Namespace getNamespace() { 66 return namespace; 67 } 68 69 public SlideToken getToken() { 70 return token; 71 } 72 73 public final static class Lock extends VetoableEventMethod { 74 public Lock() { 75 super(GROUP, "lock"); 76 } 77 78 public void fireVetaoableEvent(EventListener listener, EventObject event) throws VetoException { 79 if ( listener instanceof LockListener ) ((LockListener)listener).lock((LockEvent)event); 80 } 81 } 82 83 public final static class Unlock extends VetoableEventMethod { 84 public Unlock() { 85 super(GROUP, "unlock"); 86 } 87 88 public void fireVetaoableEvent(EventListener listener, EventObject event) throws VetoException { 89 if ( listener instanceof LockListener ) ((LockListener)listener).unlock((LockEvent)event); 90 } 91 } 92 93 public final static class Renew extends VetoableEventMethod { 94 public Renew() { 95 super(GROUP, "renew"); 96 } 97 98 public void fireVetaoableEvent(EventListener listener, EventObject event) throws VetoException { 99 if ( listener instanceof LockListener ) ((LockListener)listener).renew((LockEvent)event); 100 } 101 } 102 103 public final static class Kill extends VetoableEventMethod { 104 public Kill() { 105 super(GROUP, "kill"); 106 } 107 108 public void fireVetaoableEvent(EventListener listener, EventObject event) throws VetoException { 109 if ( listener instanceof LockListener ) ((LockListener)listener).kill((LockEvent)event); 110 } 111 } 112 } | Popular Tags |