001    /**
002     * Copyright (c) 2000-2013 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.cluster;
016    
017    import java.io.Serializable;
018    
019    import java.util.Arrays;
020    import java.util.List;
021    
022    /**
023     * @author Tina Tian
024     */
025    public class ClusterEvent implements Serializable {
026    
027            public static ClusterEvent depart(ClusterNode... clusterNodes) {
028                    return new ClusterEvent(
029                            ClusterEventType.DEPART, Arrays.asList(clusterNodes));
030            }
031    
032            public static ClusterEvent depart(List<ClusterNode> clusterNodes) {
033                    return new ClusterEvent(ClusterEventType.DEPART, clusterNodes);
034            }
035    
036            public static ClusterEvent join(ClusterNode... clusterNodes) {
037                    return new ClusterEvent(
038                            ClusterEventType.JOIN, Arrays.asList(clusterNodes));
039            }
040    
041            public static ClusterEvent join(List<ClusterNode> clusterNodes) {
042                    return new ClusterEvent(ClusterEventType.JOIN, clusterNodes);
043            }
044    
045            public ClusterEvent(ClusterEventType clusterEventType) {
046                    _clusterEventType = clusterEventType;
047            }
048    
049            public ClusterEvent(
050                    ClusterEventType clusterEventType, List<ClusterNode> clusterNodes) {
051    
052                    _clusterEventType = clusterEventType;
053                    _clusterNodes = clusterNodes;
054            }
055    
056            public ClusterEventType getClusterEventType() {
057                    return _clusterEventType;
058            }
059    
060            public List<ClusterNode> getClusterNodes() {
061                    return _clusterNodes;
062            }
063    
064            public void setClusterNodes(List<ClusterNode> clusterNodes) {
065                    _clusterNodes = clusterNodes;
066            }
067    
068            private ClusterEventType _clusterEventType;
069            private List<ClusterNode> _clusterNodes;
070    
071    }