1 16 17 package org.springframework.jms.connection; 18 19 import java.util.ArrayList ; 20 import java.util.Iterator ; 21 import java.util.List ; 22 23 import javax.jms.ExceptionListener ; 24 import javax.jms.JMSException ; 25 26 import org.springframework.util.Assert; 27 28 35 public class ChainedExceptionListener implements ExceptionListener { 36 37 38 private final List delegates = new ArrayList (2); 39 40 41 44 public final void addDelegate(ExceptionListener listener) { 45 Assert.notNull(listener, "ExceptionListener must not be null"); 46 this.delegates.add(listener); 47 } 48 49 52 public final ExceptionListener [] getDelegates() { 53 return (ExceptionListener []) this.delegates.toArray(new ExceptionListener [this.delegates.size()]); 54 } 55 56 57 public void onException(JMSException ex) { 58 for (Iterator it = this.delegates.iterator(); it.hasNext();) { 59 ExceptionListener listener = (ExceptionListener ) it.next(); 60 listener.onException(ex); 61 } 62 } 63 64 } 65 | Popular Tags |