1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.kernel.messaging.sender;
16  
17  import com.liferay.portal.kernel.messaging.Message;
18  import com.liferay.portal.kernel.messaging.MessageBusException;
19  
20  /**
21   * <a href="DefaultSingleDestinationSynchronousMessageSender.java.html"><b>
22   * <i>View Source</i></b></a>
23   *
24   * @author Michael C. Han
25   */
26  public class DefaultSingleDestinationSynchronousMessageSender
27      implements SingleDestinationSynchronousMessageSender {
28  
29      public DefaultSingleDestinationSynchronousMessageSender() {
30      }
31  
32      /**
33       * @deprecated
34       */
35      public DefaultSingleDestinationSynchronousMessageSender(
36          String destinationName,
37          SynchronousMessageSender synchronousMessageSender) {
38  
39          _destinationName = destinationName;
40          _synchronousMessageSender = synchronousMessageSender;
41      }
42  
43      public Object send(Message message) throws MessageBusException {
44          return _synchronousMessageSender.send(_destinationName, message);
45      }
46  
47      public Object send(Message message, long timeout)
48          throws MessageBusException {
49  
50          return _synchronousMessageSender.send(
51              _destinationName, message, timeout);
52      }
53  
54      public Object send(Object payload) throws MessageBusException {
55          Message message = new Message();
56  
57          message.setPayload(payload);
58  
59          return send(message);
60      }
61  
62      public Object send(Object payload, long timeout)
63          throws MessageBusException {
64  
65          Message message = new Message();
66  
67          message.setPayload(payload);
68  
69          return send(message, timeout);
70      }
71  
72      public void setDestinationName(String destinationName) {
73          _destinationName = destinationName;
74      }
75  
76      public void setSynchronousMessageSender(
77          SynchronousMessageSender synchronousMessageSender) {
78  
79          _synchronousMessageSender = synchronousMessageSender;
80      }
81  
82      private String _destinationName;
83      private SynchronousMessageSender _synchronousMessageSender;
84  
85  }