001/**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.activemq.advisory;
018
019import java.util.EventObject;
020
021import javax.jms.Destination;
022
023import org.apache.activemq.command.ProducerId;
024
025/**
026 * An event when the number of producers on a given destination changes.
027 * 
028 * 
029 */
030public abstract class ProducerEvent extends EventObject {
031    private static final long serialVersionUID = 2442156576867593780L;
032    private final Destination destination;
033    private final ProducerId producerId;
034    private final int producerCount;
035
036    public ProducerEvent(ProducerEventSource source, Destination destination, ProducerId producerId, int producerCount) {
037        super(source);
038        this.destination = destination;
039        this.producerId = producerId;
040        this.producerCount = producerCount;
041    }
042
043    public ProducerEventSource getAdvisor() {
044        return (ProducerEventSource) getSource();
045    }
046
047    public Destination getDestination() {
048        return destination;
049    }
050
051    /**
052     * Returns the current number of producers active at the time this advisory was sent.
053     * 
054     */
055    public int getProducerCount() {
056        return producerCount;
057    }
058
059    public ProducerId getProducerId() {
060        return producerId;
061    }
062
063    public abstract boolean isStarted();
064}