001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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    }