KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > fjank > jcache > distribution > ClusterNotification


1 /* Open Source Java Caching Service
2 * Copyright (C) 2002 Frank Karlstrøm
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * The author can be contacted by email: fjankk@users.sourceforge.net
18 */

19 package org.fjank.jcache.distribution;
20
21 /**
22  * User: Philippe
23  * Date: Jun 7, 2004
24  * Time: 11:41:36 PM
25  */

26
27 import java.io.Serializable JavaDoc;
28
29 /**
30  * A notification message that holds information about a cache event. This
31  * class is <code>Serializable</code> to allow it to be sent across the
32  * network to other machines running in a cluster.
33  *
34  * @author <a HREF="&#109;a&#105;&#108;&#116;&#111;:chris&#64;swebtec.&#99;&#111;&#109;">Philippe Fajeau</a>
35  */

36 public class ClusterNotification implements Serializable JavaDoc
37 {
38     public static final int OBJECT_UPDATED = 1;
39     public static final int OBJECT_ADDED = 2;
40     public static final int OBJECT_INVALIDATED = 3;
41
42     /**
43      * Any additional data that may be required
44      */

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

50     protected int type;
51
52     protected String JavaDoc region;
53     protected String JavaDoc group;
54
55     /**
56      * Creates a new notification message object to broadcast to other
57      * listening nodes in the cluster.
58      *
59      * @param type The type of notification message.
60      * @param data Specifies the object key or group name to flush.
61      */

62     public ClusterNotification(String JavaDoc region,
63                                String JavaDoc group,
64                                int type,
65                                Serializable JavaDoc data)
66     {
67         this.type = type;
68         this.data = data;
69         this.region = region;
70         this.group = group;
71     }
72
73     /**
74      * Holds any additional data that was required
75      */

76     public Serializable JavaDoc getData()
77     {
78         return data;
79     }
80
81     /**
82      * The type of notification message.
83      */

84     public int getType()
85     {
86         return type;
87     }
88
89     public String JavaDoc getRegionName()
90     {
91         return region;
92     }
93
94     public String JavaDoc getGroupName()
95     {
96         return group;
97     }
98
99     public String JavaDoc toString()
100     {
101         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
102         buf.append("type=").append(type).append(", data=").append(data);
103
104         return buf.toString();
105     }
106 }
107
108
Popular Tags