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;
16  
17  import com.liferay.portal.kernel.util.SetUtil;
18  
19  import java.util.List;
20  import java.util.Set;
21  
22  /**
23   * <a href="GlobalDestinationEventListener.java.html"><b><i>View Source</i></b>
24   * </a>
25   *
26   * @author Michael C. Han
27   */
28  public class GlobalDestinationEventListener
29      extends BaseDestinationEventListener {
30  
31      public GlobalDestinationEventListener() {
32      }
33  
34      /**
35       * @deprecated
36       */
37      public GlobalDestinationEventListener(
38          MessageListener messageListener, List<String> ignoredDestinations) {
39  
40          _messageListener = messageListener;
41          _ignoredDestinations = SetUtil.fromList(ignoredDestinations);
42      }
43  
44      public void destinationAdded(Destination destination) {
45          if (!_ignoredDestinations.contains(destination.getName())) {
46              destination.register(_messageListener);
47          }
48      }
49  
50      public void destinationRemoved(Destination destination) {
51          if (!_ignoredDestinations.contains(destination.getName())) {
52              destination.unregister(_messageListener);
53          }
54      }
55  
56      public void setIgnoredDestinations(List<String> ignoredDestinations) {
57          _ignoredDestinations = SetUtil.fromList(ignoredDestinations);
58      }
59  
60      public void setMessageListener(MessageListener messageListener) {
61          _messageListener = messageListener;
62      }
63  
64      private Set<String> _ignoredDestinations;
65      private MessageListener _messageListener;
66  
67  }