001    /**
002     * Copyright (c) 2000-2010 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;
016    
017    import com.liferay.portal.kernel.util.SetUtil;
018    
019    import java.util.List;
020    import java.util.Set;
021    
022    /**
023     * @author Michael C. Han
024     */
025    public class GlobalDestinationEventListener
026            extends BaseDestinationEventListener {
027    
028            public GlobalDestinationEventListener() {
029            }
030    
031            /**
032             * @deprecated
033             */
034            public GlobalDestinationEventListener(
035                    MessageListener messageListener, List<String> ignoredDestinations) {
036    
037                    _messageListener = messageListener;
038                    _ignoredDestinations = SetUtil.fromList(ignoredDestinations);
039            }
040    
041            public void destinationAdded(Destination destination) {
042                    if (!_ignoredDestinations.contains(destination.getName())) {
043                            destination.register(_messageListener);
044                    }
045            }
046    
047            public void destinationRemoved(Destination destination) {
048                    if (!_ignoredDestinations.contains(destination.getName())) {
049                            destination.unregister(_messageListener);
050                    }
051            }
052    
053            public void setIgnoredDestinations(List<String> ignoredDestinations) {
054                    _ignoredDestinations = SetUtil.fromList(ignoredDestinations);
055            }
056    
057            public void setMessageListener(MessageListener messageListener) {
058                    _messageListener = messageListener;
059            }
060    
061            private Set<String> _ignoredDestinations;
062            private MessageListener _messageListener;
063    
064    }