001    /**
002     * Copyright (c) 2000-2013 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            public DefaultSingleDestinationMessageSender(
032                    String destinationName, MessageSender messageSender) {
033    
034                    _destinationName = destinationName;
035                    _messageSender = messageSender;
036            }
037    
038            @Override
039            public void send(Message message) {
040                    _messageSender.send(_destinationName, message);
041            }
042    
043            @Override
044            public void send(Object payload) {
045                    Message message = new Message();
046    
047                    message.setPayload(payload);
048    
049                    send(message);
050            }
051    
052            public void setDestinationName(String destinationName) {
053                    _destinationName = destinationName;
054            }
055    
056            public void setMessageSender(MessageSender messageSender) {
057                    _messageSender = messageSender;
058            }
059    
060            private String _destinationName;
061            private MessageSender _messageSender;
062    
063    }