001 /*
002 GRANITE DATA SERVICES
003 Copyright (C) 2012 GRANITE DATA SERVICES S.A.S.
004
005 This file is part of Granite Data Services.
006
007 Granite Data Services is free software; you can redistribute it and/or modify
008 it under the terms of the GNU Library General Public License as published by
009 the Free Software Foundation; either version 2 of the License, or (at your
010 option) any later version.
011
012 Granite Data Services is distributed in the hope that it will be useful, but
013 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
014 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
015 for more details.
016
017 You should have received a copy of the GNU Library General Public License
018 along with this library; if not, see <http://www.gnu.org/licenses/>.
019 */
020
021 package org.granite.client.messaging.messages.requests;
022
023 import java.util.Map;
024
025 import org.granite.client.messaging.messages.Message;
026
027 /**
028 * @author Franck WOLFF
029 */
030 public final class UnsubscribeMessage extends AbstractTopicRequestMessage {
031
032 private String subscriptionId = null;
033
034 public UnsubscribeMessage() {
035 }
036
037 public UnsubscribeMessage(String destination, String topic, String subscriptionId) {
038 this(null, destination, topic, subscriptionId);
039 }
040
041 public UnsubscribeMessage(String clientId, String destination, String topic, String subscriptionId) {
042 super(clientId, destination, topic);
043
044 this.subscriptionId = subscriptionId;
045 }
046
047 public UnsubscribeMessage(
048 String id,
049 String clientId,
050 long timestamp,
051 long timeToLive,
052 Map<String, Object> headers,
053 String destination,
054 String topic,
055 String subscriptionId) {
056
057 super(id, clientId, timestamp, timeToLive, headers, destination, topic);
058
059 this.subscriptionId = subscriptionId;
060 }
061
062 public String getSubscriptionId() {
063 return subscriptionId;
064 }
065
066 public void setSubscriptionId(String subscriptionId) {
067 this.subscriptionId = subscriptionId;
068 }
069
070 @Override
071 public Type getType() {
072 return Type.UNSUBSCRIBE;
073 }
074
075 @Override
076 public Message copy() {
077 UnsubscribeMessage message = new UnsubscribeMessage();
078
079 copy(message);
080
081 message.subscriptionId = subscriptionId;
082
083 return message;
084 }
085 }