1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
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  }