001package org.apache.commons.jcs3.auxiliary.remote.value; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import java.io.Serializable; 023 024/** 025 * This is the response wrapper. The servlet wraps all different type of responses in one of these 026 * objects. 027 */ 028public class RemoteCacheResponse<T> 029 implements Serializable 030{ 031 /** Don't change. */ 032 private static final long serialVersionUID = -8858447417390442568L; 033 034 /** Was the event processed without error */ 035 private boolean success = true; 036 037 /** Simple error messaging */ 038 private String errorMessage; 039 040 /** 041 * The payload. Typically a key / ICacheElement<K, V> map. A normal get will return a map with one 042 * record. 043 */ 044 private T payload; 045 046 /** 047 * @param success the success to set 048 */ 049 public void setSuccess( final boolean success ) 050 { 051 this.success = success; 052 } 053 054 /** 055 * @return the success 056 */ 057 public boolean isSuccess() 058 { 059 return success; 060 } 061 062 /** 063 * @param errorMessage the errorMessage to set 064 */ 065 public void setErrorMessage( final String errorMessage ) 066 { 067 this.errorMessage = errorMessage; 068 } 069 070 /** 071 * @return the errorMessage 072 */ 073 public String getErrorMessage() 074 { 075 return errorMessage; 076 } 077 078 /** 079 * @param payload the payload to set 080 */ 081 public void setPayload( final T payload ) 082 { 083 this.payload = payload; 084 } 085 086 /** 087 * @return the payload 088 */ 089 public T getPayload() 090 { 091 return payload; 092 } 093 094 /** @return string */ 095 @Override 096 public String toString() 097 { 098 final StringBuilder buf = new StringBuilder(); 099 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}