1 7 package org.jboss.mq.server; 8 9 import java.util.Iterator ; 10 11 import javax.jms.InvalidClientIDException ; 12 import javax.jms.JMSException ; 13 14 import org.jboss.logging.Logger; 15 import org.jboss.mq.ConnectionToken; 16 27 public class ClientReconnectInterceptor extends JMSServerInterceptorSupport { 28 29 static protected Logger log = 30 Logger.getLogger(ClientReconnectInterceptor.class); 31 32 private JMSDestinationManager destinationManager; 33 private JMSDestinationManager getDestinationManager() { 34 if(destinationManager!=null) 35 return destinationManager; 36 37 JMSServerInterceptor interceptor = getNext(); 38 while( ! (interceptor instanceof JMSDestinationManager) ) 39 interceptor = getNext(); 40 destinationManager = (JMSDestinationManager)interceptor; 41 return destinationManager; 42 } 43 44 private ConnectionToken findConnectionTokenFor(String clientID) { 45 Iterator iterator = getDestinationManager().clientConsumers.keySet().iterator(); 46 while (iterator.hasNext()) { 47 ConnectionToken dc = (ConnectionToken) iterator.next(); 48 if( dc.getClientID().equals(clientID)) 49 return dc; 50 } 51 return null; 52 } 53 54 57 public void checkID(String ID) throws JMSException { 58 try { 59 super.checkID(ID); 60 } catch (InvalidClientIDException e) { 61 ConnectionToken dc = findConnectionTokenFor(ID); 62 if( dc == null ) 65 throw e; 66 67 try { 69 super.connectionClosing(dc); 70 } catch (Throwable e2) { 71 log.trace("Disconnect of previously connected client caused an error:",e); 73 } 74 75 super.checkID(ID); 77 } 78 } 79 } 80 | Popular Tags |