[webbeans-commits] Webbeans SVN: r2945 - in ri/trunk: impl/src/main/java/org/jboss/webbeans/bean and 6 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Wed Jul 1 12:02:20 EDT 2009


Author: pete.muir at jboss.org
Date: 2009-07-01 12:02:20 -0400 (Wed, 01 Jul 2009)
New Revision: 2945

Added:
   ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/EnumerationIterable.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/EnumerationIterator.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/EnumerationVector.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ListComparator.java
Removed:
   ri/trunk/impl/src/main/java/org/jboss/webbeans/util/EnumerationIterable.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/util/EnumerationIterator.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/util/EnumerationVector.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/util/ListComparator.java
Modified:
   ri/trunk/impl/src/main/java/org/jboss/webbeans/Validator.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/context/beanstore/AbstractAttributeBackedBeanStore.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/resources/DefaultResourceLoader.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Beans.java
   ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockResourceLoader.java
   ri/trunk/tests/src/main/java/org/jboss/webbeans/test/AbstractWebBeansTest.java
Log:
minor changes and repackage utils

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/Validator.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/Validator.java	2009-07-01 15:48:31 UTC (rev 2944)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/Validator.java	2009-07-01 16:02:20 UTC (rev 2945)
@@ -50,10 +50,10 @@
 import org.jboss.webbeans.metadata.cache.MetaAnnotationStore;
 import org.jboss.webbeans.resolution.ResolvableWBClass;
 import org.jboss.webbeans.util.Beans;
-import org.jboss.webbeans.util.ListComparator;
 import org.jboss.webbeans.util.Names;
 import org.jboss.webbeans.util.Proxies;
 import org.jboss.webbeans.util.Reflections;
+import org.jboss.webbeans.util.collections.ListComparator;
 
 /**
  * Checks a list of beans for DeploymentExceptions and their subclasses

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java	2009-07-01 15:48:31 UTC (rev 2944)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java	2009-07-01 16:02:20 UTC (rev 2945)
@@ -44,7 +44,7 @@
 import org.jboss.webbeans.introspector.WBParameter;
 import org.jboss.webbeans.literal.AnyLiteral;
 import org.jboss.webbeans.literal.CurrentLiteral;
-import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Log;
 import org.jboss.webbeans.log.Logging;
 import org.jboss.webbeans.metadata.cache.MergedStereotypes;
 import org.jboss.webbeans.metadata.cache.MetaAnnotationStore;
@@ -67,15 +67,11 @@
    @SuppressWarnings("unchecked")
    private static Set<Class<?>> STANDARD_WEB_BEAN_CLASSES = new HashSet<Class<?>>(Arrays.asList(Event.class, BeanManagerImpl.class, ConversationImpl.class));
 
-   private boolean proxyable; 
+   private boolean proxyable;
 
    /**
-    * Helper class for getting deployment type
+    * Helper method for getting the highest precedence enabled deployment type
     * 
-    * Loops through the enabled deployment types (backwards) and returns the
-    * first one present in the possible deployments type, resulting in the
-    * deployment type of highest priority
-    * 
     * @param enabledDeploymentTypes The currently enabled deployment types
     * @param possibleDeploymentTypes The possible deployment types
     * @return The deployment type
@@ -93,7 +89,7 @@
    }
 
    // Logger
-   private final LogProvider log = Logging.getLogProvider(AbstractBean.class);
+   private final Log log = Logging.getLog(AbstractBean.class);
    // The binding types
    protected Set<Annotation> bindings;
    // The name
@@ -135,7 +131,7 @@
    {
       super(manager);
       this.manager = manager;
-      injectionPoints = new HashSet<WBInjectionPoint<?, ?>>();  
+      injectionPoints = new HashSet<WBInjectionPoint<?, ?>>();
    }
 
    /**
@@ -176,7 +172,7 @@
 
    protected void initDecorates()
    {
-      this.decoratesInjectionPoint = new HashSet<WBInjectionPoint<?,?>>();
+      this.decoratesInjectionPoint = new HashSet<WBInjectionPoint<?, ?>>();
       for (WBInjectionPoint<?, ?> injectionPoint : getAnnotatedInjectionPoints())
       {
          if (injectionPoint.isAnnotationPresent(Decorates.class))
@@ -233,8 +229,7 @@
       if (possibleDeploymentTypes.size() > 0)
       {
          this.deploymentType = getDeploymentType(manager.getEnabledDeploymentTypes(), possibleDeploymentTypes);
-         if (log.isTraceEnabled())
-            log.trace("Deployment type " + deploymentType + " specified by stereotype");
+         log.trace("Deployment type #0 specified by stereotype", deploymentType);
          return;
       }
    }
@@ -298,7 +293,7 @@
          Bean<?> resolvedBean = manager.getBeans(injectionPoint.getJavaClass(), bindings).iterator().next();
          if (passivating)
          {
-            if (Dependent.class.equals(resolvedBean.getScopeType()) && !resolvedBean.isSerializable() && (((injectionPoint instanceof WBField) && !((WBField<?>) injectionPoint).isTransient()) || (injectionPoint instanceof WBParameter)) )
+            if (Dependent.class.equals(resolvedBean.getScopeType()) && !resolvedBean.isSerializable() && (((injectionPoint instanceof WBField) && !((WBField<?>) injectionPoint).isTransient()) || (injectionPoint instanceof WBParameter)))
             {
                return false;
             }
@@ -513,7 +508,8 @@
 
    public boolean isSerializable()
    {
-      // TODO WTF - why are we not caching the serializability of injection points!
+      // TODO WTF - why are we not caching the serializability of injection
+      // points!
       return _serializable && checkInjectionPointsAreSerializable();
    }
 
@@ -551,5 +547,4 @@
       return getAnnotatedItem().isAnnotationPresent(Specializes.class);
    }
 
-
 }

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/context/beanstore/AbstractAttributeBackedBeanStore.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/context/beanstore/AbstractAttributeBackedBeanStore.java	2009-07-01 15:48:31 UTC (rev 2944)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/context/beanstore/AbstractAttributeBackedBeanStore.java	2009-07-01 16:02:20 UTC (rev 2945)
@@ -27,8 +27,8 @@
 import org.jboss.webbeans.context.api.BeanStore;
 import org.jboss.webbeans.log.LogProvider;
 import org.jboss.webbeans.log.Logging;
-import org.jboss.webbeans.util.EnumerationIterable;
 import org.jboss.webbeans.util.Names;
+import org.jboss.webbeans.util.collections.EnumerationIterable;
 
 /**
  * Provides common BeanStore operations

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/resources/DefaultResourceLoader.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/resources/DefaultResourceLoader.java	2009-07-01 15:48:31 UTC (rev 2944)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/resources/DefaultResourceLoader.java	2009-07-01 16:02:20 UTC (rev 2945)
@@ -21,7 +21,7 @@
 
 import org.jboss.webbeans.resources.spi.ResourceLoader;
 import org.jboss.webbeans.resources.spi.ResourceLoadingException;
-import org.jboss.webbeans.util.EnumerationIterable;
+import org.jboss.webbeans.util.collections.EnumerationIterable;
 
 /**
  * A simple resource loader.

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Beans.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Beans.java	2009-07-01 15:48:31 UTC (rev 2944)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Beans.java	2009-07-01 16:02:20 UTC (rev 2945)
@@ -37,6 +37,7 @@
 import org.jboss.webbeans.introspector.WBField;
 import org.jboss.webbeans.metadata.cache.BindingTypeModel;
 import org.jboss.webbeans.metadata.cache.MetaAnnotationStore;
+import org.jboss.webbeans.util.collections.ListComparator;
 
 /**
  * Helper class for bean inspection

Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/EnumerationIterable.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/EnumerationIterable.java	2009-07-01 15:48:31 UTC (rev 2944)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/EnumerationIterable.java	2009-07-01 16:02:20 UTC (rev 2945)
@@ -1,59 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 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.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,  
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.webbeans.util;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * An Enumeration -> Iteratble adaptor
- *  
- * @author Pete Muir
- * @see org.jboss.webbeans.util.EnumerationIterator
- */
-public class EnumerationIterable<T> implements Iterable<T>
-{
-   // The enumeration as a list
-   private final List<T> list = new ArrayList<T>();
-   
-   /**
-    * Constructor
-    * 
-    * @param enumeration The enumeration
-    */
-   public EnumerationIterable(Enumeration<T> enumeration)
-   {
-      while (enumeration.hasMoreElements())
-      {
-         list.add(enumeration.nextElement());
-      }
-   }
-   
-   /**
-    * Gets an iterator
-    * 
-    * @return The iterator
-    */
-   public Iterator<T> iterator()
-   {
-      return Collections.unmodifiableList(list).iterator();
-   }
-   
-}

Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/EnumerationIterator.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/EnumerationIterator.java	2009-07-01 15:48:31 UTC (rev 2944)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/EnumerationIterator.java	2009-07-01 16:02:20 UTC (rev 2945)
@@ -1,70 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 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.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,  
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.webbeans.util;
-
-import java.util.Enumeration;
-import java.util.Iterator;
-
-/**
- * An enumeration -> iterator adapter
- *  
- * @author Pete Muir
- */
-public class EnumerationIterator<T> implements Iterator<T>
-{
-   // The enumeration
-   private Enumeration<T> e;
-
-   /**
-    * Constructor
-    * 
-    * @param e The enumeration
-    */
-   public EnumerationIterator(Enumeration<T> e)
-   {
-      this.e = e;
-   }
-
-   /**
-    * Indicates if there are more items to iterate
-    * 
-    * @return True if more, false otherwise
-    */
-   public boolean hasNext()
-   {
-      return e.hasMoreElements();
-   }
-
-   /**
-    * Gets the next item
-    * 
-    * @return The next items
-    */
-   public T next()
-   {
-      return (T) e.nextElement();
-   }
-
-   /**
-    * Removes an item. Not supported
-    */
-   public void remove()
-   {
-      throw new UnsupportedOperationException();
-   }
-   
-}

Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/EnumerationVector.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/EnumerationVector.java	2009-07-01 15:48:31 UTC (rev 2944)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/EnumerationVector.java	2009-07-01 16:02:20 UTC (rev 2945)
@@ -1,19 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 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.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,  
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.webbeans.util;
-
-

Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/ListComparator.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/ListComparator.java	2009-07-01 15:48:31 UTC (rev 2944)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/ListComparator.java	2009-07-01 16:02:20 UTC (rev 2945)
@@ -1,54 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 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.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,  
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.webbeans.util;
-
-import java.util.Comparator;
-import java.util.List;
-
-/**
- * List comparator based on element location
- * 
- * @author Pete Muir
- * 
- * @param <T>
- */
-public class ListComparator<T> implements Comparator<T>
-{
-   // The source list
-   private List<T> list;
-
-   /**
-    * Constructor
-    * 
-    * @param list The source list
-    */
-   public ListComparator(List<T> list)
-   {
-      this.list = list;
-   }
-
-   /**
-    * Compares the entries
-    */
-   public int compare(T o1, T o2)
-   {
-      int p1 = list.indexOf(o1);
-      int p2 = list.indexOf(o2);
-      return p1 - p2;
-   }
-
-}

Copied: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/EnumerationIterable.java (from rev 2937, ri/trunk/impl/src/main/java/org/jboss/webbeans/util/EnumerationIterable.java)
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/EnumerationIterable.java	                        (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/EnumerationIterable.java	2009-07-01 16:02:20 UTC (rev 2945)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.util.collections;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * An Enumeration -> Iteratble adaptor
+ *  
+ * @author Pete Muir
+ * @see org.jboss.webbeans.util.collections.EnumerationIterator
+ */
+public class EnumerationIterable<T> implements Iterable<T>
+{
+   // The enumeration as a list
+   private final List<T> list = new ArrayList<T>();
+   
+   /**
+    * Constructor
+    * 
+    * @param enumeration The enumeration
+    */
+   public EnumerationIterable(Enumeration<T> enumeration)
+   {
+      while (enumeration.hasMoreElements())
+      {
+         list.add(enumeration.nextElement());
+      }
+   }
+   
+   /**
+    * Gets an iterator
+    * 
+    * @return The iterator
+    */
+   public Iterator<T> iterator()
+   {
+      return Collections.unmodifiableList(list).iterator();
+   }
+   
+}


Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/EnumerationIterable.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Copied: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/EnumerationIterator.java (from rev 2937, ri/trunk/impl/src/main/java/org/jboss/webbeans/util/EnumerationIterator.java)
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/EnumerationIterator.java	                        (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/EnumerationIterator.java	2009-07-01 16:02:20 UTC (rev 2945)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.util.collections;
+
+import java.util.Enumeration;
+import java.util.Iterator;
+
+/**
+ * An enumeration -> iterator adapter
+ *  
+ * @author Pete Muir
+ */
+public class EnumerationIterator<T> implements Iterator<T>
+{
+   // The enumeration
+   private Enumeration<T> e;
+
+   /**
+    * Constructor
+    * 
+    * @param e The enumeration
+    */
+   public EnumerationIterator(Enumeration<T> e)
+   {
+      this.e = e;
+   }
+
+   /**
+    * Indicates if there are more items to iterate
+    * 
+    * @return True if more, false otherwise
+    */
+   public boolean hasNext()
+   {
+      return e.hasMoreElements();
+   }
+
+   /**
+    * Gets the next item
+    * 
+    * @return The next items
+    */
+   public T next()
+   {
+      return (T) e.nextElement();
+   }
+
+   /**
+    * Removes an item. Not supported
+    */
+   public void remove()
+   {
+      throw new UnsupportedOperationException();
+   }
+   
+}


Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/EnumerationIterator.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Copied: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/EnumerationVector.java (from rev 2937, ri/trunk/impl/src/main/java/org/jboss/webbeans/util/EnumerationVector.java)
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/EnumerationVector.java	                        (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/EnumerationVector.java	2009-07-01 16:02:20 UTC (rev 2945)
@@ -0,0 +1,19 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.util.collections;
+
+


Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/EnumerationVector.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Copied: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ListComparator.java (from rev 2937, ri/trunk/impl/src/main/java/org/jboss/webbeans/util/ListComparator.java)
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ListComparator.java	                        (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ListComparator.java	2009-07-01 16:02:20 UTC (rev 2945)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.util.collections;
+
+import java.util.Comparator;
+import java.util.List;
+
+/**
+ * List comparator based on element location
+ * 
+ * @author Pete Muir
+ * 
+ * @param <T>
+ */
+public class ListComparator<T> implements Comparator<T>
+{
+   // The source list
+   private List<T> list;
+
+   /**
+    * Constructor
+    * 
+    * @param list The source list
+    */
+   public ListComparator(List<T> list)
+   {
+      this.list = list;
+   }
+
+   /**
+    * Compares the entries
+    */
+   public int compare(T o1, T o2)
+   {
+      int p1 = list.indexOf(o1);
+      int p2 = list.indexOf(o2);
+      return p1 - p2;
+   }
+
+}


Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ListComparator.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockResourceLoader.java
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockResourceLoader.java	2009-07-01 15:48:31 UTC (rev 2944)
+++ ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockResourceLoader.java	2009-07-01 16:02:20 UTC (rev 2945)
@@ -21,7 +21,7 @@
 
 import org.jboss.webbeans.resources.spi.ResourceLoader;
 import org.jboss.webbeans.resources.spi.ResourceLoadingException;
-import org.jboss.webbeans.util.EnumerationIterable;
+import org.jboss.webbeans.util.collections.EnumerationIterable;
 
 public class MockResourceLoader implements ResourceLoader
 {

Modified: ri/trunk/tests/src/main/java/org/jboss/webbeans/test/AbstractWebBeansTest.java
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/webbeans/test/AbstractWebBeansTest.java	2009-07-01 15:48:31 UTC (rev 2944)
+++ ri/trunk/tests/src/main/java/org/jboss/webbeans/test/AbstractWebBeansTest.java	2009-07-01 16:02:20 UTC (rev 2945)
@@ -24,7 +24,7 @@
 import org.jboss.webbeans.CurrentManager;
 import org.jboss.webbeans.context.DependentContext;
 import org.jboss.webbeans.mock.el.EL;
-import org.jboss.webbeans.util.EnumerationIterable;
+import org.jboss.webbeans.util.collections.EnumerationIterable;
 import org.testng.ITestContext;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;




More information about the weld-commits mailing list