KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > oscache > plugins > clustersupport > ClusterNotification


1 /*
2  * Copyright (c) 2002-2003 by OpenSymphony
3  * All rights reserved.
4  */

5 package com.opensymphony.oscache.plugins.clustersupport;
6
7 import java.io.Serializable JavaDoc;
8
9 /**
10  * A notification message that holds information about a cache event. This
11  * class is <code>Serializable</code> to allow it to be sent across the
12  * network to other machines running in a cluster.
13  *
14  * @author <a HREF="&#109;a&#105;&#108;&#116;&#111;:chris&#64;swebtec.&#99;&#111;&#109;">Chris Miller</a>
15  * @author $Author: dres $
16  * @version $Revision: 1.1 $
17  */

18 public class ClusterNotification implements Serializable JavaDoc {
19     /**
20      * Specifies a notification message that indicates a particular cache key
21      * should be flushed.
22      */

23     public static final int FLUSH_KEY = 1;
24
25     /**
26      * Specifies a notification message that indicates an entire cache group
27      * should be flushed.
28      */

29     public static final int FLUSH_GROUP = 2;
30
31     /**
32      * Specifies a notification message that indicates all entries in the cache
33      * that match the specified pattern should be flushed.
34      */

35     public static final int FLUSH_PATTERN = 3;
36
37     /**
38      * Specifies a notification message indicating that an entire cache should
39      * be flushed.
40      */

41     public static final int FLUSH_CACHE = 4;
42
43     /**
44      * Any additional data that may be required
45      */

46     protected Serializable JavaDoc data;
47
48     /**
49      * The type of notification message.
50      */

51     protected int type;
52
53     /**
54      * Creates a new notification message object to broadcast to other
55      * listening nodes in the cluster.
56      *
57      * @param type The type of notification message. Valid types are
58      * {@link #FLUSH_KEY} and {@link #FLUSH_GROUP}.
59      * @param data Specifies the object key or group name to flush.
60      */

61     public ClusterNotification(int type, Serializable JavaDoc data) {
62         this.type = type;
63         this.data = data;
64     }
65
66     /**
67      * Holds any additional data that was required
68      */

69     public Serializable JavaDoc getData() {
70         return data;
71     }
72
73     /**
74      * The type of notification message.
75      */

76     public int getType() {
77         return type;
78     }
79
80     public String JavaDoc toString() {
81         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
82         buf.append("type=").append(type).append(", data=").append(data);
83
84         return buf.toString();
85     }
86 }
87
Popular Tags