001 package org.apache.archiva.consumers; 002 003 /* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022 import org.apache.archiva.common.FileTypeUtils; 023 024 import java.util.HashSet; 025 import java.util.Iterator; 026 import java.util.List; 027 import java.util.Set; 028 029 /** 030 * AbstractMonitoredConsumer 031 * 032 * 033 */ 034 public abstract class AbstractMonitoredConsumer 035 implements Consumer 036 { 037 private Set<ConsumerMonitor> monitors = new HashSet<ConsumerMonitor>(); 038 039 public void addConsumerMonitor( ConsumerMonitor monitor ) 040 { 041 monitors.add( monitor ); 042 } 043 044 public void removeConsumerMonitor( ConsumerMonitor monitor ) 045 { 046 monitors.remove( monitor ); 047 } 048 049 protected void triggerConsumerError( String type, String message ) 050 { 051 for ( Iterator<ConsumerMonitor> itmonitors = monitors.iterator(); itmonitors.hasNext(); ) 052 { 053 ConsumerMonitor monitor = itmonitors.next(); 054 try 055 { 056 monitor.consumerError( this, type, message ); 057 } 058 catch ( Throwable t ) 059 { 060 /* discard error */ 061 } 062 } 063 } 064 065 protected void triggerConsumerWarning( String type, String message ) 066 { 067 for ( Iterator<ConsumerMonitor> itmonitors = monitors.iterator(); itmonitors.hasNext(); ) 068 { 069 ConsumerMonitor monitor = itmonitors.next(); 070 try 071 { 072 monitor.consumerWarning( this, type, message ); 073 } 074 catch ( Throwable t ) 075 { 076 /* discard error */ 077 } 078 } 079 } 080 081 protected void triggerConsumerInfo( String message ) 082 { 083 for ( Iterator<ConsumerMonitor> itmonitors = monitors.iterator(); itmonitors.hasNext(); ) 084 { 085 ConsumerMonitor monitor = itmonitors.next(); 086 try 087 { 088 monitor.consumerInfo( this, message ); 089 } 090 catch ( Throwable t ) 091 { 092 /* discard error */ 093 } 094 } 095 } 096 097 public boolean isProcessUnmodified() 098 { 099 return false; 100 } 101 102 protected List<String> getDefaultArtifactExclusions() 103 { 104 return FileTypeUtils.DEFAULT_EXCLUSIONS; 105 } 106 107 108 }