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 SubscribeMessage extends AbstractTopicRequestMessage {
031
032 private String selector = null;
033
034 public SubscribeMessage() {
035 }
036
037 public SubscribeMessage(String destination, String topic, String selector) {
038 this(null, destination, topic, selector);
039 }
040
041 public SubscribeMessage(String clientId, String destination, String topic, String selector) {
042 super(clientId, destination, topic);
043
044 this.selector = selector;
045 }
046
047 public SubscribeMessage(
048 String id,
049 String clientId,
050 long timestamp,
051 long timeToLive,
052 Map<String, Object> headers,
053 String destination, String topic,
054 String selector) {
055
056 super(id, clientId, timestamp, timeToLive, headers, destination, topic);
057
058 this.selector = selector;
059 }
060
061 public String getSelector() {
062 return selector;
063 }
064
065 public void setSelector(String selector) {
066 this.selector = selector;
067 }
068
069 @Override
070 public Type getType() {
071 return Type.SUBSCRIBE;
072 }
073
074 @Override
075 public Message copy() {
076 SubscribeMessage message = new SubscribeMessage();
077
078 copy(message);
079
080 message.selector = selector;
081
082 return message;
083 }
084 }