| %line | %branch | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| org.apache.jcs.engine.CacheAdaptor |
|
|
| 1 | package org.apache.jcs.engine; |
|
| 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 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.engine.behavior.ICache; |
|
| 28 | import org.apache.jcs.engine.behavior.ICacheElement; |
|
| 29 | import org.apache.jcs.engine.behavior.ICacheListener; |
|
| 30 | ||
| 31 | /** |
|
| 32 | * Used for Cache-to-Cache messaging purposes. These are used in the balking |
|
| 33 | * facades in the lateral and remote caches. |
|
| 34 | */ |
|
| 35 | public class CacheAdaptor |
|
| 36 | implements ICacheListener |
|
| 37 | { |
|
| 38 | 54 | private final static Log log = LogFactory.getLog( CacheAdaptor.class ); |
| 39 | ||
| 40 | private final ICache cache; |
|
| 41 | ||
| 42 | /** The unique id of this listner. */ |
|
| 43 | 96 | protected long listenerId = 0; |
| 44 | ||
| 45 | /** |
|
| 46 | * Sets the listenerId attribute of the CacheAdaptor object |
|
| 47 | * <p> |
|
| 48 | * @param id |
|
| 49 | * The new listenerId value |
|
| 50 | * @throws IOException |
|
| 51 | */ |
|
| 52 | public void setListenerId( long id ) |
|
| 53 | throws IOException |
|
| 54 | { |
|
| 55 | 0 | this.listenerId = id; |
| 56 | 0 | log.debug( "listenerId = " + id ); |
| 57 | 0 | } |
| 58 | ||
| 59 | /** |
|
| 60 | * Gets the listenerId attribute of the CacheAdaptor object |
|
| 61 | * <p> |
|
| 62 | * @return The listenerId value |
|
| 63 | * @throws IOException |
|
| 64 | */ |
|
| 65 | public long getListenerId() |
|
| 66 | throws IOException |
|
| 67 | { |
|
| 68 | 0 | return this.listenerId; |
| 69 | } |
|
| 70 | ||
| 71 | /** |
|
| 72 | * Constructor for the CacheAdaptor object |
|
| 73 | * @param cache |
|
| 74 | */ |
|
| 75 | public CacheAdaptor( ICache cache ) |
|
| 76 | 96 | { |
| 77 | 96 | this.cache = cache; |
| 78 | 96 | } |
| 79 | ||
| 80 | /** |
|
| 81 | * Puts an item into the cache. |
|
| 82 | * <p> |
|
| 83 | * @param item |
|
| 84 | * @throws IOException |
|
| 85 | */ |
|
| 86 | public void handlePut( ICacheElement item ) |
|
| 87 | throws IOException |
|
| 88 | { |
|
| 89 | try |
|
| 90 | { |
|
| 91 | 774 | cache.update( item ); |
| 92 | } |
|
| 93 | 0 | catch ( Exception e ) |
| 94 | { |
|
| 95 | // swallow |
|
| 96 | 774 | } |
| 97 | 774 | } |
| 98 | ||
| 99 | /* |
|
| 100 | * (non-Javadoc) |
|
| 101 | * @see org.apache.jcs.engine.behavior.ICacheListener#handleRemove(java.lang.String, |
|
| 102 | * java.io.Serializable) |
|
| 103 | */ |
|
| 104 | public void handleRemove( String cacheName, Serializable key ) |
|
| 105 | throws IOException |
|
| 106 | { |
|
| 107 | 14 | cache.remove( key ); |
| 108 | 14 | } |
| 109 | ||
| 110 | /* |
|
| 111 | * (non-Javadoc) |
|
| 112 | * @see org.apache.jcs.engine.behavior.ICacheListener#handleRemoveAll(java.lang.String) |
|
| 113 | */ |
|
| 114 | public void handleRemoveAll( String cacheName ) |
|
| 115 | throws IOException |
|
| 116 | { |
|
| 117 | 0 | cache.removeAll(); |
| 118 | 0 | } |
| 119 | ||
| 120 | /* |
|
| 121 | * (non-Javadoc) |
|
| 122 | * @see org.apache.jcs.engine.behavior.ICacheListener#handleDispose(java.lang.String) |
|
| 123 | */ |
|
| 124 | public void handleDispose( String cacheName ) |
|
| 125 | throws IOException |
|
| 126 | { |
|
| 127 | 0 | cache.dispose(); |
| 128 | 0 | } |
| 129 | } |
| This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |