EventRegistration.java 2.05 KB
Newer Older
Matt Tucker's avatar
Matt Tucker committed
1
/**
Matt Tucker's avatar
Matt Tucker committed
2 3 4 5
 * $RCSfile$
 * $Revision$
 * $Date$
 *
Matt Tucker's avatar
Matt Tucker committed
6
 * Copyright (C) 2004 Jive Software. All rights reserved.
Matt Tucker's avatar
Matt Tucker committed
7
 *
Matt Tucker's avatar
Matt Tucker committed
8 9
 * This software is published under the terms of the GNU Public License (GPL),
 * a copy of which is included in this distribution.
Matt Tucker's avatar
Matt Tucker committed
10
 */
Matt Tucker's avatar
Matt Tucker committed
11

Matt Tucker's avatar
Matt Tucker committed
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
package org.jivesoftware.messenger.container;

import java.io.Serializable;

/**
 * A class that groups all the information needed to manage an event
 * listener registration.
 *
 * @author Iain Shigeoka
 */
public abstract class EventRegistration implements Serializable {
    private long eventID;
    private long seqNumber;
    private Object sourceObject;
    /**
     * Serializable id. Increment whenever class signature changes.
     */
    private static final long serialVersionUID = 1;

    /**
     * Constructor
     *
     * @param id             The event ID for events associated with this registration
     * @param source         The source of the registration (the lookup)
     * @param sequenceNumber The current sequence number when registering
     */
    public EventRegistration(long id, Object source, long sequenceNumber) {
        eventID = id;
        this.sourceObject = source;
        this.seqNumber = sequenceNumber;
    }

    /**
     * Obtain the event ID that will be used with all events
     * generated using this registration.
     *
     * @return The event id for all events from this registration
     */
    public long getID() {
        return eventID;
    }

    /**
     * The sequence number current at the time of registration. Useful
     * for tracking future event notifications relative to the registration.
     *
     * @return The sequence number current at time of registration
     */
    public long getSequenceNumber() {
        return seqNumber;
    }

    /**
     * The source object that will be used for all events from this registration.
     *
     * @return The source object for events coming from this registration
     */
    public Object getSource() {
        return sourceObject;
    }

    /**
     * Cancels the event registration.
     */
    public abstract void cancel();
}