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 */ 017 package org.apache.activemq.command; 018 019 import org.apache.activemq.util.IntrospectionSupport; 020 021 /** 022 * Used to represent a durable subscription. 023 * 024 * @openwire:marshaller code="55" 025 * @version $Revision: 1.6 $ 026 */ 027 public class SubscriptionInfo implements DataStructure { 028 029 public static final byte DATA_STRUCTURE_TYPE = CommandTypes.DURABLE_SUBSCRIPTION_INFO; 030 031 protected ActiveMQDestination subscribedDestination; 032 protected ActiveMQDestination destination; 033 protected String clientId; 034 protected String subscriptionName; 035 protected String selector; 036 037 public byte getDataStructureType() { 038 return DATA_STRUCTURE_TYPE; 039 } 040 041 /** 042 * @openwire:property version=1 043 */ 044 public String getClientId() { 045 return clientId; 046 } 047 048 public void setClientId(String clientId) { 049 this.clientId = clientId; 050 } 051 052 /** 053 * This is the a resolved destination that the subscription is receiving 054 * messages from. This will never be a pattern or a composite destination. 055 * 056 * @openwire:property version=1 cache=true 057 */ 058 public ActiveMQDestination getDestination() { 059 return destination; 060 } 061 062 public void setDestination(ActiveMQDestination destination) { 063 this.destination = destination; 064 } 065 066 /** 067 * @openwire:property version=1 068 */ 069 public String getSelector() { 070 return selector; 071 } 072 073 public void setSelector(String selector) { 074 this.selector = selector; 075 } 076 077 /** 078 * @openwire:property version=1 079 * @deprecated 080 */ 081 public String getSubcriptionName() { 082 return subscriptionName; 083 } 084 085 /** 086 * @param subscriptionName * 087 * @deprecated 088 */ 089 public void setSubcriptionName(String subscriptionName) { 090 this.subscriptionName = subscriptionName; 091 } 092 093 public String getSubscriptionName() { 094 return subscriptionName; 095 } 096 097 public void setSubscriptionName(String subscriptionName) { 098 this.subscriptionName = subscriptionName; 099 } 100 101 public boolean isMarshallAware() { 102 return false; 103 } 104 105 public String toString() { 106 return IntrospectionSupport.toString(this); 107 } 108 109 public int hashCode() { 110 int h1 = clientId != null ? clientId.hashCode() : -1; 111 int h2 = subscriptionName != null ? subscriptionName.hashCode() : -1; 112 return h1 ^ h2; 113 } 114 115 public boolean equals(Object obj) { 116 boolean result = false; 117 if (obj instanceof SubscriptionInfo) { 118 SubscriptionInfo other = (SubscriptionInfo)obj; 119 result = (clientId == null && other.clientId == null || clientId != null 120 && other.clientId != null 121 && clientId.equals(other.clientId)) 122 && (subscriptionName == null && other.subscriptionName == null || subscriptionName != null 123 && other.subscriptionName != null 124 && subscriptionName 125 .equals(other.subscriptionName)); 126 } 127 return result; 128 } 129 130 /** 131 * The destination the client originally subscribed to.. This may not match 132 * the {@see getDestination} method if the subscribed destination uses 133 * patterns or composites. 134 * 135 * If the subscribed destinationis not set, this just ruturns the 136 * desitination. 137 * 138 * @openwire:property version=3 139 */ 140 public ActiveMQDestination getSubscribedDestination() { 141 if (subscribedDestination == null) { 142 return getDestination(); 143 } 144 return subscribedDestination; 145 } 146 147 public void setSubscribedDestination(ActiveMQDestination subscribedDestination) { 148 this.subscribedDestination = subscribedDestination; 149 } 150 151 }