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; 023import java.util.Set; 024 025import org.apache.commons.jcs3.engine.behavior.ICacheElement; 026 027/** 028 * The basic request wrapper. The different types of requests are differentiated by their types. 029 * <p> 030 * Rather than creating sub object types, I created on object that has values for all types of 031 * requests. 032 */ 033public class RemoteCacheRequest<K, V> 034 implements Serializable 035{ 036 /** Don't change. */ 037 private static final long serialVersionUID = -8858447417390442569L; 038 039 /** The request type specifies the type of request: get, put, remove, . . */ 040 private RemoteRequestType requestType; 041 042 /** Used to identify the source. Same as listener id on the client side. */ 043 private long requesterId; 044 045 /** The name of the region */ 046 private String cacheName; 047 048 /** The key, if this request has a key. */ 049 private K key; 050 051 /** The keySet, if this request has a keySet. Only getMultiple requests. */ 052 private Set<K> keySet; 053 054 /** The pattern, if this request uses a pattern. Only getMatching requests. */ 055 private String pattern; 056 057 /** The ICacheEleemnt, if this request contains a value. Only update requests will have this. */ 058 private ICacheElement<K, V> cacheElement; 059 060 /** 061 * @param requestType the requestType to set 062 */ 063 public void setRequestType( final RemoteRequestType requestType ) 064 { 065 this.requestType = requestType; 066 } 067 068 /** 069 * @return the requestType 070 */ 071 public RemoteRequestType getRequestType() 072 { 073 return requestType; 074 } 075 076 /** 077 * @param cacheName the cacheName to set 078 */ 079 public void setCacheName( final String cacheName ) 080 { 081 this.cacheName = cacheName; 082 } 083 084 /** 085 * @return the cacheName 086 */ 087 public String getCacheName() 088 { 089 return cacheName; 090 } 091 092 /** 093 * @param key the key to set 094 */ 095 public void setKey( final K key ) 096 { 097 this.key = key; 098 } 099 100 /** 101 * @return the key 102 */ 103 public K getKey() 104 { 105 return key; 106 } 107 108 /** 109 * @param pattern the pattern to set 110 */ 111 public void setPattern( final String pattern ) 112 { 113 this.pattern = pattern; 114 } 115 116 /** 117 * @return the pattern 118 */ 119 public String getPattern() 120 { 121 return pattern; 122 } 123 124 /** 125 * @param cacheElement the cacheElement to set 126 */ 127 public void setCacheElement( final ICacheElement<K, V> cacheElement ) 128 { 129 this.cacheElement = cacheElement; 130 } 131 132 /** 133 * @return the cacheElement 134 */ 135 public ICacheElement<K, V> getCacheElement() 136 { 137 return cacheElement; 138 } 139 140 /** 141 * @param requesterId the requesterId to set 142 */ 143 public void setRequesterId( final long requesterId ) 144 { 145 this.requesterId = requesterId; 146 } 147 148 /** 149 * @return the requesterId 150 */ 151 public long getRequesterId() 152 { 153 return requesterId; 154 } 155 156 /** 157 * @param keySet the keySet to set 158 */ 159 public void setKeySet( final Set<K> keySet ) 160 { 161 this.keySet = keySet; 162 } 163 164 /** 165 * @return the keySet 166 */ 167 public Set<K> getKeySet() 168 { 169 return keySet; 170 } 171 172 /** @return string */ 173 @Override 174 public String toString() 175 { 176 final StringBuilder buf = new StringBuilder(); 177 buf.append( "\nRemoteHttpCacheRequest" ); 178 buf.append( "\n requesterId [" + getRequesterId() + "]" ); 179 buf.append( "\n requestType [" + getRequestType() + "]" ); 180 buf.append( "\n cacheName [" + getCacheName() + "]" ); 181 buf.append( "\n key [" + getKey() + "]" ); 182 buf.append( "\n keySet [" + getKeySet() + "]" ); 183 buf.append( "\n pattern [" + getPattern() + "]" ); 184 buf.append( "\n cacheElement [" + getCacheElement() + "]" ); 185 return buf.toString(); 186 } 187}