KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > slide > event > LockEvent


1 /*
2  * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/event/LockEvent.java,v 1.4 2004/07/28 09:36:23 ib Exp $
3  * $Revision: 1.4 $
4  * $Date: 2004/07/28 09:36:23 $
5  *
6  * ====================================================================
7  *
8  * Copyright 2004 The Apache Software Foundation
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */

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 JavaDoc;
31 import java.util.EventObject JavaDoc;
32
33 /**
34  * Lock event class
35  *
36  * @version $Revision: 1.4 $
37  */

38 public class LockEvent extends EventObject JavaDoc {
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 JavaDoc 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 JavaDoc 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 JavaDoc toString() {
59         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc(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 JavaDoc listener, EventObject JavaDoc 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 JavaDoc listener, EventObject JavaDoc 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 JavaDoc listener, EventObject JavaDoc 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 JavaDoc listener, EventObject JavaDoc event) throws VetoException {
109             if ( listener instanceof LockListener ) ((LockListener)listener).kill((LockEvent)event);
110         }
111     }
112 }
Popular Tags