[jbosscache-commits] JBoss Cache SVN: r7278 - in core/branches/flat/src/main/java/org/jboss/starobrno: util and 1 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Wed Dec 10 11:55:30 EST 2008


Author: manik.surtani at jboss.com
Date: 2008-12-10 11:55:29 -0500 (Wed, 10 Dec 2008)
New Revision: 7278

Added:
   core/branches/flat/src/main/java/org/jboss/starobrno/util/BeanUtils.java
   core/branches/flat/src/main/java/org/jboss/starobrno/util/FileLookup.java
   core/branches/flat/src/main/java/org/jboss/starobrno/util/ImmutableListCopy.java
   core/branches/flat/src/main/java/org/jboss/starobrno/util/SimpleImmutableEntry.java
   core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/BoundedExecutors.java
   core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/ConcurrentHashSet.java
   core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/ReclosableLatch.java
   core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/SelfInitializingConcurrentHashMap.java
   core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/WithinThreadExecutor.java
Modified:
   core/branches/flat/src/main/java/org/jboss/starobrno/tree/TreeCacheImpl.java
Log:
Fixed eviction in tree adapter

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/tree/TreeCacheImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/tree/TreeCacheImpl.java	2008-12-10 16:43:27 UTC (rev 7277)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/tree/TreeCacheImpl.java	2008-12-10 16:55:29 UTC (rev 7278)
@@ -166,9 +166,59 @@
 
    public void evict(Fqn fqn, boolean recursive)
    {
-      //TODO: Autogenerated.  Implement me properly
+      boolean removeFromParent;
+      if (recursive)
+      {
+         childFirstEvict(fqn);
+         removeFromParent = true;
+      }
+      else
+      {
+         removeFromParent = evictNode((NodeImpl) getNode(fqn), false);
+      }
+
+      if (!fqn.isRoot() && removeFromParent)
+      {
+         Node parent = getNode(fqn.getParent());
+         parent.removeChild(fqn.getLastElement());
+      }
    }
 
+   private void childFirstEvict(Fqn fqn)
+   {
+      Node n = getNode(fqn);
+      if (n != null)
+      {
+         for (Object childName : n.getChildrenNames())
+         {
+            childFirstEvict(Fqn.fromRelativeElements(fqn, childName));
+         }
+      }
+      evictNode((NodeImpl) n, true);
+   }
+
+   /**
+    * Returns true if the node was completely removed; false if just the data was evicted.
+    *
+    * @param node
+    * @param recursive
+    * @return
+    */
+   private boolean evictNode(NodeImpl node, boolean recursive)
+   {
+      boolean retval = false;
+      if (node != null)
+      {
+         if (recursive || node.getChildrenNames().isEmpty())
+         {
+            cache.evict(node.structureKey);
+            retval = true;
+         }
+         cache.evict(node.dataKey);
+      }
+      return retval;
+   }
+
    public void evict(Fqn fqn)
    {
       startAtomic();

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/util/BeanUtils.java (from rev 7261, core/branches/flat/src/main/java/org/jboss/cache/util/BeanUtils.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/util/BeanUtils.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/util/BeanUtils.java	2008-12-10 16:55:29 UTC (rev 7278)
@@ -0,0 +1,131 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.starobrno.util;
+
+import java.lang.reflect.Method;
+import java.util.Locale;
+
+/**
+ * Simple JavaBean manipulation helper methods
+ *
+ * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
+ * @since 2.1.0
+ */
+public class BeanUtils
+{
+   /**
+    * Retrieves a setter name based on a field name passed in
+    *
+    * @param fieldName field name to find setter for
+    * @return name of setter method
+    */
+   public static String setterName(String fieldName)
+   {
+      StringBuilder sb = new StringBuilder("set");
+      if (fieldName != null && fieldName.length() > 0)
+      {
+         sb.append(fieldName.substring(0, 1).toUpperCase(Locale.ENGLISH));
+         if (fieldName.length() > 1)
+         {
+            sb.append(fieldName.substring(1));
+         }
+      }
+      return sb.toString();
+   }
+
+   /**
+    * Returns a getter for a given class
+    *
+    * @param componentClass class to find getter for
+    * @return name of getter method
+    */
+   public static String getterName(Class componentClass)
+   {
+      if (componentClass == null) return null;
+      StringBuilder sb = new StringBuilder("get");
+      sb.append(componentClass.getSimpleName());
+      return sb.toString();
+   }
+
+   /**
+    * Returns a setter for a given class
+    *
+    * @param componentClass class to find setter for
+    * @return name of getter method
+    */
+   public static String setterName(Class componentClass)
+   {
+      if (componentClass == null) return null;
+      StringBuilder sb = new StringBuilder("set");
+      sb.append(componentClass.getSimpleName());
+      return sb.toString();
+   }
+
+
+   /**
+    * Returns a Method object corresponding to a getter that retrieves an instance of componentClass from target.
+    *
+    * @param target         class that the getter should exist on
+    * @param componentClass component to get
+    * @return Method object, or null of one does not exist
+    */
+   public static Method getterMethod(Class target, Class componentClass)
+   {
+      try
+      {
+         return target.getMethod(getterName(componentClass));
+      }
+      catch (NoSuchMethodException e)
+      {
+         //if (log.isTraceEnabled()) log.trace("Unable to find method " + getterName(componentClass) + " in class " + target);
+         return null;
+      }
+      catch (NullPointerException e)
+      {
+         return null;
+      }
+   }
+
+   /**
+    * Returns a Method object corresponding to a setter that sets an instance of componentClass from target.
+    *
+    * @param target         class that the setter should exist on
+    * @param componentClass component to set
+    * @return Method object, or null of one does not exist
+    */
+   public static Method setterMethod(Class target, Class componentClass)
+   {
+      try
+      {
+         return target.getMethod(setterName(componentClass), componentClass);
+      }
+      catch (NoSuchMethodException e)
+      {
+         //if (log.isTraceEnabled()) log.trace("Unable to find method " + setterName(componentClass) + " in class " + target);
+         return null;
+      }
+      catch (NullPointerException e)
+      {
+         return null;
+      }
+   }
+}


Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/util/BeanUtils.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/util/FileLookup.java (from rev 7261, core/branches/flat/src/main/java/org/jboss/cache/util/FileLookup.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/util/FileLookup.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/util/FileLookup.java	2008-12-10 16:55:29 UTC (rev 7278)
@@ -0,0 +1,109 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.starobrno.util;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+/**
+ * Holds the logic of looking up a file, in the following sequence:
+ * <ol>
+ * <li> try to load it with the curent thread's context ClassLoader</li>
+ * <li> if fails, the system ClassLoader</li>
+ * <li> if fails, try to load it as a file from the disck </li>
+ * </ol>
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 3.0
+ */
+public class FileLookup
+{
+   private static final Log log = LogFactory.getLog(FileLookup.class);
+
+   /**
+    * Looks up the file, see : {@link FileLookup}.
+    *
+    * @param filename might be the name of the file (too look it up in the class path) or an url to a file.
+    * @return an input stream to the file or null if nothing found through all lookup steps.
+    */
+   public InputStream lookupFile(String filename)
+   {
+      InputStream is = getAsInputStreamFromClassLoader(filename);
+      if (is == null)
+      {
+         if (log.isDebugEnabled())
+            log.debug("Unable to find configuration file " + filename + " in classpath; searching for this file on the filesystem instead.");
+         try
+         {
+            is = new FileInputStream(filename);
+         }
+         catch (FileNotFoundException e)
+         {
+            return null;
+         }
+      }
+      return is;
+   }
+
+   protected InputStream getAsInputStreamFromClassLoader(String filename)
+   {
+      ClassLoader cl = Thread.currentThread().getContextClassLoader();
+      InputStream is = cl == null ? null : cl.getResourceAsStream(filename);
+      if (is == null)
+      {
+         // check system class loader
+         is = getClass().getClassLoader().getResourceAsStream(filename);
+      }
+      return is;
+   }
+
+   public URL lookupFileLocation(String filename)
+   {
+      ClassLoader cl = Thread.currentThread().getContextClassLoader();
+      URL u = cl == null ? null : cl.getResource(filename);
+      if (u == null)
+      {
+         // check system class loader
+         u = getClass().getClassLoader().getResource(filename);
+      }
+      if (u == null)
+      {
+         File f = new File(filename);
+         if (f.exists()) try
+         {
+            u = f.toURL();
+         }
+         catch (MalformedURLException e)
+         {
+            // what do we do here?
+         }
+      }
+      return u;
+   }
+}


Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/util/FileLookup.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/util/ImmutableListCopy.java (from rev 7261, core/branches/flat/src/main/java/org/jboss/cache/util/ImmutableListCopy.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/util/ImmutableListCopy.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/util/ImmutableListCopy.java	2008-12-10 16:55:29 UTC (rev 7278)
@@ -0,0 +1,474 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.starobrno.util;
+
+import net.jcip.annotations.Immutable;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.lang.reflect.Array;
+import java.util.*;
+
+/**
+ * A lightweight, read-only copy of a List.  Typically used in place of the common idiom:
+ * <code>
+ * return Collections.unmodifiableList(new ArrayList( myInternalList ));
+ * </code>
+ * <p/>
+ * a it is far more efficient than making a defensive copy and then wrapping the defensive copy in a read-only wrapper.
+ * <p/>
+ * Also used whenever a read-only reference List is needed (such as in Fqns).
+ * <p/>
+ *
+ * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
+ * @since 3.0
+ */
+ at Immutable
+public class ImmutableListCopy<E> extends AbstractList<E> implements Externalizable, Immutables.Immutable
+{
+   private static final long serialVersionUID = 10929568968966L;
+   private E[] elements;
+   private int size;
+
+   /**
+    * Constructs a new ImmutableListCopy.
+    * Required by Serialization.
+    */
+   public ImmutableListCopy()
+   {
+   }
+
+   /**
+    * Only one copy constructor since the list is immutable.
+    *
+    * @param c collection to copy from
+    */
+   @SuppressWarnings("unchecked")
+   public ImmutableListCopy(Collection<? extends E> c)
+   {
+      size = c.size();
+      Object[] el = new Object[size]; // no room for growth;
+      el = c.toArray(el);
+      elements = (E[]) el;
+   }
+
+   /**
+    * Assumes that the array passed in is "safe", i.e., is not referenced from elsewhere.  Use with care!
+    *
+    * @param array to reference
+    */
+   public ImmutableListCopy(E[] array)
+   {
+      size = array.length;
+      elements = array;
+   }
+
+   /**
+    * Utility constructors to allow combining collections
+    *
+    * @param collection1 collection to copy from
+    * @param collection2 collection to copy from
+    */
+   @SuppressWarnings("unchecked")
+   public ImmutableListCopy(Collection<? extends E> collection1, Collection<? extends E> collection2)
+   {
+      size = collection1.size() + collection2.size();
+      elements = (E[]) new Object[size]; // no room for growth;
+      Object[] c1 = new Object[collection1.size()];
+      Object[] c2 = new Object[collection2.size()];
+      c1 = collection1.toArray(c1);
+      c2 = collection2.toArray(c2);
+      System.arraycopy(c1, 0, elements, 0, c1.length);
+      System.arraycopy(c2, 0, elements, c1.length, c2.length);
+   }
+
+   @Override
+   public final int size()
+   {
+      return size;
+   }
+
+   @Override
+   public final boolean isEmpty()
+   {
+      return size == 0;
+   }
+
+   @Override
+   public final boolean contains(Object o)
+   {
+      return indexOf(o) >= 0;
+   }
+
+   @Override
+   public final Iterator<E> iterator()
+   {
+      return new ImmutableIterator();
+   }
+
+   @Override
+   public final Object[] toArray()
+   {
+      Object[] result = new Object[size];
+      System.arraycopy(elements, 0, result, 0, size);
+      return result;
+   }
+
+   @Override
+   @SuppressWarnings("unchecked")
+   public final <T> T[] toArray(T[] a)
+   {
+      if (a.length < size)
+      {
+         a = (T[]) Array.newInstance(a.getClass().getComponentType(), size);
+      }
+      System.arraycopy(elements, 0, a, 0, size);
+      if (a.length > size) a[size] = null;
+      return a;
+   }
+
+   @Override
+   public final boolean add(E o)
+   {
+      throw new UnsupportedOperationException();
+   }
+
+   @Override
+   public final boolean remove(Object o)
+   {
+      throw new UnsupportedOperationException();
+   }
+
+   @Override
+   public final boolean addAll(Collection<? extends E> c)
+   {
+      throw new UnsupportedOperationException();
+   }
+
+   @Override
+   public final boolean addAll(int index, Collection<? extends E> c)
+   {
+      throw new UnsupportedOperationException();
+   }
+
+   @Override
+   public final boolean removeAll(Collection<?> c)
+   {
+      throw new UnsupportedOperationException();
+   }
+
+   @Override
+   public final boolean retainAll(Collection<?> c)
+   {
+      throw new UnsupportedOperationException();
+   }
+
+   public final E get(int index)
+   {
+      if (index >= size || index < 0) throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size);
+      return elements[index];
+   }
+
+   @Override
+   public final int indexOf(Object o)
+   {
+      if (o == null)
+      {
+         for (int i = 0; i < size; i++)
+         {
+            if (elements[i] == null) return i;
+         }
+      }
+      else
+      {
+         for (int i = 0; i < size; i++)
+         {
+            if (o.equals(elements[i])) return i;
+         }
+      }
+      return -1;
+   }
+
+   @Override
+   public final int lastIndexOf(Object o)
+   {
+      if (o == null)
+      {
+         for (int i = size - 1; i >= 0; i--)
+         {
+            if (elements[i] == null) return i;
+         }
+      }
+      else
+      {
+         for (int i = size - 1; i >= 0; i--)
+         {
+            if (o.equals(elements[i])) return i;
+         }
+      }
+      return -1;
+   }
+
+   @Override
+   public final ListIterator<E> listIterator()
+   {
+      return new ImmutableIterator();
+   }
+
+   @Override
+   public final ListIterator<E> listIterator(int index)
+   {
+      return new ImmutableIterator(index);
+   }
+
+   @Override
+   public final List<E> subList(int fromIndex, int toIndex)
+   {
+      return new ImmutableSubList<E>(fromIndex, toIndex);
+   }
+
+   /**
+    * Format:
+    * - entry array size (int)
+    * - elements (Object)
+    *
+    * @param out stream to write to
+    * @throws IOException
+    */
+   public void writeExternal(ObjectOutput out) throws IOException
+   {
+      out.writeInt(size);
+      for (E e : elements) out.writeObject(e);
+   }
+
+   /**
+    * See {@link #writeExternal(java.io.ObjectOutput)} for serialization format
+    *
+    * @param in stream
+    * @throws IOException
+    * @throws ClassNotFoundException
+    */
+   @SuppressWarnings("unchecked")
+   public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+   {
+      size = in.readInt();
+      elements = (E[]) new Object[size];
+      for (int i = 0; i < size; i++) elements[i] = (E) in.readObject();
+   }
+
+   private class ImmutableIterator implements ListIterator<E>
+   {
+      int cursor = 0;
+
+      ImmutableIterator(int index)
+      {
+         if (index < 0 || index > size()) throw new IndexOutOfBoundsException("Index: " + index);
+         cursor = index;
+      }
+
+      ImmutableIterator()
+      {
+      }
+
+      public boolean hasNext()
+      {
+         return cursor != size;
+      }
+
+      public E next()
+      {
+         try
+         {
+            return get(cursor++);
+         }
+         catch (IndexOutOfBoundsException e)
+         {
+            throw new NoSuchElementException();
+         }
+      }
+
+      public void remove()
+      {
+         throw new UnsupportedOperationException();
+      }
+
+      public boolean hasPrevious()
+      {
+         return cursor != 0;
+      }
+
+      public E previous()
+      {
+         try
+         {
+            return get(--cursor);
+         }
+         catch (IndexOutOfBoundsException e)
+         {
+            throw new NoSuchElementException();
+         }
+      }
+
+      public int nextIndex()
+      {
+         return cursor;
+      }
+
+      public int previousIndex()
+      {
+         return cursor - 1;
+      }
+
+      public void set(E o)
+      {
+         throw new UnsupportedOperationException();
+      }
+
+      public void add(E o)
+      {
+         throw new UnsupportedOperationException();
+      }
+   }
+
+   private class ImmutableSubList<E> extends AbstractList<E>
+   {
+      private int offset;
+      private int size;
+
+      ImmutableSubList(int fromIndex, int toIndex)
+      {
+         if (fromIndex < 0 || toIndex > ImmutableListCopy.this.size || fromIndex > toIndex)
+            throw new IllegalArgumentException("fromIndex(" + fromIndex + "), toIndex(" + toIndex + "), size (" + ImmutableListCopy.this.size + "), List=" + ImmutableListCopy.this.toString());
+         offset = fromIndex;
+         size = toIndex - fromIndex;
+      }
+
+      @SuppressWarnings("unchecked")
+      public final E get(int index)
+      {
+         if (index < 0 || index >= size) throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size);
+         return (E) ImmutableListCopy.this.get(index + offset);
+      }
+
+      public final int size()
+      {
+         return size;
+      }
+
+      @Override
+      protected final void removeRange(int fromIndex, int toIndex)
+      {
+         throw new UnsupportedOperationException();
+      }
+
+      @Override
+      public final boolean addAll(Collection<? extends E> c)
+      {
+         throw new UnsupportedOperationException();
+      }
+
+      @Override
+      public final boolean addAll(int index, Collection<? extends E> c)
+      {
+         throw new UnsupportedOperationException();
+      }
+
+      @Override
+      public final Iterator<E> iterator()
+      {
+         return listIterator();
+      }
+
+      @Override
+      public final ListIterator<E> listIterator(final int index)
+      {
+         if (index < 0 || (index != 0 && index >= size))
+            throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size);
+
+         return new ListIterator<E>()
+         {
+            private ListIterator i = ImmutableListCopy.this.listIterator(index + offset);
+
+            public boolean hasNext()
+            {
+               return nextIndex() < size;
+            }
+
+            @SuppressWarnings("unchecked")
+            public E next()
+            {
+               if (hasNext())
+                  return (E) i.next();
+               else
+                  throw new NoSuchElementException();
+            }
+
+            public boolean hasPrevious()
+            {
+               return previousIndex() >= 0;
+            }
+
+            @SuppressWarnings("unchecked")
+            public E previous()
+            {
+               if (hasPrevious())
+                  return (E) i.previous();
+               else
+                  throw new NoSuchElementException();
+            }
+
+            public int nextIndex()
+            {
+               return i.nextIndex() - offset;
+            }
+
+            public int previousIndex()
+            {
+               return i.previousIndex() - offset;
+            }
+
+            public void remove()
+            {
+               throw new UnsupportedOperationException();
+            }
+
+            public void set(E o)
+            {
+               throw new UnsupportedOperationException();
+            }
+
+            public void add(E o)
+            {
+               throw new UnsupportedOperationException();
+            }
+         };
+      }
+
+      @Override
+      public final List<E> subList(int fromIndex, int toIndex)
+      {
+         return new ImmutableSubList<E>(offset + fromIndex, offset + toIndex);
+      }
+   }
+}


Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/util/ImmutableListCopy.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/util/SimpleImmutableEntry.java (from rev 7261, core/branches/flat/src/main/java/org/jboss/cache/util/SimpleImmutableEntry.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/util/SimpleImmutableEntry.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/util/SimpleImmutableEntry.java	2008-12-10 16:55:29 UTC (rev 7278)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.starobrno.util;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.Map.Entry;
+
+/**
+ * Where is Java 1.6?
+ */
+public class SimpleImmutableEntry<K, V> implements Map.Entry<K, V>, Serializable
+{
+   private static final long serialVersionUID = -6092752114794052323L;
+
+   private final K key;
+
+   private final V value;
+
+   public SimpleImmutableEntry(Entry<K, V> me)
+   {
+      key = me.getKey();
+      value = me.getValue();
+   }
+
+   public SimpleImmutableEntry(K key, V value)
+   {
+      this.key = key;
+      this.value = value;
+   }
+
+   public K getKey()
+   {
+      return key;
+   }
+
+   public V getValue()
+   {
+      return value;
+   }
+
+   public V setValue(V arg0)
+   {
+      throw new UnsupportedOperationException();
+   }
+
+   @Override
+   public boolean equals(Object o)
+   {
+      if (!(o instanceof Map.Entry))
+         return false;
+      Map.Entry e2 = (Map.Entry) o;
+      return (getKey() == null ? e2.getKey() == null : getKey().equals(e2.getKey()))
+            && (getValue() == null ? e2.getValue() == null : getValue().equals(e2.getValue()));
+   }
+
+   @Override
+   public int hashCode()
+   {
+      return (getKey() == null ? 0 : getKey().hashCode()) ^
+            (getValue() == null ? 0 : getValue().hashCode());
+   }
+
+   @Override
+   public String toString()
+   {
+      return key + "=" + value;
+   }
+}
\ No newline at end of file


Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/util/SimpleImmutableEntry.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/BoundedExecutors.java (from rev 7261, core/branches/flat/src/main/java/org/jboss/cache/util/concurrent/BoundedExecutors.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/BoundedExecutors.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/BoundedExecutors.java	2008-12-10 16:55:29 UTC (rev 7278)
@@ -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.
+ *
+ * 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.starobrno.util.concurrent;
+
+import java.util.concurrent.*;
+
+/**
+ * Similar to JDK {@link java.util.concurrent.Executors} except that the factory methods here allow you to specify the
+ * size of the blocking queue that backs the executor.
+ *
+ * @author Manik Surtani (<a href="mailto:manik AT jboss DOT org">manik AT jboss DOT org</a>)
+ * @since 3.0
+ */
+public class BoundedExecutors
+{
+   /**
+    * Creates a thread pool that reuses a fixed set of threads
+    * operating off a shared bounded queue. If any thread
+    * terminates due to a failure during execution prior to shutdown,
+    * a new one will take its place if needed to execute subsequent
+    * tasks.
+    *
+    * @param nThreads         the number of threads in the pool
+    * @param boundedQueueSize size of the bounded queue
+    * @return the newly created thread pool
+    */
+   public static ExecutorService newFixedThreadPool(int nThreads, int boundedQueueSize)
+   {
+      return new ThreadPoolExecutor(nThreads, nThreads,
+            0L, TimeUnit.MILLISECONDS,
+            new LinkedBlockingQueue<Runnable>(boundedQueueSize));
+   }
+
+   /**
+    * Creates a thread pool that reuses a fixed set of threads
+    * operating off a shared bounded queue, using the provided
+    * ThreadFactory to create new threads when needed.
+    *
+    * @param nThreads         the number of threads in the pool
+    * @param threadFactory    the factory to use when creating new threads
+    * @param boundedQueueSize size of the bounded queue
+    * @return the newly created thread pool
+    */
+   public static ExecutorService newFixedThreadPool(int nThreads, ThreadFactory threadFactory, int boundedQueueSize)
+   {
+      return new ThreadPoolExecutor(nThreads, nThreads,
+            0L, TimeUnit.MILLISECONDS,
+            new LinkedBlockingQueue<Runnable>(boundedQueueSize),
+            threadFactory);
+   }
+}


Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/BoundedExecutors.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/ConcurrentHashSet.java (from rev 7261, core/branches/flat/src/main/java/org/jboss/cache/util/concurrent/ConcurrentHashSet.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/ConcurrentHashSet.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/ConcurrentHashSet.java	2008-12-10 16:55:29 UTC (rev 7278)
@@ -0,0 +1,144 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.starobrno.util.concurrent;
+
+import java.util.AbstractSet;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * A simple Set implementation backed by a {@link java.util.concurrent.ConcurrentHashMap} to deal with the fact that the
+ * JDK does not have a proper concurrent Set implementation that uses efficient lock striping.
+ * <p/>
+ * Note that values are stored as keys in the underlying Map, with a static dummy object as value.
+ *
+ * @author <a href="mailto:manik at jboss.org">Manik Surtani</a>
+ * @since 2.0.0
+ */
+public class ConcurrentHashSet<E> extends AbstractSet<E>
+{
+   protected ConcurrentHashMap<E, Object> map;
+   private static final Object DUMMY = new Object();
+
+   public ConcurrentHashSet()
+   {
+      map = new ConcurrentHashMap<E, Object>();
+   }
+
+   /**
+    * @param concurrencyLevel passed in to the underlying CHM.  See {@link java.util.concurrent.ConcurrentHashMap#ConcurrentHashMap(int, float, int)} javadocs for details.
+    */
+   public ConcurrentHashSet(int concurrencyLevel)
+   {
+      map = new ConcurrentHashMap<E, Object>(16, 0.75f, concurrencyLevel);
+   }
+
+   /**
+    * Params passed in to the underlying CHM.  See {@link java.util.concurrent.ConcurrentHashMap#ConcurrentHashMap(int, float, int)} javadocs for details.
+    */
+   public ConcurrentHashSet(int initSize, float loadFactor, int concurrencyLevel)
+   {
+      map = new ConcurrentHashMap<E, Object>(initSize, loadFactor, concurrencyLevel);
+   }
+
+
+   @Override
+   public int size()
+   {
+      return map.size();
+   }
+
+   @Override
+   public boolean isEmpty()
+   {
+      return map.isEmpty();
+   }
+
+   @Override
+   public boolean contains(Object o)
+   {
+      return map.containsKey(o);
+   }
+
+   @Override
+   public Iterator<E> iterator()
+   {
+      return map.keySet().iterator();
+   }
+
+   @Override
+   public Object[] toArray()
+   {
+      return map.keySet().toArray();
+   }
+
+   @Override
+   public <T> T[] toArray(T[] a)
+   {
+      return map.keySet().toArray(a);
+   }
+
+   @Override
+   public boolean add(E o)
+   {
+      Object v = map.put(o, DUMMY);
+      return v == null;
+   }
+
+   @Override
+   public boolean remove(Object o)
+   {
+      Object v = map.remove(o);
+      return v != null;
+   }
+
+   @Override
+   public boolean containsAll(Collection<?> c)
+   {
+      return map.keySet().containsAll(c);
+   }
+
+   @Override
+   public boolean addAll(Collection<? extends E> c)
+   {
+      throw new UnsupportedOperationException("Not supported in this implementation since additional locking is required and cannot directly be delegated to multiple calls to ConcurrentHashMap");
+   }
+
+   @Override
+   public boolean retainAll(Collection<?> c)
+   {
+      throw new UnsupportedOperationException("Not supported in this implementation since additional locking is required and cannot directly be delegated to multiple calls to ConcurrentHashMap");
+   }
+
+   @Override
+   public boolean removeAll(Collection<?> c)
+   {
+      throw new UnsupportedOperationException("Not supported in this implementation since additional locking is required and cannot directly be delegated to multiple calls to ConcurrentHashMap");
+   }
+
+   @Override
+   public void clear()
+   {
+      map.clear();
+   }
+}


Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/ConcurrentHashSet.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/ReclosableLatch.java (from rev 7261, core/branches/flat/src/main/java/org/jboss/cache/util/concurrent/ReclosableLatch.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/ReclosableLatch.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/ReclosableLatch.java	2008-12-10 16:55:29 UTC (rev 7278)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.starobrno.util.concurrent;
+
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.AbstractQueuedSynchronizer;
+
+/**
+ * A better impl of {@link org.jboss.cache.util.ThreadGate}, that uses an {@link java.util.concurrent.locks.AbstractQueuedSynchronizer}.
+ * <p/>
+ * This implementation allows you to create a latch with a default state (open or closed), and repeatedly open or close
+ * the latch.
+ *
+ * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
+ * @since 3.0
+ */
+public class ReclosableLatch extends AbstractQueuedSynchronizer
+{
+   // the following states are used in the AQS.
+   private static final int OPEN_STATE = 0, CLOSED_STATE = 1;
+
+   public ReclosableLatch()
+   {
+      setState(CLOSED_STATE);
+   }
+
+   public ReclosableLatch(boolean defaultOpen)
+   {
+      setState(defaultOpen ? OPEN_STATE : CLOSED_STATE);
+   }
+
+   @Override
+   public final int tryAcquireShared(int ignored)
+   {
+      // return 1 if we allow the requestor to proceed, -1 if we want the requestor to block.
+      return getState() == OPEN_STATE ? 1 : -1;
+   }
+
+   @Override
+   public final boolean tryReleaseShared(int state)
+   {
+      // used as a mechanism to set the state of the Sync.
+      setState(state);
+      return true;
+   }
+
+   public final void open()
+   {
+      // do not use setState() directly since this won't notify parked threads.
+      releaseShared(OPEN_STATE);
+   }
+
+   public final void close()
+   {
+      // do not use setState() directly since this won't notify parked threads.
+      releaseShared(CLOSED_STATE);
+   }
+
+   public final void await() throws InterruptedException
+   {
+      acquireSharedInterruptibly(1); // the 1 is a dummy value that is not used.
+   }
+
+   public final boolean await(long time, TimeUnit unit) throws InterruptedException
+   {
+      return tryAcquireSharedNanos(1, unit.toNanos(time)); // the 1 is a dummy value that is not used.
+   }
+}


Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/ReclosableLatch.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/SelfInitializingConcurrentHashMap.java (from rev 7261, core/branches/flat/src/main/java/org/jboss/cache/util/concurrent/SelfInitializingConcurrentHashMap.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/SelfInitializingConcurrentHashMap.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/SelfInitializingConcurrentHashMap.java	2008-12-10 16:55:29 UTC (rev 7278)
@@ -0,0 +1,166 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.starobrno.util.concurrent;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ * Primarily used to hold child maps for nodes.  Underlying CHM is null initially, and once threads start
+ * writing to this map, the CHM is initialized.
+ *
+ * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
+ * @since 3.0
+ */
+public class SelfInitializingConcurrentHashMap<K, V> implements ConcurrentMap<K, V>
+{
+   private volatile ConcurrentMap<K, V> delegate;
+
+   // -------------- initialization methods and helpers ----------------------
+   private ConcurrentMap<K, V> getDelegate()
+   {
+      if (delegate == null) init();
+      return delegate;
+   }
+
+   private synchronized void init()
+   {
+      // Reminiscent of DCL but the delegate here is volatile so construction reordering should not affect.
+      if (delegate == null) delegate = new ConcurrentHashMap<K, V>(1, 0.75f, 4);
+   }
+
+   // -------------- Public API methods that will trigger initialization ----------------------
+
+   public final V put(K key, V value)
+   {
+      return getDelegate().put(key, value);
+   }
+
+   public final V remove(Object key)
+   {
+      return getDelegate().remove(key);
+   }
+
+   public final void putAll(Map<? extends K, ? extends V> m)
+   {
+      getDelegate().putAll(m);
+   }
+
+   public final V putIfAbsent(K key, V value)
+   {
+      return getDelegate().putIfAbsent(key, value);
+   }
+
+   public final boolean replace(K key, V oldValue, V newValue)
+   {
+      return getDelegate().replace(key, oldValue, newValue);
+   }
+
+   public final V replace(K key, V value)
+   {
+      return getDelegate().replace(key, value);
+   }
+
+   // -------------- Public API methods that won't trigger initialization ----------------------
+
+   public final boolean remove(Object key, Object value)
+   {
+      return delegate != null && delegate.remove(key, value);
+   }
+
+   public final int size()
+   {
+      return delegate == null ? 0 : delegate.size();
+   }
+
+   public final boolean isEmpty()
+   {
+      return delegate == null || delegate.isEmpty();
+   }
+
+   public final boolean containsKey(Object key)
+   {
+      return delegate != null && delegate.containsKey(key);
+   }
+
+   public final boolean containsValue(Object value)
+   {
+      return delegate != null && delegate.containsValue(value);
+   }
+
+   public final V get(Object key)
+   {
+      return delegate == null ? null : delegate.get(key);
+   }
+
+   public final void clear()
+   {
+      if (delegate != null) delegate.clear();
+   }
+
+   public final Set<K> keySet()
+   {
+      if (delegate == null || delegate.isEmpty()) return Collections.emptySet();
+      return delegate.keySet();
+   }
+
+   public final Collection<V> values()
+   {
+      if (delegate == null || delegate.isEmpty()) return Collections.emptySet();
+      return delegate.values();
+   }
+
+   public final Set<Entry<K, V>> entrySet()
+   {
+      if (delegate == null || delegate.isEmpty()) return Collections.emptySet();
+      return delegate.entrySet();
+   }
+
+   @Override
+   public String toString()
+   {
+      return "SelfInitializingConcurrentHashMap{" +
+            "delegate=" + delegate +
+            '}';
+   }
+
+   @Override
+   public boolean equals(Object o)
+   {
+      if (this == o) return true;
+      if (o == null || getClass() != o.getClass()) return false;
+      SelfInitializingConcurrentHashMap that = (SelfInitializingConcurrentHashMap) o;
+      return !(delegate != null ? !delegate.equals(that.delegate) : that.delegate != null);
+   }
+
+   @Override
+   public int hashCode()
+   {
+      int result;
+      result = (delegate != null ? delegate.hashCode() : 0);
+      return result;
+   }
+}


Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/SelfInitializingConcurrentHashMap.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/WithinThreadExecutor.java (from rev 7261, core/branches/flat/src/main/java/org/jboss/cache/util/concurrent/WithinThreadExecutor.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/WithinThreadExecutor.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/WithinThreadExecutor.java	2008-12-10 16:55:29 UTC (rev 7278)
@@ -0,0 +1,150 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.starobrno.util.concurrent;
+
+import org.jboss.starobrno.CacheException;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.*;
+
+/**
+ * An executor that works within the current thread.
+ *
+ * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
+ * @see <a href="http://jcip.net/">Java Concurrency In Practice</a>
+ * @since 3.0
+ */
+public class WithinThreadExecutor implements ExecutorService
+{
+   boolean shutDown = false;
+
+   public void execute(Runnable command)
+   {
+      command.run();
+   }
+
+   public void shutdown()
+   {
+      shutDown = true;
+   }
+
+   public List<Runnable> shutdownNow()
+   {
+      shutDown = true;
+      return Collections.emptyList();
+   }
+
+   public boolean isShutdown()
+   {
+      return shutDown;
+   }
+
+   public boolean isTerminated()
+   {
+      return shutDown;
+   }
+
+   public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException
+   {
+      return shutDown;
+   }
+
+   public <T> Future<T> submit(Callable<T> task)
+   {
+      try
+      {
+         final T resp = task.call();
+         return new Future<T>()
+         {
+
+            public boolean cancel(boolean mayInterruptIfRunning)
+            {
+               return false;
+            }
+
+            public boolean isCancelled()
+            {
+               return false;
+            }
+
+            public boolean isDone()
+            {
+               return true;
+            }
+
+            public T get() throws InterruptedException, ExecutionException
+            {
+               return resp;
+            }
+
+            public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
+            {
+               return resp;
+            }
+         };
+      }
+      catch (Exception e)
+      {
+         throw new CacheException(e);
+      }
+   }
+
+   public <T> Future<T> submit(Runnable task, T result)
+   {
+      throw new UnsupportedOperationException();
+   }
+
+   public Future<?> submit(Runnable task)
+   {
+      throw new UnsupportedOperationException();
+   }
+
+   @SuppressWarnings("unchecked")
+   // unchecked on purpose due to http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6267833
+   public List invokeAll(Collection tasks) throws InterruptedException
+   {
+      throw new UnsupportedOperationException();
+   }
+
+   @SuppressWarnings("unchecked")
+   // unchecked on purpose due to http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6267833
+   public List invokeAll(Collection tasks, long timeout, TimeUnit unit) throws InterruptedException
+   {
+      throw new UnsupportedOperationException();
+   }
+
+   @SuppressWarnings("unchecked")
+   // unchecked on purpose due to http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6267833
+   public Object invokeAny(Collection tasks) throws InterruptedException, ExecutionException
+   {
+      throw new UnsupportedOperationException();
+   }
+
+   @SuppressWarnings("unchecked")
+   // unchecked on purpose due to http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6267833
+   public Object invokeAny(Collection tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
+   {
+      throw new UnsupportedOperationException();
+   }
+}


Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/util/concurrent/WithinThreadExecutor.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF




More information about the jbosscache-commits mailing list