1 package org.apache.commons.jcs3.auxiliary.remote.value; 2 3 /* 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 */ 21 22 import java.io.Serializable; 23 24 /** 25 * This is the response wrapper. The servlet wraps all different type of responses in one of these 26 * objects. 27 */ 28 public class RemoteCacheResponse<T> 29 implements Serializable 30 { 31 /** Don't change. */ 32 private static final long serialVersionUID = -8858447417390442568L; 33 34 /** Was the event processed without error */ 35 private boolean success = true; 36 37 /** Simple error messaging */ 38 private String errorMessage; 39 40 /** 41 * The payload. Typically a key / ICacheElement<K, V> map. A normal get will return a map with one 42 * record. 43 */ 44 private T payload; 45 46 /** 47 * @param success the success to set 48 */ 49 public void setSuccess( final boolean success ) 50 { 51 this.success = success; 52 } 53 54 /** 55 * @return the success 56 */ 57 public boolean isSuccess() 58 { 59 return success; 60 } 61 62 /** 63 * @param errorMessage the errorMessage to set 64 */ 65 public void setErrorMessage( final String errorMessage ) 66 { 67 this.errorMessage = errorMessage; 68 } 69 70 /** 71 * @return the errorMessage 72 */ 73 public String getErrorMessage() 74 { 75 return errorMessage; 76 } 77 78 /** 79 * @param payload the payload to set 80 */ 81 public void setPayload( final T payload ) 82 { 83 this.payload = payload; 84 } 85 86 /** 87 * @return the payload 88 */ 89 public T getPayload() 90 { 91 return payload; 92 } 93 94 /** @return string */ 95 @Override 96 public String toString() 97 { 98 final StringBuilder buf = new StringBuilder(); 99 buf.append( "\nRemoteHttpCacheResponse" ); 100 buf.append( "\n success [" + isSuccess() + "]" ); 101 buf.append( "\n payload [" + getPayload() + "]" ); 102 buf.append( "\n errorMessage [" + getErrorMessage() + "]" ); 103 return buf.toString(); 104 } 105 }