001 /* 002 * Copyright 2004 Niclas Hedhman. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 013 * implied. 014 * 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 019 package net.dpml.transit.monitor; 020 021 import java.io.File; 022 023 import java.net.URL; 024 025 import net.dpml.transit.Artifact; 026 027 /** 028 * A monitor of a Transit cache activity. 029 * 030 * <p> 031 * The CacheMonitor must be thread safe. 032 * </p> 033 * 034 * @author <a href="http://www.dpml.net">Digital Product Meta Library</a> 035 * @version 1.1.0 036 * @see Monitor 037 */ 038 public interface CacheMonitor extends Monitor 039 { 040 /** 041 * Notify the monitor that an artifact has been requested. 042 * @param artifact the requested artifact 043 */ 044 void resourceRequested( Artifact artifact ); 045 046 /** 047 * Notify the monitor that an artifact has been added to the local cache. 048 * @param resource the url of the resource added to the local cache 049 * @param localFile the local file resident in the cache 050 */ 051 void addedToLocalCache( URL resource, File localFile ); 052 053 /** 054 * Notify the monitor that an artifact in the local cache has been updated. 055 * @param resource the url of the resource updating the local cache 056 * @param localFile the local file that has been updated 057 */ 058 void updatedLocalCache( URL resource, File localFile ); 059 060 /** 061 * Notify the monitor that an artifact has been removed from the local cache. 062 * @param resource the url of the resource removed from the local cache 063 * @param localFile the local file removed from the cache 064 */ 065 void removedFromLocalCache( URL resource, File localFile ); 066 067 /** 068 * Notify the monitor of a failed download attempt relative to an identified host. 069 * @param host the host raising the fail status 070 * @param artifact the requested artifact 071 * @param cause the exception causing the failure 072 */ 073 void failedDownloadFromHost( String host, Artifact artifact, Throwable cause ); 074 075 /** 076 * Notify the monitor of a failed download attempt. 077 * @param artifact the requested artifact 078 */ 079 void failedDownload( Artifact artifact ); 080 081 }