| 1 | /* |
| 2 | * Copyright 2005-2006 The RbUtils Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | * |
| 16 | */ |
| 17 | |
| 18 | // $Id: AbstractProcessor.java,v 1.4 2006/09/16 14:47:56 redfish Exp $ |
| 19 | |
| 20 | package org.ktc.rbutils.api.audit; |
| 21 | |
| 22 | import java.util.ArrayList; |
| 23 | import java.util.Collection; |
| 24 | import java.util.Iterator; |
| 25 | |
| 26 | import org.ktc.rbutils.api.i18n.AbstractLocalized; |
| 27 | |
| 28 | /** |
| 29 | * Adds logger functionalities to the Processor interface. |
| 30 | * @since RbUtils 0.9.3.3 |
| 31 | * @version $Revision: 1.4 $ |
| 32 | * @author moishi |
| 33 | */ |
| 34 | public abstract class AbstractProcessor extends AbstractLocalized implements Processor { |
| 35 | |
| 36 | /** List of registered loggers in this Processor. */ |
| 37 | protected final Collection loggers = new ArrayList(); |
| 38 | |
| 39 | /** |
| 40 | * {@inheritDoc} |
| 41 | */ |
| 42 | public boolean addLoggers(final Collection loggersCollection) { |
| 43 | return loggers.addAll(loggersCollection); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * {@inheritDoc} |
| 48 | */ |
| 49 | public boolean addLogger(final Logger logger) { |
| 50 | return loggers.add(logger); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * {@inheritDoc} |
| 55 | */ |
| 56 | public void fireException(final Exception exception) { |
| 57 | for (final Iterator it = loggers.iterator(); it.hasNext();) { |
| 58 | final Logger logger = (Logger) it.next(); |
| 59 | logger.addException(exception); |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | } |