[jboss-cvs] JBossAS SVN: r95604 - projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/deployer/kernel.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Oct 27 06:15:29 EDT 2009
Author: kabir.khan at jboss.com
Date: 2009-10-27 06:15:28 -0400 (Tue, 27 Oct 2009)
New Revision: 95604
Added:
projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/deployer/kernel/KernelControllerContextComparator.java
Modified:
projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/deployer/kernel/BeanMetaDataDeployer.java
Log:
[JBDEPLOY-219] Extract KernelControllerContextComparator as a top-level class
Modified: projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/deployer/kernel/BeanMetaDataDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/deployer/kernel/BeanMetaDataDeployer.java 2009-10-27 09:20:36 UTC (rev 95603)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/deployer/kernel/BeanMetaDataDeployer.java 2009-10-27 10:15:28 UTC (rev 95604)
@@ -24,7 +24,6 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.Comparator;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
@@ -122,19 +121,7 @@
try
{
controllerContextCreators.add(creator);
- Collections.sort(controllerContextCreators, new Comparator<KernelControllerContextCreator>()
- {
-
- public int compare(KernelControllerContextCreator o1, KernelControllerContextCreator o2)
- {
- if (o1.getRelativeOrder() < o2.getRelativeOrder())
- return -1;
- if (o1.getRelativeOrder() > o2.getRelativeOrder())
- return 1;
-
- return 0;
- }
- });
+ Collections.sort(controllerContextCreators, KernelControllerContextComparator.getInstance());
}
finally
{
Added: projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/deployer/kernel/KernelControllerContextComparator.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/deployer/kernel/KernelControllerContextComparator.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/deployer/kernel/KernelControllerContextComparator.java 2009-10-27 10:15:28 UTC (rev 95604)
@@ -0,0 +1,46 @@
+package org.jboss.deployers.vfs.deployer.kernel;
+
+import java.util.Comparator;
+
+import org.jboss.deployers.vfs.spi.deployer.helpers.KernelControllerContextCreator;
+
+/**
+ * Singleton comparator to compare KernelControllerContextCreators by their relative order
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class KernelControllerContextComparator implements Comparator<KernelControllerContextCreator>
+{
+ /** Singleton instance*/
+ private static final KernelControllerContextComparator INSTANCE = new KernelControllerContextComparator();
+
+ private KernelControllerContextComparator()
+ {
+ }
+
+ /**
+ * Get the singleton
+ * @return the singleton KernelControllerContextComparator
+ */
+ public static KernelControllerContextComparator getInstance()
+ {
+ return INSTANCE;
+ }
+
+ /**
+ * Compares two KernelControllerContextCreators' relative orders
+ * @param o1 The first KernelContextCreator
+ * @param o1 The second KernelContextCreator
+ * @return An integer as per the {@link Comparator#compare(Object, Object)} contract
+ */
+ public int compare(KernelControllerContextCreator o1, KernelControllerContextCreator o2)
+ {
+ if (o1.getRelativeOrder() < o2.getRelativeOrder())
+ return -1;
+ if (o1.getRelativeOrder() > o2.getRelativeOrder())
+ return 1;
+
+ return 0;
+ }
+}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list