001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.messaging.sender;
016    
017    import com.liferay.portal.kernel.messaging.Message;
018    
019    /**
020     * @author Michael C. Han
021     */
022    public class DefaultSingleDestinationMessageSender
023            implements SingleDestinationMessageSender {
024    
025            public DefaultSingleDestinationMessageSender() {
026            }
027    
028            /**
029             * @deprecated As of 6.1.0
030             */
031            @Deprecated
032            public DefaultSingleDestinationMessageSender(
033                    String destinationName, MessageSender messageSender) {
034    
035                    _destinationName = destinationName;
036                    _messageSender = messageSender;
037            }
038    
039            @Override
040            public void send(Message message) {
041                    _messageSender.send(_destinationName, message);
042            }
043    
044            @Override
045            public void send(Object payload) {
046                    Message message = new Message();
047    
048                    message.setPayload(payload);
049    
050                    send(message);
051            }
052    
053            public void setDestinationName(String destinationName) {
054                    _destinationName = destinationName;
055            }
056    
057            public void setMessageSender(MessageSender messageSender) {
058                    _messageSender = messageSender;
059            }
060    
061            private String _destinationName;
062            private MessageSender _messageSender;
063    
064    }