1 package org.apache.jcs.auxiliary.remote.http.client;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.IOException;
23 import java.io.Serializable;
24
25 import org.apache.commons.logging.Log;
26 import org.apache.commons.logging.LogFactory;
27 import org.apache.jcs.auxiliary.remote.AbstractRemoteAuxiliaryCache;
28 import org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheListener;
29 import org.apache.jcs.engine.ZombieCacheServiceNonLocal;
30 import org.apache.jcs.engine.behavior.ICacheServiceNonLocal;
31
32
33
34
35 public class RemoteHttpCache<K extends Serializable, V extends Serializable>
36 extends AbstractRemoteAuxiliaryCache<K, V>
37 {
38
39 private static final long serialVersionUID = -5329231850422826461L;
40
41
42 private final static Log log = LogFactory.getLog( RemoteHttpCache.class );
43
44
45 private RemoteHttpCacheAttributes remoteHttpCacheAttributes;
46
47
48
49
50
51
52
53
54
55
56
57 public RemoteHttpCache( RemoteHttpCacheAttributes remoteHttpCacheAttributes, ICacheServiceNonLocal<K, V> remote,
58 IRemoteCacheListener<K, V> listener )
59 {
60 super( remoteHttpCacheAttributes, remote, listener );
61
62 setRemoteHttpCacheAttributes( remoteHttpCacheAttributes );
63 }
64
65
66
67
68
69
70
71
72
73 @Override
74 protected void handleException( Exception ex, String msg, String eventName )
75 throws IOException
76 {
77
78 if ( !( getRemoteCacheService() instanceof ZombieCacheServiceNonLocal ) )
79 {
80 String message = "Disabling remote cache due to error: " + msg;
81 logError( cacheName, "", message );
82 log.error( message, ex );
83
84 setRemoteCacheService( new ZombieCacheServiceNonLocal<K, V>( getRemoteCacheAttributes().getZombieQueueMaxSize() ) );
85
86 RemoteHttpCacheMonitor.getInstance().notifyError( this );
87 }
88
89 if ( ex instanceof IOException )
90 {
91 throw (IOException) ex;
92 }
93 throw new IOException( ex.getMessage() );
94 }
95
96
97
98
99 @Override
100 public String getEventLoggingExtraInfo()
101 {
102 return null;
103 }
104
105
106
107
108 public void setRemoteHttpCacheAttributes( RemoteHttpCacheAttributes remoteHttpCacheAttributes )
109 {
110 this.remoteHttpCacheAttributes = remoteHttpCacheAttributes;
111 }
112
113
114
115
116 public RemoteHttpCacheAttributes getRemoteHttpCacheAttributes()
117 {
118 return remoteHttpCacheAttributes;
119 }
120 }