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