+++ /dev/null
-/*
- * Copyright 2005-2011 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.wamblee.xmlrouter.impl;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.print.attribute.standard.Destination;
-import javax.xml.transform.dom.DOMSource;
-
-import org.wamblee.concurrency.ReadLock;
-import org.wamblee.concurrency.WriteLock;
-import org.wamblee.xmlrouter.common.Id;
-import org.wamblee.xmlrouter.config.Transformation;
-import org.wamblee.xmlrouter.logging.EventLogger;
-
-public class CompositeEventLogger implements EventLogger {
-
- private static final Logger LOGGER = Logger
- .getLogger(CompositeEventLogger.class.getName());
- private List<EventLogger> loggers;
-
- public CompositeEventLogger() {
- loggers = new ArrayList<EventLogger>();
- }
-
- /**
- * Adds a logger.
- *
- * @param aLogger
- * Logger
- */
- @WriteLock
- public void addLogger(EventLogger aLogger) {
- loggers.add(aLogger);
- }
-
- /**
- * Removes a logger.
- *
- * @param aLogger
- * Logger
- * @return True iff the logger was removed.
- */
- @WriteLock
- public boolean removeLogger(EventLogger aLogger) {
- Iterator<EventLogger> logger = loggers.iterator();
- while (logger.hasNext()) {
- EventLogger value = logger.next();
- if (value == aLogger) {
- logger.remove();
- return true;
- }
- }
- return false;
- }
-
- @Override
- @ReadLock
- public void delivered(String aDocumentType, Id<DOMSource> aEventId,
- DOMSource aEvent, List<Transformation> aSequence,
- Id<Destination> aDestination, String aDestinationName,
- boolean aSuccessFlag) {
- for (EventLogger logger : loggers) {
- try {
- logger.delivered(aDocumentType, aEventId, aEvent, aSequence,
- aDestination, aDestinationName, aSuccessFlag);
- } catch (Exception e) {
- LOGGER.log(Level.WARNING, "Logger threw exception", e);
- }
- }
- }
-
- @Override
- @ReadLock
- public void notDelivered(String aDocumentType, Id<DOMSource> aEventId,
- DOMSource aEvent) {
- for (EventLogger logger : loggers) {
- try {
- logger.notDelivered(aDocumentType, aEventId, aEvent);
- } catch (Exception e) {
- LOGGER.log(Level.WARNING, "Logger threw exception", e);
- }
- }
- }
-
-}