001    /**
002     * Copyright (c) 2000-2010 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 com.liferay.portal.kernel.util.StringBundler;
018    
019    import java.io.Serializable;
020    
021    /**
022     * @author Tina Tian
023     */
024    public class ClusterNodeResponse implements Serializable {
025    
026            public ClusterMessageType getClusterMessageType() {
027                    return _clusterMessageType;
028            }
029    
030            public ClusterNode getClusterNode() {
031                    return _clusterNode;
032            }
033    
034            public Exception getException() {
035                    return _exception;
036            }
037    
038            public Object getResult() throws Exception {
039                    if (_exception != null) {
040                            throw _exception;
041                    }
042    
043                    return _result;
044            }
045    
046            public String getUuid() {
047                    return _uuid;
048            }
049    
050            public boolean hasException() {
051                    if (_exception != null) {
052                            return true;
053                    }
054                    else {
055                            return false;
056                    }
057            }
058    
059            public boolean isMulticast() {
060                    return _multicast;
061            }
062    
063            public void setClusterMessageType(ClusterMessageType clusterMessageType) {
064                    _clusterMessageType = clusterMessageType;
065            }
066    
067            public void setClusterNode(ClusterNode clusterNode) {
068                    _clusterNode = clusterNode;
069            }
070    
071            public void setException(Exception exception) {
072                    _exception = exception;
073            }
074    
075            public void setMulticast(boolean multicast) {
076                    _multicast = multicast;
077            }
078    
079            public void setResult(Object result) {
080                    _result = result;
081            }
082    
083            public void setUuid(String uuid) {
084                    _uuid = uuid;
085            }
086    
087            public String toString() {
088                    StringBundler sb = new StringBundler(9);
089    
090                    sb.append("{clusterMessageType=");
091                    sb.append(_clusterMessageType);
092                    sb.append(", multicast=");
093                    sb.append(_multicast);
094                    sb.append(", uuid=");
095                    sb.append(_uuid);
096    
097                    if (_clusterMessageType.equals(ClusterMessageType.NOTIFY) ||
098                            _clusterMessageType.equals(ClusterMessageType.UPDATE)) {
099    
100                            sb.append(", clusterNode=");
101                            sb.append(_clusterNode);
102                    }
103                    else {
104                            if (hasException()) {
105                                    sb.append(", exception=");
106                                    sb.append(_exception);
107                            }
108                            else {
109                                    sb.append(", result=");
110                                    sb.append(_result);
111                            }
112                    }
113    
114                    sb.append("}");
115    
116                    return sb.toString();
117            }
118    
119            private ClusterMessageType _clusterMessageType;
120            private ClusterNode _clusterNode;
121            private Exception _exception;
122            private boolean _multicast;
123            private Object _result;
124            private String _uuid;
125    
126    }