View Javadoc
1   package org.apache.commons.jcs.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 org.apache.commons.jcs.engine.behavior.ICacheElement;
23  
24  import java.io.Serializable;
25  import java.util.Set;
26  
27  /**
28   * The basic request wrapper. The different types of requests are differentiated by their types.
29   * <p>
30   * Rather than creating sub object types, I created on object that has values for all types of
31   * requests.
32   */
33  public class RemoteCacheRequest<K, V>
34      implements Serializable
35  {
36      /** Don't change. */
37      private static final long serialVersionUID = -8858447417390442569L;
38  
39      /** The request type specifies the type of request: get, put, remove, . . */
40      private RemoteRequestType requestType = null;
41  
42      /** Used to identify the source. Same as listener id on the client side. */
43      private long requesterId = 0;
44  
45      /** The name of the region */
46      private String cacheName;
47  
48      /** The key, if this request has a key. */
49      private K key;
50  
51      /** The keySet, if this request has a keySet. Only getMultiple requests. */
52      private Set<K> keySet;
53  
54      /** The pattern, if this request uses a pattern. Only getMatching requests. */
55      private String pattern;
56  
57      /** The ICacheEleemnt, if this request contains a value. Only update requests will have this. */
58      private ICacheElement<K, V> cacheElement;
59  
60      /**
61       * @param requestType the requestType to set
62       */
63      public void setRequestType( RemoteRequestType requestType )
64      {
65          this.requestType = requestType;
66      }
67  
68      /**
69       * @return the requestType
70       */
71      public RemoteRequestType getRequestType()
72      {
73          return requestType;
74      }
75  
76      /**
77       * @param cacheName the cacheName to set
78       */
79      public void setCacheName( String cacheName )
80      {
81          this.cacheName = cacheName;
82      }
83  
84      /**
85       * @return the cacheName
86       */
87      public String getCacheName()
88      {
89          return cacheName;
90      }
91  
92      /**
93       * @param key the key to set
94       */
95      public void setKey( K key )
96      {
97          this.key = key;
98      }
99  
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( 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( 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( 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( 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         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 }