001package 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 022import org.apache.archiva.common.FileTypeUtils; 023 024import java.util.HashSet; 025import java.util.List; 026import java.util.Set; 027 028/** 029 * AbstractMonitoredConsumer 030 * 031 * 032 */ 033public abstract class AbstractMonitoredConsumer 034 implements Consumer 035{ 036 private final Set<ConsumerMonitor> monitors = new HashSet<ConsumerMonitor>(); 037 038 @Override 039 public void addConsumerMonitor( ConsumerMonitor monitor ) 040 { 041 monitors.add( monitor ); 042 } 043 044 @Override 045 public void removeConsumerMonitor( ConsumerMonitor monitor ) 046 { 047 monitors.remove( monitor ); 048 } 049 050 protected void triggerConsumerError( String type, String message ) 051 { 052 for ( ConsumerMonitor monitor : monitors ) 053 { 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 ( ConsumerMonitor monitor : monitors ) 068 { 069 try 070 { 071 monitor.consumerWarning( this, type, message ); 072 } 073 catch ( Throwable t ) 074 { 075 /* discard error */ 076 } 077 } 078 } 079 080 protected void triggerConsumerInfo( String message ) 081 { 082 for ( ConsumerMonitor monitor : monitors ) 083 { 084 try 085 { 086 monitor.consumerInfo( this, message ); 087 } 088 catch ( Throwable t ) 089 { 090 /* discard error */ 091 } 092 } 093 } 094 095 public boolean isProcessUnmodified() 096 { 097 return false; 098 } 099 100 protected List<String> getDefaultArtifactExclusions() 101 { 102 return FileTypeUtils.DEFAULT_EXCLUSIONS; 103 } 104 105 106}