| /** |
| * Licensed to the Apache Software Foundation (ASF) under one or more |
| * contributor license agreements. See the NOTICE file distributed with |
| * this work for additional information regarding copyright ownership. |
| * The ASF licenses this file to You 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.apache.activemq.openwire.commands; |
| |
| import org.apache.activemq.openwire.annotations.OpenWireType; |
| import org.apache.activemq.openwire.annotations.OpenWireProperty; |
| |
| /** |
| * Used to represent a durable subscription. |
| * |
| * @openwire:marshaller code="55" |
| */ |
| @OpenWireType(typeCode = 55) |
| public class SubscriptionInfo implements DataStructure { |
| |
| public static final byte DATA_STRUCTURE_TYPE = CommandTypes.DURABLE_SUBSCRIPTION_INFO; |
| |
| @OpenWireProperty(version = 1, sequence = 1) |
| protected String clientId; |
| |
| @OpenWireProperty(version = 1, sequence = 2, cached = true) |
| protected OpenWireDestination destination; |
| |
| @OpenWireProperty(version = 1, sequence = 3) |
| protected String selector; |
| |
| @OpenWireProperty(version = 1, sequence = 4) |
| protected String subscriptionName; |
| |
| @OpenWireProperty(version = 3, sequence = 5) |
| protected OpenWireDestination subscribedDestination; |
| |
| @OpenWireProperty(version = 11, sequence = 6) |
| protected boolean noLocal; |
| |
| public SubscriptionInfo() { |
| } |
| |
| public SubscriptionInfo(String clientId, String subscriptionName) { |
| this.clientId = clientId; |
| this.subscriptionName = subscriptionName; |
| } |
| |
| @Override |
| public byte getDataStructureType() { |
| return DATA_STRUCTURE_TYPE; |
| } |
| |
| /** |
| * @openwire:property version=1 |
| */ |
| public String getClientId() { |
| return clientId; |
| } |
| |
| public void setClientId(String clientId) { |
| this.clientId = clientId; |
| } |
| |
| /** |
| * This is the a resolved destination that the subscription is receiving messages from. This |
| * will never be a pattern or a composite destination. |
| * |
| * @openwire:property version=1 cache=true |
| */ |
| public OpenWireDestination getDestination() { |
| return destination; |
| } |
| |
| public void setDestination(OpenWireDestination destination) { |
| this.destination = destination; |
| } |
| |
| /** |
| * @openwire:property version=1 |
| */ |
| public String getSelector() { |
| return selector; |
| } |
| |
| public void setSelector(String selector) { |
| this.selector = selector; |
| } |
| |
| /** |
| * @openwire:property version=1 |
| */ |
| public String getSubcriptionName() { |
| return subscriptionName; |
| } |
| |
| /** |
| * @param subscriptionName |
| * * |
| */ |
| public void setSubcriptionName(String subscriptionName) { |
| this.subscriptionName = subscriptionName; |
| } |
| |
| public String getSubscriptionName() { |
| return subscriptionName; |
| } |
| |
| public void setSubscriptionName(String subscriptionName) { |
| this.subscriptionName = subscriptionName; |
| } |
| |
| @Override |
| public boolean isMarshallAware() { |
| return false; |
| } |
| |
| @Override |
| public String toString() { |
| return getClass().getSimpleName() + " { " + destination + " }"; |
| } |
| |
| @Override |
| public int hashCode() { |
| int h1 = clientId != null ? clientId.hashCode() : -1; |
| int h2 = subscriptionName != null ? subscriptionName.hashCode() : -1; |
| return h1 ^ h2; |
| } |
| |
| @Override |
| public boolean equals(Object obj) { |
| boolean result = false; |
| if (obj instanceof SubscriptionInfo) { |
| SubscriptionInfo other = (SubscriptionInfo) obj; |
| result = (clientId == null && other.clientId == null || |
| clientId != null && other.clientId != null && clientId.equals(other.clientId)) && |
| (subscriptionName == null && other.subscriptionName == null || |
| subscriptionName != null && other.subscriptionName != null && subscriptionName.equals(other.subscriptionName)); |
| } |
| return result; |
| } |
| |
| /** |
| * The destination the client originally subscribed to.. This may not match the {@see |
| * getDestination} method if the subscribed destination uses patterns or composites. |
| * |
| * If the subscribed destinations not set, this just returns the destination. |
| * |
| * @openwire:property version=3 |
| */ |
| public OpenWireDestination getSubscribedDestination() { |
| if (subscribedDestination == null) { |
| return getDestination(); |
| } |
| return subscribedDestination; |
| } |
| |
| public void setSubscribedDestination(OpenWireDestination subscribedDestination) { |
| this.subscribedDestination = subscribedDestination; |
| } |
| |
| /** |
| * @openwire:property version=11 |
| */ |
| public boolean isNoLocal() { |
| return noLocal; |
| } |
| |
| public void setNoLocal(boolean noLocal) { |
| this.noLocal = noLocal; |
| } |
| } |