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