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;
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 As of 6.1.0
033             */
034            @Deprecated
035            public GlobalDestinationEventListener(
036                    MessageListener messageListener, List<String> ignoredDestinations) {
037    
038                    _messageListener = messageListener;
039                    _ignoredDestinations = SetUtil.fromList(ignoredDestinations);
040            }
041    
042            @Override
043            public void destinationAdded(Destination destination) {
044                    if (!_ignoredDestinations.contains(destination.getName())) {
045                            destination.register(_messageListener);
046                    }
047            }
048    
049            @Override
050            public void destinationRemoved(Destination destination) {
051                    if (!_ignoredDestinations.contains(destination.getName())) {
052                            destination.unregister(_messageListener);
053                    }
054            }
055    
056            public void setIgnoredDestinations(List<String> ignoredDestinations) {
057                    _ignoredDestinations = SetUtil.fromList(ignoredDestinations);
058            }
059    
060            public void setMessageListener(MessageListener messageListener) {
061                    _messageListener = messageListener;
062            }
063    
064            private Set<String> _ignoredDestinations;
065            private MessageListener _messageListener;
066    
067    }