|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| ClusterNotification.java | - | 0% | 0% | 0% |
|
||||||||||||||
| 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; | |
| 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="mailto:chris@swebtec.com">Chris Miller</a> | |
| 15 | * @author $Author: dres $ | |
| 16 | * @version $Revision: 254 $ | |
| 17 | */ | |
| 18 | public class ClusterNotification implements Serializable { | |
| 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 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 | 0 | public ClusterNotification(int type, Serializable data) { |
| 62 | 0 | this.type = type; |
| 63 | 0 | this.data = data; |
| 64 | } | |
| 65 | ||
| 66 | /** | |
| 67 | * Holds any additional data that was required | |
| 68 | */ | |
| 69 | 0 | public Serializable getData() { |
| 70 | 0 | return data; |
| 71 | } | |
| 72 | ||
| 73 | /** | |
| 74 | * The type of notification message. | |
| 75 | */ | |
| 76 | 0 | public int getType() { |
| 77 | 0 | return type; |
| 78 | } | |
| 79 | ||
| 80 | 0 | public String toString() { |
| 81 | 0 | StringBuffer buf = new StringBuffer(); |
| 82 | 0 | buf.append("type=").append(type).append(", data=").append(data); |
| 83 | ||
| 84 | 0 | return buf.toString(); |
| 85 | } | |
| 86 | } |
|
||||||||||