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    import com.liferay.portal.kernel.messaging.MessageBusException;
019    
020    /**
021     * @author Michael C. Han
022     */
023    public class DefaultSingleDestinationSynchronousMessageSender
024            implements SingleDestinationSynchronousMessageSender {
025    
026            public DefaultSingleDestinationSynchronousMessageSender() {
027            }
028    
029            /**
030             * @deprecated As of 6.1.0
031             */
032            @Deprecated
033            public DefaultSingleDestinationSynchronousMessageSender(
034                    String destinationName,
035                    SynchronousMessageSender synchronousMessageSender) {
036    
037                    _destinationName = destinationName;
038                    _synchronousMessageSender = synchronousMessageSender;
039            }
040    
041            @Override
042            public Object send(Message message) throws MessageBusException {
043                    return _synchronousMessageSender.send(_destinationName, message);
044            }
045    
046            @Override
047            public Object send(Message message, long timeout)
048                    throws MessageBusException {
049    
050                    return _synchronousMessageSender.send(
051                            _destinationName, message, timeout);
052            }
053    
054            @Override
055            public Object send(Object payload) throws MessageBusException {
056                    Message message = new Message();
057    
058                    message.setPayload(payload);
059    
060                    return send(message);
061            }
062    
063            @Override
064            public Object send(Object payload, long timeout)
065                    throws MessageBusException {
066    
067                    Message message = new Message();
068    
069                    message.setPayload(payload);
070    
071                    return send(message, timeout);
072            }
073    
074            public void setDestinationName(String destinationName) {
075                    _destinationName = destinationName;
076            }
077    
078            public void setSynchronousMessageSender(
079                    SynchronousMessageSender synchronousMessageSender) {
080    
081                    _synchronousMessageSender = synchronousMessageSender;
082            }
083    
084            private String _destinationName;
085            private SynchronousMessageSender _synchronousMessageSender;
086    
087    }