2 * Copyright 2005-2011 the original author or authors.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org.wamblee.xmlrouter.listener;
18 import java.util.ArrayList;
19 import java.util.Iterator;
20 import java.util.List;
21 import java.util.logging.Level;
22 import java.util.logging.Logger;
24 import org.wamblee.concurrency.ReadLock;
25 import org.wamblee.concurrency.WriteLock;
26 import org.wamblee.xmlrouter.config.Transformation;
28 public class CompositeEventListener implements EventListener {
30 private static final Logger LOGGER = Logger
31 .getLogger(CompositeEventListener.class.getName());
32 private List<EventListener> loggers;
34 public CompositeEventListener() {
35 loggers = new ArrayList<EventListener>();
45 public void addListener(EventListener aLogger) {
54 * @return True iff the logger was removed.
57 public boolean removeListener(EventListener aLogger) {
58 Iterator<EventListener> logger = loggers.iterator();
59 while (logger.hasNext()) {
60 EventListener value = logger.next();
61 if (value == aLogger) {
71 public void delivered(EventInfo aInfo, List<Transformation> aSequence,
72 String aDestinationId, boolean aSuccessFlag) {
73 for (EventListener logger : loggers) {
76 .delivered(aInfo, aSequence, aDestinationId, aSuccessFlag);
77 } catch (Exception e) {
78 LOGGER.log(Level.WARNING, "Logger threw exception", e);
85 public void notDelivered(EventInfo aInfo) {
86 for (EventListener logger : loggers) {
88 logger.notDelivered(aInfo);
89 } catch (Exception e) {
90 LOGGER.log(Level.WARNING, "Logger threw exception", e);