001 /* 002 * Copyright 2006 Stephen McConnell. 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; 020 021 import java.io.File; 022 023 import java.net.URL; 024 025 /** 026 * Transit event monitor. 027 * 028 * @author <a href="http://www.dpml.net">Digital Product Management Laboratory</a> 029 * @version 2.0.1 030 */ 031 public interface Monitor 032 { 033 // cache monitoring functions 034 035 /** 036 * Notify the monitor that an artifact has been requested. 037 * @param artifact the requested artifact 038 */ 039 void resourceRequested( Artifact artifact ); 040 041 /** 042 * Notify the monitor that an artifact has been added to the local cache. 043 * @param resource the url of the resource added to the local cache 044 * @param localFile the local file resident in the cache 045 */ 046 void addedToLocalCache( URL resource, File localFile ); 047 048 /** 049 * Notify the monitor that an artifact in the local cache has been updated. 050 * @param resource the url of the resource updating the local cache 051 * @param localFile the local file that has been updated 052 */ 053 void updatedLocalCache( URL resource, File localFile ); 054 055 /** 056 * Notify the monitor that an artifact has been removed from the local cache. 057 * @param resource the url of the resource removed from the local cache 058 * @param localFile the local file removed from the cache 059 */ 060 void removedFromLocalCache( URL resource, File localFile ); 061 062 /** 063 * Notify the monitor of a failed download attempt relative to an identified host. 064 * @param host the host raising the fail status 065 * @param artifact the requested artifact 066 * @param cause the exception causing the failure 067 */ 068 void failedDownloadFromHost( String host, Artifact artifact, Throwable cause ); 069 070 /** 071 * Notify the monitor of a failed download attempt. 072 * @param artifact the requested artifact 073 */ 074 void failedDownload( Artifact artifact ); 075 076 // network monitoring 077 078 /** 079 * Notify the monitor of the update in the download status. 080 * 081 * @param resource the name of the remote resource being downloaded. 082 * @param expected the expected number of bytes to be downloaded. 083 * @param count the number of bytes downloaded. 084 */ 085 void notifyUpdate( URL resource, int expected, int count ); 086 087 /** 088 * Notify the monitor of the successful completion of a download 089 * process. 090 * @param resource the name of the remote resource. 091 */ 092 void notifyCompletion( URL resource ); 093 094 095 }