KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > slide > event > UncacheModifiedUriListener


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17 package org.apache.slide.event;
18
19 import org.apache.slide.common.Domain;
20 import org.apache.slide.store.ExtendedStore;
21 import org.apache.slide.store.Store;
22 import org.apache.slide.util.logger.Logger;
23
24 /**
25  * In response to an UriModifiedEvent this listener asks the Uri's Store to remove the Uri
26  * from its cache.
27  *
28  */

29 public class UncacheModifiedUriListener implements UriModifiedListener {
30     
31     public static final String JavaDoc LOG_CHANNEL = UncacheModifiedUriListener.class.getName();
32     
33     public UncacheModifiedUriListener() {
34         Domain.log( "Creating UncacheModifiedUriListener.", LOG_CHANNEL, Logger.DEBUG );
35     }
36
37     public void modified(UriModifiedEvent event) {
38         Store store = event.getUri().getStore();
39         /*
40          * TODO: Moving the cache methods on ExtendedStore into their own interface (say CachingStore)
41          * would make this more portable.
42          */

43         if ( store instanceof ExtendedStore ) {
44             ((ExtendedStore)store).removeObjectFromCache( event.getUri() );
45         } else {
46             Domain.log(
47                 "Invalid store type " + store + " while uncaching " + event.getUri().toString(),
48                 LOG_CHANNEL,
49                 Logger.WARNING );
50         }
51     }
52
53 }
54
Popular Tags