ServiceEvent.java 2.3 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 78
package org.jivesoftware.messenger.container;

import java.io.Serializable;

/**
 * Special events sent by service lookup to registered listeners to notifyEvent of
 * service registration changes. The extra information covers the service
 * that caused the change, and the transition that occured. Sequence numbers
 * are guaranteed to be sequential and increasing. Missing sequence numbers
 * indicate an event may have been missed (missing numbers may also indicate
 * that a remote server has crashed and recovered).
 *
 * @author Iain Shigeoka
 */
public class ServiceEvent extends Event {

    private int transition;
    private ServiceID serviceID;
    private ServiceItem item;

    /**
     * Create a service event.
     *
     * @param source the event source (service lookup).
     * @param eventID the event type.
     * @param sequenceNumber the sequence number.
     * @param payload the payload for the event.
     * @param id the id of the server that caused the event.
     * @param serviceItem the state of the service that caused the event.
     * @param eventTransition the transition that triggered the event.
     */
    public ServiceEvent(Object source, long eventID, long sequenceNumber,
        Serializable payload, ServiceItem serviceItem, ServiceID id, int eventTransition)
    {
        super(source, eventID, sequenceNumber, payload);
        this.transition = eventTransition;
        this.serviceID = id;
        this.item = serviceItem;
    }

    /**
     * Returns the transition that caused the event.
     *
     * @return The transition that caused the event
     */
    public int getTransition() {
        return transition;
    }

    /**
     * Returns the service id of the service that caused the event.
     *
     * @return The service id of the service that caused the event.
     */
    public ServiceID getServiceID() {
        return serviceID;
    }

    /**
     * Returns the state of the item that caused the event.
     *
     * @return The state of the item that caused the event.
     */
    public ServiceItem getServiceItem() {
        return item;
    }
}