Package org.codehaus.activemq.service.boundedvm

Source Code of org.codehaus.activemq.service.boundedvm.TransientSubscription

/**
*
* Copyright 2004 Protique Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
**/

package org.codehaus.activemq.service.boundedvm;


import javax.jms.JMSException;
import org.codehaus.activemq.filter.Filter;
import org.codehaus.activemq.message.ActiveMQMessage;
import org.codehaus.activemq.message.ConsumerInfo;
import org.codehaus.activemq.message.ActiveMQDestination;
import org.codehaus.activemq.message.BrokerInfo;
import org.codehaus.activemq.broker.BrokerClient;
import org.codehaus.activemq.broker.BrokerConnector;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
* A holder for Transient  consumer info and message routing
*
* @version $Revision: 1.3 $
*/
public abstract class TransientSubscription  {
    protected Filter filter;
    protected ConsumerInfo consumerInfo;
    protected BrokerClient client;
    protected String brokerName;
    protected String clusterName;

    /**
     * Construct the TransientSubscription
     * @param filter
     * @param info
     */
    public TransientSubscription(Filter filter, ConsumerInfo info, BrokerClient client) {
        this.filter = filter;
        this.consumerInfo = info;
        this.client = client;
        if (client != null) {
            BrokerConnector connector = client.getBrokerConnector();
            if (connector != null) {
                BrokerInfo bi = connector.getBrokerInfo();
                if (bi != null) {
                    this.brokerName = bi.getBrokerName();
                    this.clusterName = bi.getClusterName();
                }
            }
        }
    }

   
    /**
     * determines if the Subscription is interested in the message
     *
     * @param message
     * @return true if this Subscription will accept the message
     * @throws JMSException
     */
    public abstract boolean isTarget(ActiveMQMessage message) throws JMSException;
  
    /**
     * @return Returns the consumerInfo.
     */
    public ConsumerInfo getConsumerInfo() {
        return consumerInfo;
    }
    /**
     * @param consumerInfo The consumerInfo to set.
     */
    public void setConsumerInfo(ConsumerInfo consumerInfo) {
        this.consumerInfo = consumerInfo;
    }
    /**
     * @return Returns the filter.
     */
    public Filter getFilter() {
        return filter;
    }
    /**
     * @param filter The filter to set.
     */
    public void setFilter(Filter filter) {
        this.filter = filter;
    }
   
    /**
     * close the subscription
     */
    public void close(){
    }

    /**
     * @return Returns the destination.
     */
    public ActiveMQDestination getDestination() {
        return consumerInfo.getDestination();
    }

    /**
     * @return true if this subscription is for a non-broker consumer
     */
    public boolean isLocalSubscription() {
        boolean localSubscription = true;
        if (client != null) {
            localSubscription = !(client.isClusteredConnection() || client.isBrokerConnection());
        }
        return localSubscription;
    }
}
TOP

Related Classes of org.codehaus.activemq.service.boundedvm.TransientSubscription

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.