[jboss-cvs] JBossAS SVN: r58911 - branches/JBoss_4_0_5_GA_JBAS_3657/server/src/main/org/jboss/jms/asf

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Dec 7 17:00:01 EST 2006


Author: weston.price at jboss.com
Date: 2006-12-07 16:59:59 -0500 (Thu, 07 Dec 2006)
New Revision: 58911

Added:
   branches/JBoss_4_0_5_GA_JBAS_3657/server/src/main/org/jboss/jms/asf/AllFatalJMSExceptionSorter.java
   branches/JBoss_4_0_5_GA_JBAS_3657/server/src/main/org/jboss/jms/asf/AllNonFatalJMSExceptionSorter.java
   branches/JBoss_4_0_5_GA_JBAS_3657/server/src/main/org/jboss/jms/asf/JMSExceptionCodeMatcher.java
   branches/JBoss_4_0_5_GA_JBAS_3657/server/src/main/org/jboss/jms/asf/JMSExceptionSorter.java
   branches/JBoss_4_0_5_GA_JBAS_3657/server/src/main/org/jboss/jms/asf/JMSSupportCodeHandler.java
   branches/JBoss_4_0_5_GA_JBAS_3657/server/src/main/org/jboss/jms/asf/JMSSupportCodeLoader.java
   branches/JBoss_4_0_5_GA_JBAS_3657/server/src/main/org/jboss/jms/asf/JmsServerSessionReaper.java
   branches/JBoss_4_0_5_GA_JBAS_3657/server/src/main/org/jboss/jms/asf/JmsSessionPoolFiller.java
Log:
[JBAS-3657][JBAS-3511] Port of patch made for client in integrating with WebSphereMQ

Added: branches/JBoss_4_0_5_GA_JBAS_3657/server/src/main/org/jboss/jms/asf/AllFatalJMSExceptionSorter.java
===================================================================
--- branches/JBoss_4_0_5_GA_JBAS_3657/server/src/main/org/jboss/jms/asf/AllFatalJMSExceptionSorter.java	2006-12-07 21:59:27 UTC (rev 58910)
+++ branches/JBoss_4_0_5_GA_JBAS_3657/server/src/main/org/jboss/jms/asf/AllFatalJMSExceptionSorter.java	2006-12-07 21:59:59 UTC (rev 58911)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.jms.asf;
+
+import javax.jms.JMSException;
+
+
+/**
+ * A AllFatalJMSExceptionSorter.
+ * 
+ * @author <a href="mailto:weston.price at jboss.org>Weston Price</a>
+ * @version $Revision: 1.1 $
+ */
+public class AllFatalJMSExceptionSorter implements JMSExceptionSorter
+{
+   private boolean validateLinkedException;
+   
+   public boolean isJMSExceptionFatal(JMSException e)
+   {
+      return true;
+   }
+
+   public boolean getValidateLinkedException()
+   {
+      return this.validateLinkedException;
+   }
+
+   public void setValidateLinkedException(boolean vle)
+   {
+      this.validateLinkedException = vle;
+      
+   }
+
+   
+}

Added: branches/JBoss_4_0_5_GA_JBAS_3657/server/src/main/org/jboss/jms/asf/AllNonFatalJMSExceptionSorter.java
===================================================================
--- branches/JBoss_4_0_5_GA_JBAS_3657/server/src/main/org/jboss/jms/asf/AllNonFatalJMSExceptionSorter.java	2006-12-07 21:59:27 UTC (rev 58910)
+++ branches/JBoss_4_0_5_GA_JBAS_3657/server/src/main/org/jboss/jms/asf/AllNonFatalJMSExceptionSorter.java	2006-12-07 21:59:59 UTC (rev 58911)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.jms.asf;
+
+import javax.jms.JMSException;
+
+/**
+ * A AllNonFatalJMSExceptionSorter.
+ * 
+ * @author <a href="mailto:weston.price at jboss.org>Weston Price</a>
+ * @version $Revision: 1.1 $
+ */
+public class AllNonFatalJMSExceptionSorter implements JMSExceptionSorter
+{
+   private boolean validateLinkedException;
+   
+   public boolean isJMSExceptionFatal(JMSException e)
+   {      
+      return false;
+   }
+
+   public boolean getValidateLinkedException()
+   {
+      return this.validateLinkedException;
+   }
+
+   public void setValidateLinkedException(boolean vle)
+   {
+      this.validateLinkedException = vle;
+      
+   }
+}

Added: branches/JBoss_4_0_5_GA_JBAS_3657/server/src/main/org/jboss/jms/asf/JMSExceptionCodeMatcher.java
===================================================================
--- branches/JBoss_4_0_5_GA_JBAS_3657/server/src/main/org/jboss/jms/asf/JMSExceptionCodeMatcher.java	2006-12-07 21:59:27 UTC (rev 58910)
+++ branches/JBoss_4_0_5_GA_JBAS_3657/server/src/main/org/jboss/jms/asf/JMSExceptionCodeMatcher.java	2006-12-07 21:59:59 UTC (rev 58911)
@@ -0,0 +1,33 @@
+package org.jboss.jms.asf;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.jboss.logging.Logger;
+
+public class JMSExceptionCodeMatcher
+{
+   private static final Logger log = Logger.getLogger(JMSExceptionCodeMatcher.class);
+   
+   public static boolean matches(final String errorCode, final String code)
+   {   
+      boolean matches = false;
+      boolean trace = log.isTraceEnabled();
+      
+      if(trace)
+         log.trace("Attempting to match JMSErrorCode: " + errorCode + " with candidate code " + code);
+      Pattern p = Pattern.compile(code);
+      Matcher m = p.matcher(errorCode);
+      matches = m.find();
+      
+      if(trace)
+         log.trace("Match results for JMSErrorCode: " +  errorCode + " with candidate " + code + " are" + matches);
+
+      return matches;
+   }
+
+   public static boolean matches(String errorCode, Integer code)
+   {
+      return matches(errorCode, code.toString());
+   }
+}

Added: branches/JBoss_4_0_5_GA_JBAS_3657/server/src/main/org/jboss/jms/asf/JMSExceptionSorter.java
===================================================================
--- branches/JBoss_4_0_5_GA_JBAS_3657/server/src/main/org/jboss/jms/asf/JMSExceptionSorter.java	2006-12-07 21:59:27 UTC (rev 58910)
+++ branches/JBoss_4_0_5_GA_JBAS_3657/server/src/main/org/jboss/jms/asf/JMSExceptionSorter.java	2006-12-07 21:59:59 UTC (rev 58911)
@@ -0,0 +1,11 @@
+package org.jboss.jms.asf;
+
+import javax.jms.JMSException;
+
+public interface JMSExceptionSorter
+{
+   
+   public boolean isJMSExceptionFatal(JMSException e);
+   public void setValidateLinkedException(boolean vle);
+   public boolean getValidateLinkedException();
+}

Added: branches/JBoss_4_0_5_GA_JBAS_3657/server/src/main/org/jboss/jms/asf/JMSSupportCodeHandler.java
===================================================================
--- branches/JBoss_4_0_5_GA_JBAS_3657/server/src/main/org/jboss/jms/asf/JMSSupportCodeHandler.java	2006-12-07 21:59:27 UTC (rev 58910)
+++ branches/JBoss_4_0_5_GA_JBAS_3657/server/src/main/org/jboss/jms/asf/JMSSupportCodeHandler.java	2006-12-07 21:59:59 UTC (rev 58911)
@@ -0,0 +1,249 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.jms.asf;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.jms.JMSException;
+
+import org.jboss.logging.Logger;
+
+/**
+ * A JMSSupportCodeHandler.
+ * 
+ *
+ */
+public class JMSSupportCodeHandler implements JMSExceptionSorter
+{
+   private static final Logger log = Logger.getLogger(JMSSupportCodeLoader.class);
+   private static final String NO_SORTER = "NoSorter";
+   private static final String NO_URL = "NoUrl";
+   
+   private boolean validateLinkedExcpetion;
+   private List fatalCodes = new ArrayList();
+   private JMSExceptionSorter sorter;
+   private String supportCodeUrl;
+   
+   public boolean hasSupportCodes()
+   {
+      return fatalCodes.size() > 0;
+      
+   }
+   
+   //For testing only.
+   public JMSExceptionSorter getUnderlyingSorter()
+   {
+      return this.sorter;
+      
+   }
+   
+   public JMSSupportCodeHandler(final String fileName, final String sorterClassName)
+   {
+      this(fileName, sorterClassName, false);
+      
+   }
+   public JMSSupportCodeHandler(final String fileName, final String sorterClassName, boolean validateLinkedException)
+   {
+      this.validateLinkedExcpetion = validateLinkedException;
+      
+      if(sorterClassName == null || sorterClassName.equalsIgnoreCase(NO_SORTER))
+      {  
+         
+         if(fileName != null && !fileName.equalsIgnoreCase("") && !fileName.equalsIgnoreCase(NO_URL))
+         {
+            log.trace("Exception sorter class name is null. Attempting to load codes from external file " + fileName);
+            this.supportCodeUrl = fileName;
+            fatalCodes = JMSSupportCodeLoader.loadJMSSupportCodes(fileName);
+            
+         }else
+         {
+            log.trace("No external url or exception sorter classname was provided. JMSSessions will not be validated.");
+         }
+         
+         
+      }else
+      {
+         
+         final ClassLoader cl = Thread.currentThread().getContextClassLoader();
+         
+         try
+         {
+            final Class sorterClass = cl.loadClass(sorterClassName);
+            sorter = (JMSExceptionSorter)sorterClass.newInstance();
+            sorter.setValidateLinkedException(validateLinkedException);
+            
+         }catch(Exception e)
+         {
+            log.error("Sorter class " + sorterClassName + " could not be loaded. Using default exception sorter");
+            sorter = new AllNonFatalJMSExceptionSorter();
+            sorter.setValidateLinkedException(validateLinkedException);
+         }
+         
+         
+      }
+      
+   }
+
+   public JMSSupportCodeHandler(final String fileName)
+   {
+      this(fileName, null, false);
+      
+   }
+   
+   public void reloadSupportFile()
+   {      
+      if(fatalCodes != null)
+         log.trace("Attempting to reload support code file " + supportCodeUrl);
+      
+      synchronized (this)
+      {
+         if(fatalCodes != null)
+         {
+            fatalCodes = null;
+            fatalCodes = JMSSupportCodeLoader.loadJMSSupportCodes(supportCodeUrl);
+            
+         }
+      }      
+   }
+
+   public void addSupportCodes(String fileName)
+   {
+      if(fatalCodes != null)
+         log.trace("Attempting to reload support code file " + fileName);
+
+      List newCodes = JMSSupportCodeLoader.loadJMSSupportCodes(fileName);
+      
+      synchronized (fatalCodes)
+      {
+         fatalCodes.addAll(newCodes);
+                 
+      }
+      
+   }
+   
+   public boolean isCodeInUse(int code)
+   {
+      return (fatalCodes != null && fatalCodes.contains(new Integer(code)));
+      
+   }
+   public void reloadSupportFile(String fileName)
+   {
+      if(fatalCodes != null)
+         log.trace("Attempting to reload support code file " + fileName);
+      
+      synchronized (this)
+      {
+         fatalCodes = JMSSupportCodeLoader.loadJMSSupportCodes(fileName);
+         
+      }
+            
+   }
+   
+   public void clearSupportCodes()
+   {
+      synchronized (fatalCodes)
+      {
+         fatalCodes.clear();
+         
+      }      
+      
+   }
+   public Integer[] getCurrentCodes()
+   {
+      synchronized (fatalCodes)
+      {
+         return (Integer[]) fatalCodes.toArray(new Integer[fatalCodes.size()]);      
+         
+      }
+   }
+   
+   public boolean isJMSExceptionFatal(final JMSException e)
+   {
+    
+      if(sorter != null)
+      {
+         return sorter.isJMSExceptionFatal(e);
+         
+      }
+      
+      boolean fatal = false;      
+      final String errorCode = e.getErrorCode();
+      
+      if(errorCode != null)
+      {
+         for(Iterator iter = fatalCodes.iterator(); iter.hasNext();)
+         {
+            Integer code = (Integer)iter.next();         
+            
+            if(code != null)
+            {
+           
+               
+               if(JMSExceptionCodeMatcher.matches(errorCode, code))
+               {
+                  log.trace("JMS error code " + errorCode + " contains value " + code + " and will be processed as a fatal exception.");
+                  fatal = true;               
+                  break;
+               }
+            }
+         
+         }         
+      }
+      
+      if(fatal || !fatal && !validateLinkedExcpetion)
+      {
+         return fatal;
+      }
+      
+      if(e.getLinkedException() instanceof JMSException)
+      {
+         JMSException linked = (JMSException)e.getLinkedException();
+         final String linkedErrorCode = linked.getErrorCode();
+         
+         if(linkedErrorCode != null)
+         {
+            for(Iterator iter = fatalCodes.iterator(); iter.hasNext();)
+            {
+               Integer code = (Integer)iter.next();
+               
+               if(linkedErrorCode != null)
+               {
+                  if(JMSExceptionCodeMatcher.matches(linkedErrorCode,code))
+                  {
+                     log.trace("JMS error code from linked exception " + linkedErrorCode + " contains value " + code + " and will be processed as a fatal exception.");
+                     fatal = true;
+                     break;
+                  }
+                  
+               }
+            }
+                     
+         }
+      }
+   
+      return fatal;
+   }
+
+   public boolean getValidateLinkedException()
+   {
+      return validateLinkedExcpetion;
+      
+   }
+
+   public void setValidateLinkedException(boolean vle)
+   {
+      this.validateLinkedExcpetion = vle;
+      
+   }
+
+   
+
+}

Added: branches/JBoss_4_0_5_GA_JBAS_3657/server/src/main/org/jboss/jms/asf/JMSSupportCodeLoader.java
===================================================================
--- branches/JBoss_4_0_5_GA_JBAS_3657/server/src/main/org/jboss/jms/asf/JMSSupportCodeLoader.java	2006-12-07 21:59:27 UTC (rev 58910)
+++ branches/JBoss_4_0_5_GA_JBAS_3657/server/src/main/org/jboss/jms/asf/JMSSupportCodeLoader.java	2006-12-07 21:59:59 UTC (rev 58911)
@@ -0,0 +1,151 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.jms.asf;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.jboss.logging.Logger;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+
+/**
+ * A JMSSupportCodeLoader.
+ *
+ */
+public class JMSSupportCodeLoader
+{
+   private static final Logger log = Logger.getLogger(JMSSupportCodeLoader.class);
+   private static final String FATAL_CODE_ELEM_NAME = "jms-fatal-code";
+   
+   public static List loadJMSSupportCodes(final String fileName)
+   {
+      final List supportCodes = new ArrayList();
+      InputStream is = null;
+      DocumentBuilder builder = null;
+      InputSource source = null;
+      boolean loaded = false;
+      
+      if(fileName == null)
+         return supportCodes;
+      
+      try
+      {
+         if(fileName != null)
+         {
+            
+            try
+            {
+               builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+               
+            }catch(Exception e)
+            {
+               log.trace("Could not instantiate DocumentBuilder.", e);
+               return supportCodes;
+               
+            }
+            
+            //First try the file system
+            try
+            {
+               source = new InputSource(new FileReader(new File(fileName)));
+               loaded = true;
+            
+            }catch(Exception e)
+            {
+               log.trace("Could not load filesystem resource", e);                           
+            }
+
+            if(source == null || loaded == false)
+            {
+               log.debug("Could not load filesystem resource " + fileName + " attempting to load from classpath");            
+               final ClassLoader cl = Thread.currentThread().getContextClassLoader();
+               is = cl.getResourceAsStream(fileName);
+               
+               if(is == null)
+               {
+                  log.debug("Could not load system resource " + fileName + " from classpath");
+                  return supportCodes;
+               }
+               
+               source = new InputSource(is);
+            }
+            
+            try
+            {
+               Document document = builder.parse(source);            
+               //Get nodes and populate
+               NodeList nl = document.getElementsByTagName(FATAL_CODE_ELEM_NAME);
+               log.debug("Found " + nl.getLength() + " codes for processing.");
+               
+               for(int i = 0; i < nl.getLength(); i++)
+               {
+                  Node fatal = (Node)nl.item(i);
+                  String txt = fatal.getFirstChild().getNodeValue();
+                  
+                  try
+                  {
+                     
+                     if(txt != null)
+                     {
+                        Integer code = Integer.valueOf(txt);
+                        supportCodes.add(code);
+                        
+                     }
+                  
+                  }catch(Exception e)
+                  {
+                     log.trace("Could not format or add supoprt code " + txt + " please validate support code file " + fileName);
+                     
+                  }
+                  
+               }
+
+               log.trace("Loaded " + supportCodes.size() + " codes " + "from " + fileName);       
+               
+               return supportCodes;
+               
+            }catch(Exception e)
+            {
+               log.trace("Could not parse support code file.", e);
+               return supportCodes;            
+               
+            }
+                        
+         }
+           
+         
+      }finally
+      {
+         try
+         {
+            if(is != null)
+               is.close();
+            
+         }catch(Exception ignore)
+         {
+            
+         }
+      }
+      
+      return supportCodes;
+      
+      
+   }
+   
+   
+   
+}

Added: branches/JBoss_4_0_5_GA_JBAS_3657/server/src/main/org/jboss/jms/asf/JmsServerSessionReaper.java
===================================================================
--- branches/JBoss_4_0_5_GA_JBAS_3657/server/src/main/org/jboss/jms/asf/JmsServerSessionReaper.java	2006-12-07 21:59:27 UTC (rev 58910)
+++ branches/JBoss_4_0_5_GA_JBAS_3657/server/src/main/org/jboss/jms/asf/JmsServerSessionReaper.java	2006-12-07 21:59:59 UTC (rev 58911)
@@ -0,0 +1,134 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.jms.asf;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.jboss.logging.Logger;
+
+/**
+ * A JmsServerSessionReaper based on JCA <code>org.jboss.resource.connectionmanager.IdleRemover</code>.
+ * 
+ * @author <a href="mailto:weston.price at jboss.com>Weston Price</a>
+ * 
+ * @see org.jboss.resource.connectionmanager.IdleRemover
+ * @version $Revision: 1.1 $
+ */
+public class JmsServerSessionReaper
+{
+   
+   private static final Logger logger = Logger.getLogger(JmsServerSessionReaper.class);
+   private static final Collection pools = new ArrayList();
+   private long interval = Long.MAX_VALUE;
+   private long next = Long.MAX_VALUE;
+   private Thread reaperThread;
+   
+   private static final JmsServerSessionReaper reaper = new JmsServerSessionReaper();
+   
+   public static void registerSessionPool(StdServerSessionPool pool, long interval)
+   {
+      reaper.internalRegisterPool(pool, interval);
+   }
+   
+   public static void unregisterSessionPool(StdServerSessionPool pool)
+   {     
+      reaper.internalUnregisterPool(pool);
+   }
+
+   private JmsServerSessionReaper()
+   {
+      reaperThread = new Thread(
+            new Runnable() {
+
+               public void run()
+               {
+                  synchronized (pools)
+                  {
+                     while (true)
+                     {
+                        try 
+                        {
+                           pools.wait(interval);
+                           logger.debug("run: JmsSessionReaper notifying pools, interval: " + interval);
+                           
+                           for (Iterator i = pools.iterator(); i.hasNext(); ) 
+                           {
+                             StdServerSessionPool pool = (StdServerSessionPool)i.next();
+                             pool.removeTimedOut();
+                           } 
+                           next = System.currentTimeMillis() + interval;
+                           
+                           if (next < 0) 
+                           {
+                              next = Long.MAX_VALUE;      
+                           } 
+                           
+                        }
+                        catch (InterruptedException ie)
+                        {
+                           logger.info("run: JmsSessionReaper has been interrupted, returning");
+                           return;  
+                        } 
+                        catch (RuntimeException e)
+                        {
+                           logger.warn("run: JmsSessionReaper ignored unexpected runtime exception", e);
+                        }
+                        catch (Error e)
+                        {
+                           logger.warn("run: JmsSessionReaper ignored unexpected error", e);
+                        }
+                           
+                     } 
+                     
+                  }
+               }
+            }, "JmsSessionReaper");
+         reaperThread.setDaemon(true);
+         reaperThread.start();
+      
+   }
+   private void internalRegisterPool(StdServerSessionPool pool, long interval)
+   {
+      logger.debug("Registering StdServerSessionPool with interval " + interval);
+      
+      synchronized (pools)
+      {
+         pools.add(pool);
+         
+         if (interval > 1 && interval/2 < this.interval) 
+         {
+            this.interval = interval/2;
+            long maybeNext = System.currentTimeMillis() + this.interval;
+            if (next > maybeNext && maybeNext > 0) 
+            {
+               next = maybeNext;
+               logger.debug("internalRegisterPool: about to notify thread: old next: " + next + ", new next: " + maybeNext);
+               pools.notify();
+
+            } 
+            
+         } 
+      }
+      
+   }
+   
+   private void internalUnregisterPool(StdServerSessionPool pool)
+   {
+      synchronized (pools)
+      {
+         pools.remove(pool);
+         if (pools.size() == 0) 
+         {
+            logger.debug("internalUnregisterPool: setting interval to Long.MAX_VALUE");
+            interval = Long.MAX_VALUE;
+         } 
+         
+      }
+   }
+}

Added: branches/JBoss_4_0_5_GA_JBAS_3657/server/src/main/org/jboss/jms/asf/JmsSessionPoolFiller.java
===================================================================
--- branches/JBoss_4_0_5_GA_JBAS_3657/server/src/main/org/jboss/jms/asf/JmsSessionPoolFiller.java	2006-12-07 21:59:27 UTC (rev 58910)
+++ branches/JBoss_4_0_5_GA_JBAS_3657/server/src/main/org/jboss/jms/asf/JmsSessionPoolFiller.java	2006-12-07 21:59:59 UTC (rev 58911)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.jms.asf;
+
+import java.util.LinkedList;
+
+/**
+ * A JmsSessionPoolFiller.
+ * 
+ * @author <a href="weston.price at jboss.com">Weston Price</a>
+ * @version $Revision: 1.1 $
+ */
+public class JmsSessionPoolFiller implements Runnable
+{
+   private final LinkedList pools = new LinkedList();
+
+   private final Thread fillerThread;
+
+   private static final JmsSessionPoolFiller filler = new JmsSessionPoolFiller();
+
+   public static void fillPool(StdServerSessionPool pool)
+   {
+      filler.internalFillPool(pool);
+   }
+
+   public JmsSessionPoolFiller ()
+   {
+      fillerThread = new Thread(this, "JMS Session PoolFiller");
+      fillerThread.start();
+   }
+
+   public void run()
+   {
+      ClassLoader myClassLoader = getClass().getClassLoader();
+      Thread.currentThread().setContextClassLoader(myClassLoader);
+      //keep going unless interrupted
+      while (true)
+      {
+         try 
+         {
+            StdServerSessionPool sp = null;
+            //keep iterating through pools till empty, exception escapes.
+            while (true)
+            {
+                     
+               synchronized (pools)
+               {
+                  sp = (StdServerSessionPool)pools.removeFirst();
+               }
+               if (sp == null) 
+               {
+                  break;
+               } 
+                        
+               sp.fillToMin();
+            } 
+
+         }
+         catch (Exception e)
+         {
+         } 
+                        
+         try 
+         {
+            synchronized (pools)
+            {
+               pools.wait();                        
+            }
+         }
+         catch (InterruptedException ie)
+         {
+            return;
+         } 
+      } 
+   }
+
+   private void internalFillPool(StdServerSessionPool mcp)
+   {
+      synchronized (pools)
+      {
+         pools.addLast(mcp);
+         pools.notify();
+      }
+   }
+   
+}




More information about the jboss-cvs-commits mailing list