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.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    }