[jboss-cvs] JBoss Messaging SVN: r4979 - in branches/Branch_JBossMessaging_1_4_0_SP3_CP: tests/src/org/jboss/test/messaging/util and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Sep 17 23:07:43 EDT 2008


Author: gaohoward
Date: 2008-09-17 23:07:42 -0400 (Wed, 17 Sep 2008)
New Revision: 4979

Modified:
   branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/messaging/util/CompatibleExecutor.java
   branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/messaging/util/ExecutorFactory.java
   branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/messaging/util/JBMThreadFactory.java
   branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/messaging/util/OrderedExecutorFactory.java
   branches/Branch_JBossMessaging_1_4_0_SP3_CP/tests/src/org/jboss/test/messaging/util/OrderedExecutorFactoryTest.java
Log:
formatting the code


Modified: branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/messaging/util/CompatibleExecutor.java
===================================================================
--- branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/messaging/util/CompatibleExecutor.java	2008-09-18 02:58:10 UTC (rev 4978)
+++ branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/messaging/util/CompatibleExecutor.java	2008-09-18 03:07:42 UTC (rev 4979)
@@ -1,24 +1,24 @@
 /*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
+ * JBoss, Home of Professional Open Source Copyright 2005, JBoss Inc., and
+ * individual contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of individual
+ * contributors.
+ * 
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
 package org.jboss.messaging.util;
 
 import java.util.concurrent.Executor;
@@ -26,14 +26,14 @@
 public interface CompatibleExecutor extends Executor
 {
 
-	void clearAllExceptCurrentTask();
+   void clearAllExceptCurrentTask();
 
-	void clearClassLoader();
+   void clearClassLoader();
 
-	void shutdownNow();
+   void shutdownNow();
 
-	void shutdownAfterProcessingCurrentlyQueuedTasks();
+   void shutdownAfterProcessingCurrentlyQueuedTasks();
 
-	String getName();
+   String getName();
 
 }

Modified: branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/messaging/util/ExecutorFactory.java
===================================================================
--- branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/messaging/util/ExecutorFactory.java	2008-09-18 02:58:10 UTC (rev 4978)
+++ branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/messaging/util/ExecutorFactory.java	2008-09-18 03:07:42 UTC (rev 4979)
@@ -1,37 +1,36 @@
 /*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */ 
+ * JBoss, Home of Professional Open Source Copyright 2005-2008, Red Hat
+ * Middleware LLC, and individual contributors by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of individual
+ * contributors.
+ * 
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
 
 package org.jboss.messaging.util;
 
 import java.util.concurrent.Executor;
 
-/**
+/*
  * 
  * A ExecutorFactory
  * 
  * Copied from JBM2.0
  * 
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
  */
 public interface ExecutorFactory
 {

Modified: branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/messaging/util/JBMThreadFactory.java
===================================================================
--- branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/messaging/util/JBMThreadFactory.java	2008-09-18 02:58:10 UTC (rev 4978)
+++ branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/messaging/util/JBMThreadFactory.java	2008-09-18 03:07:42 UTC (rev 4979)
@@ -1,36 +1,35 @@
 /*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */ 
+ * JBoss, Home of Professional Open Source Copyright 2005-2008, Red Hat
+ * Middleware LLC, and individual contributors by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of individual
+ * contributors.
+ * 
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
 package org.jboss.messaging.util;
 
 import java.util.concurrent.ThreadFactory;
 
-/**
+/*
  * 
  * A JBMThreadFactory
  * 
  * Copied from JBM2.0
  * 
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
  */
 public class JBMThreadFactory implements ThreadFactory
 {
@@ -44,14 +43,15 @@
    public Thread newThread(final Runnable command)
    {
       Thread t = new Thread(group, command);
-      
-      if (command instanceof CompatibleExecutor) {
-    	  t.setName(((CompatibleExecutor)command).getName());
+
+      if (command instanceof CompatibleExecutor)
+      {
+         t.setName(((CompatibleExecutor)command).getName());
       }
-      
-      //Don't want to prevent VM from exiting
+
+      // Don't want to prevent VM from exiting
       t.setDaemon(true);
-      
+
       return t;
    }
 }

Modified: branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/messaging/util/OrderedExecutorFactory.java
===================================================================
--- branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/messaging/util/OrderedExecutorFactory.java	2008-09-18 02:58:10 UTC (rev 4978)
+++ branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/messaging/util/OrderedExecutorFactory.java	2008-09-18 03:07:42 UTC (rev 4979)
@@ -1,24 +1,24 @@
 /*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */ 
+ * JBoss, Home of Professional Open Source Copyright 2005-2008, Red Hat
+ * Middleware LLC, and individual contributors by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of individual
+ * contributors.
+ * 
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
 
 package org.jboss.messaging.util;
 
@@ -30,22 +30,23 @@
 import java.util.Set;
 import java.util.concurrent.Executor;
 
-/**
- *  
+/*
+ * 
  * This factory creates a hierarchy of Executor which shares the threads of the
  * parent Executor (typically, the root parent is a Thread pool).
  * 
  * Copied from JBM2.0
  * 
  * @author <a href="david.lloyd at jboss.com">David Lloyd</a>
+ * 
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
  * 
  * @version <tt>$Revision$</tt>
- * 
  */
 public final class OrderedExecutorFactory implements ExecutorFactory
 {
    private final Executor parent;
+
    private final Set<ChildExecutor> runningChildren = Collections.synchronizedSet(new HashSet<ChildExecutor>());
 
    public OrderedExecutorFactory(final Executor parent)
@@ -61,61 +62,61 @@
    private final class ChildExecutor implements CompatibleExecutor, Runnable
    {
       private final LinkedList<Runnable> tasks = new LinkedList<Runnable>();
+
       private boolean needToSetClassLoader = true;
+
       private ClassLoader tcl;
+
       private boolean shutdown = false;
+
       private String name = "default-thread";
-      
+
       public ChildExecutor(String n)
       {
-    	  name = n;
+         name = n;
       }
-      
+
       public void execute(Runnable command)
       {
-          if (needToSetClassLoader)
-          {
-             tcl = AccessController.doPrivileged(
-                new PrivilegedAction<ClassLoader>()
-                {
-                   public ClassLoader run()
-                   {
-                      return Thread.currentThread().getContextClassLoader();
-                   }
-                }
-             );
-          }
+         if (needToSetClassLoader)
+         {
+            tcl = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
+            {
+               public ClassLoader run()
+               {
+                  return Thread.currentThread().getContextClassLoader();
+               }
+            });
+         }
          synchronized (tasks)
          {
-        	if (!shutdown)
-        	{
+            if (!shutdown)
+            {
                tasks.add(command);
                if (tasks.size() == 1 && runningChildren.add(this))
                {
                   parent.execute(this);
                }
-        	}
+            }
          }
       }
 
       @SuppressWarnings("unchecked")
-	public void run()
+      public void run()
       {
-          if (needToSetClassLoader)
-          {
-             needToSetClassLoader = false;
+         if (needToSetClassLoader)
+         {
+            needToSetClassLoader = false;
 
-             AccessController.doPrivileged(
-                new PrivilegedAction()
-                {
-                   public Object run()
-                   {
-                      Thread.currentThread().setContextClassLoader(tcl);
-                      return null;
-                   }
-                }
-             );
-          }
+            AccessController.doPrivileged(new PrivilegedAction()
+            {
+               public Object run()
+               {
+                  Thread.currentThread().setContextClassLoader(tcl);
+                  return null;
+               }
+            });
+         }
 
          for (;;)
          {
@@ -134,48 +135,55 @@
          }
       }
 
-	 public void clearAllExceptCurrentTask()
-	 {
-		 synchronized (tasks)
-		 {
-			 tasks.clear();
-		 }
-	 }
+      public void clearAllExceptCurrentTask()
+      {
+         synchronized (tasks)
+         {
+            tasks.clear();
+         }
+      }
 
-	public void clearClassLoader() 
-	{
-		execute(new Runnable()
-        {
-           @SuppressWarnings("unchecked")
-           public void run()
-           {
-              needToSetClassLoader = true;
-           }
-        });
-	}
+      public void clearClassLoader()
+      {
+         execute(new Runnable()
+         {
+            @SuppressWarnings("unchecked")
+            public void run()
+            {
+               needToSetClassLoader = true;
+            }
+         });
+      }
 
-	//old behavior also terminates the thread. with a pool we shouldn't do this.
-	public void shutdownNow() {
-		tasks.clear();
-	}
+      // old behavior also terminates the thread. with a pool we shouldn't do
+      // this.
+      public void shutdownNow()
+      {
+         tasks.clear();
+      }
 
-	public void shutdownAfterProcessingCurrentlyQueuedTasks() {
-        synchronized (tasks)
-        {
-        	shutdown = true;
-        	while (tasks.size() > 0) 
-        	{
-        	   try 
-        	   {
-				tasks.wait();
-			   } catch (InterruptedException e) {}
-        	}
-        }
-	}
+      public void shutdownAfterProcessingCurrentlyQueuedTasks()
+      {
+         synchronized (tasks)
+         {
+            shutdown = true;
+            while (tasks.size() > 0)
+            {
+               try
+               {
+                  tasks.wait();
+               }
+               catch (InterruptedException e)
+               {
+               }
+            }
+         }
+      }
 
-	public String getName() {
-		return name;
-	}
-	
+      public String getName()
+      {
+         return name;
+      }
+
    }
 }

Modified: branches/Branch_JBossMessaging_1_4_0_SP3_CP/tests/src/org/jboss/test/messaging/util/OrderedExecutorFactoryTest.java
===================================================================
--- branches/Branch_JBossMessaging_1_4_0_SP3_CP/tests/src/org/jboss/test/messaging/util/OrderedExecutorFactoryTest.java	2008-09-18 02:58:10 UTC (rev 4978)
+++ branches/Branch_JBossMessaging_1_4_0_SP3_CP/tests/src/org/jboss/test/messaging/util/OrderedExecutorFactoryTest.java	2008-09-18 03:07:42 UTC (rev 4979)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2005, JBoss Inc., and
+ * individual contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of individual
+ * contributors.
+ * 
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
 package org.jboss.test.messaging.util;
 
 import java.util.ArrayList;
@@ -8,64 +29,65 @@
 import org.jboss.messaging.util.OrderedExecutorFactory;
 import org.jboss.test.messaging.MessagingTestCase;
 
-public class OrderedExecutorFactoryTest extends MessagingTestCase 
+public class OrderedExecutorFactoryTest extends MessagingTestCase
 {
-	
-	private ArrayList<CounterRunnable> exeQueue = new ArrayList<CounterRunnable>();
-	
-	public OrderedExecutorFactoryTest(String name) 
-	{
-		super(name);
-	}
-	
-	public void testExecutionOrder()
-	{
-		OrderedExecutorFactory factory = new OrderedExecutorFactory(
-		           Executors.newCachedThreadPool(new JBMThreadFactory("test-thread-factory")));
-		CompatibleExecutor executor = factory.getExecutor("test executor");
-		
-		final int numTasks = 200000;
-		
-		CounterRunnable[] tasks = new CounterRunnable[numTasks];
-		
-		for (int i = 0; i < numTasks; ++i)
-		{
-			tasks[i] = new CounterRunnable(this);
-		}
-		exeQueue.clear();
-		for (int i = 0; i < numTasks; ++i)
-		{
-			executor.execute(tasks[i]);
-		}
-		
-		executor.shutdownAfterProcessingCurrentlyQueuedTasks();
-		assertTrue(exeQueue.size() == numTasks);
-		
-		for (int i = 0; i < numTasks; ++i) {
-			CounterRunnable finTask = exeQueue.get(i);
-			assertTrue(finTask == tasks[i]);
-		}
-		
-		exeQueue.clear();
-	}
-	
-	class CounterRunnable implements Runnable
-	{
-		private OrderedExecutorFactoryTest myUser;
-		
-		public CounterRunnable(OrderedExecutorFactoryTest user)
-		{
-			myUser = user;
-		}
-		
-		public void run() {
-			myUser.registerOrder(this);
-		}
-		
-	}
 
-	public void registerOrder(CounterRunnable task)
-    {
-		exeQueue.add(task);
-	}
+   private ArrayList<CounterRunnable> exeQueue = new ArrayList<CounterRunnable>();
+
+   public OrderedExecutorFactoryTest(String name)
+   {
+      super(name);
+   }
+
+   public void testExecutionOrder()
+   {
+      OrderedExecutorFactory factory = new OrderedExecutorFactory(Executors.newCachedThreadPool(new JBMThreadFactory("test-thread-factory")));
+      CompatibleExecutor executor = factory.getExecutor("test executor");
+
+      final int numTasks = 200000;
+
+      CounterRunnable[] tasks = new CounterRunnable[numTasks];
+
+      for (int i = 0; i < numTasks; ++i)
+      {
+         tasks[i] = new CounterRunnable(this);
+      }
+      exeQueue.clear();
+      for (int i = 0; i < numTasks; ++i)
+      {
+         executor.execute(tasks[i]);
+      }
+
+      executor.shutdownAfterProcessingCurrentlyQueuedTasks();
+      assertTrue(exeQueue.size() == numTasks);
+
+      for (int i = 0; i < numTasks; ++i)
+      {
+         CounterRunnable finTask = exeQueue.get(i);
+         assertTrue(finTask == tasks[i]);
+      }
+
+      exeQueue.clear();
+   }
+
+   class CounterRunnable implements Runnable
+   {
+      private OrderedExecutorFactoryTest myUser;
+
+      public CounterRunnable(OrderedExecutorFactoryTest user)
+      {
+         myUser = user;
+      }
+
+      public void run()
+      {
+         myUser.registerOrder(this);
+      }
+
+   }
+
+   public void registerOrder(CounterRunnable task)
+   {
+      exeQueue.add(task);
+   }
 }




More information about the jboss-cvs-commits mailing list