This project has retired. For details please refer to its Attic page.
Source code
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;
023import org.slf4j.Logger;
024import org.slf4j.LoggerFactory;
025
026import java.util.HashSet;
027import java.util.List;
028import java.util.Set;
029
030/**
031 * AbstractMonitoredConsumer 
032 *
033 *
034 */
035public abstract class AbstractMonitoredConsumer
036    implements Consumer
037{
038
039    protected final Logger logger = LoggerFactory.getLogger( getClass() );
040
041    private final Set<ConsumerMonitor> monitors = new HashSet<ConsumerMonitor>();
042    
043    @Override
044    public void addConsumerMonitor( ConsumerMonitor monitor )
045    {
046        monitors.add( monitor );
047    }
048
049    @Override
050    public void removeConsumerMonitor( ConsumerMonitor monitor )
051    {
052        monitors.remove( monitor );
053    }
054
055    protected void triggerConsumerError( String type, String message )
056    {
057        for ( ConsumerMonitor monitor : monitors ) 
058        {
059            try
060            {
061                monitor.consumerError( this, type, message );
062            }
063            catch ( Throwable t )
064            {
065                /* discard error */
066            }
067        }
068    }
069
070    protected void triggerConsumerWarning( String type, String message )
071    {
072        for ( ConsumerMonitor monitor : monitors ) 
073        {
074            try
075            {
076                monitor.consumerWarning( this, type, message );
077            }
078            catch ( Throwable t )
079            {
080                /* discard error */
081            }
082        }
083    }
084
085    protected void triggerConsumerInfo( String message )
086    {
087        for ( ConsumerMonitor monitor : monitors ) 
088        {
089            try
090            {
091                monitor.consumerInfo( this, message );
092            }
093            catch ( Throwable t )
094            {
095                /* discard error */
096            }
097        }
098    }
099
100    public boolean isProcessUnmodified()
101    {
102        return false;
103    }
104
105    protected List<String> getDefaultArtifactExclusions()
106    {
107        return FileTypeUtils.DEFAULT_EXCLUSIONS;
108    }
109    
110    
111}