KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jcorporate > expresso > core > misc > CacheEvent


1 /* ====================================================================
2  * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
3  *
4  * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  *
18  * 3. The end-user documentation included with the redistribution,
19  * if any, must include the following acknowledgment:
20  * "This product includes software developed by Jcorporate Ltd.
21  * (http://www.jcorporate.com/)."
22  * Alternately, this acknowledgment may appear in the software itself,
23  * if and wherever such third-party acknowledgments normally appear.
24  *
25  * 4. "Jcorporate" and product names such as "Expresso" must
26  * not be used to endorse or promote products derived from this
27  * software without prior written permission. For written permission,
28  * please contact info@jcorporate.com.
29  *
30  * 5. Products derived from this software may not be called "Expresso",
31  * or other Jcorporate product names; nor may "Expresso" or other
32  * Jcorporate product names appear in their name, without prior
33  * written permission of Jcorporate Ltd.
34  *
35  * 6. No product derived from this software may compete in the same
36  * market space, i.e. framework, without prior written permission
37  * of Jcorporate Ltd. For written permission, please contact
38  * partners@jcorporate.com.
39  *
40  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
41  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
42  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
43  * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
44  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
45  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
46  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
47  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
48  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
49  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
50  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51  * SUCH DAMAGE.
52  * ====================================================================
53  *
54  * This software consists of voluntary contributions made by many
55  * individuals on behalf of the Jcorporate Ltd. Contributions back
56  * to the project(s) are encouraged when you make modifications.
57  * Please send them to support@jcorporate.com. For more information
58  * on Jcorporate Ltd. and its products, please see
59  * <http://www.jcorporate.com/>.
60  *
61  * Portions of this software are based upon other open source
62  * products and are subject to their respective licenses.
63  */

64
65 package com.jcorporate.expresso.core.misc;
66
67 /*
68  * CacheEvent.java
69  *
70  * Copyright 2000, 2001 Jcorporate Ltd.
71  */

72
73 import com.jcorporate.expresso.core.cache.Cacheable;
74
75
76 /**
77  * CacheEvent represents an event that indicates that some cached information
78  * might have to be updated. Objects that implement caches that depend on
79  * persistant data should implement CacheEventListener, and register themselves
80  * with the appropriate objects that store the data they cache - they will
81  * then be notified via a cacheEvent(CacheEvent) call when changes to the
82  * data occurr, so they can take the appropriate action to ensure their
83  * caches are not 'stale'.
84  *
85  * @author Michael Nash
86  */

87 public class CacheEvent {
88
89     /**
90      * Name of the object that originated the event
91      */

92     private String JavaDoc eventOriginator = null;
93
94     /**
95      * Code indicating the nature of the event - meaning depends on object
96      */

97     private String JavaDoc eventCode = null;
98
99     /**
100      * Reference to the object that caused the event
101      */

102     private Cacheable eventObject = null;
103
104     /**
105      * The configKey for this event - "default" if not specified
106      */

107     private String JavaDoc configKey = ("default");
108
109     /**
110      *
111      */

112     public CacheEvent() {
113     } /* CacheEvent() */
114
115     /**
116      * Convenience constructor to create a CacheEvent with the originator
117      * and event code immediately specified
118      *
119      * @param newEventOriginator
120      * @param newEventCode
121      */

122     public CacheEvent(String JavaDoc newEventOriginator, String JavaDoc newEventCode) {
123         setOriginator(newEventOriginator);
124         setCode(newEventCode);
125     } /* CacheEvent(String, String) */
126
127     /**
128      * Convenience constructor to create a CacheEvent with the originator,
129      * event code and originating object immediately specified
130      *
131      * @param newEventOriginator
132      * @param newEventCode
133      * @param newEventObject
134      */

135     public CacheEvent(String JavaDoc newEventOriginator, String JavaDoc newEventCode,
136                       Cacheable newEventObject) {
137         setOriginator(newEventOriginator);
138         setCode(newEventCode);
139         setObject(newEventObject);
140     } /* CacheEvent(String, String, Cacheable) */
141
142     /**
143      * Get the "event code" passed to this event - the exact meaning
144      * of the code is dependant on the object generating the event.
145      *
146      * @return The event code specifying what kind of event has occurred.
147      * The exact meaning depends on the originating object.
148      */

149     public String JavaDoc getCode() {
150         return eventCode;
151     } /* getCode() */
152
153     /**
154      * Get the config key passed to this event, or return "default" if none specified
155      *
156      * @return
157      */

158     public String JavaDoc getConfigKey() {
159         return configKey;
160     } /* getConfigKey() */
161
162     /**
163      * Get the object reference to the object that generated the event
164      *
165      * @return The object reference to the Object that triggered the event
166      */

167     public Cacheable getObject() {
168         return eventObject;
169     } /* getObject() */
170
171     /**
172      * Return the name of the class originating this event
173      *
174      * @return The class name of the object that originated this event
175      */

176     public String JavaDoc getOriginator() {
177         return eventOriginator;
178     } /* getOriginator() */
179
180     /**
181      * Set the event code for this event - meaning depends on the originating
182      * object
183      *
184      * @param newEventCode A string representing what type of event
185      * has occurred (e.g. an update, delete, etc). Exact meaning is determined
186      * by the originating object
187      */

188     public void setCode(String JavaDoc newEventCode) {
189         eventCode = newEventCode;
190     } /* setCode(string) */
191
192     /**
193      * @param newConfigKey
194      */

195     public void setConfigKey(String JavaDoc newConfigKey) {
196         configKey = newConfigKey;
197     } /* setConfigKey(string) */
198
199     /**
200      * Set the originating object reference for this event
201      *
202      * @param newObject A reference to the object that generated this event
203      */

204     public void setObject(Cacheable newObject) {
205         eventObject = newObject;
206     } /* setObject(Cacheable) */
207
208     /**
209      * Set the class name of the event originator
210      *
211      * @param newEventOriginator The class name of the object that has
212      * triggered this event
213      */

214     public void setOriginator(String JavaDoc newEventOriginator) {
215         eventOriginator = newEventOriginator;
216     } /* setOriginator(String) */
217
218 } /* CacheEvent */
219
Popular Tags