jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1364067 - in /jackrabbit/oak/trunk: oak-core/ oak-core/src/main/java/org/apache/jackrabbit/oak/core/ oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/ oak-core/src/mai...
Date Sat, 21 Jul 2012 11:40:17 GMT
Author: jukka
Date: Sat Jul 21 11:40:16 2012
New Revision: 1364067

URL: http://svn.apache.org/viewvc?rev=1364067&view=rev
Log:
OAK-200: Replace Commons Collections with Guava

Removed:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/Function1.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/Iterators.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/Predicate.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/Predicates.java
Modified:
    jackrabbit/oak/trunk/oak-core/pom.xml
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryChildNodeEntry.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/ModifiedNodeState.java
    jackrabbit/oak/trunk/oak-it/osgi/src/test/java/org/apache/jackrabbit/oak/osgi/OSGiIT.java
    jackrabbit/oak/trunk/oak-it/osgi/test-bundles.xml
    jackrabbit/oak/trunk/oak-jcr/pom.xml
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/observation/ChangeProcessor.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/MembershipManager.java
    jackrabbit/oak/trunk/oak-parent/pom.xml

Modified: jackrabbit/oak/trunk/oak-core/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/pom.xml?rev=1364067&r1=1364066&r2=1364067&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-core/pom.xml Sat Jul 21 11:40:16 2012
@@ -128,14 +128,9 @@
     </dependency>
 
     <dependency>
-        <groupId>commons-collections</groupId>
-        <artifactId>commons-collections</artifactId>
-        <version>3.2.1</version>
-    </dependency>
-    <dependency>
         <groupId>com.google.guava</groupId>
         <artifactId>guava</artifactId>
-        <version>12.0.1</version>
+        <version>${guava.version}</version>
     </dependency>
 
     <!-- Optional dependencies for different persistence backends -->

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java?rev=1364067&r1=1364066&r2=1364067&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
Sat Jul 21 11:40:16 2012
@@ -28,7 +28,6 @@ import java.util.concurrent.locks.Reentr
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 
-import org.apache.commons.collections.map.ReferenceMap;
 import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
@@ -37,8 +36,10 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeStateBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeStateDiff;
-import org.apache.jackrabbit.oak.util.Function1;
-import org.apache.jackrabbit.oak.util.Iterators;
+
+import com.google.common.base.Function;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.collect.Iterables;
 
 import static org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState.EMPTY_NODE;
 
@@ -223,18 +224,12 @@ public class TreeImpl implements Tree, P
 
     @Override
     public Iterable<Tree> getChildren() {
-        return new Iterable<Tree>() {
-            @Override
-            public Iterator<Tree> iterator() {
-                final NodeState nodeState = getNodeState();
-
-                Iterator<? extends ChildNodeEntry> childEntries =
-                    nodeState.getChildNodeEntries().iterator();
-
-                return Iterators.map(childEntries, new Function1<ChildNodeEntry, Tree>()
{
+        return Iterables.transform(
+                getNodeState().getChildNodeEntries(),
+                new Function<ChildNodeEntry, Tree>() {
                     @Override
-                    public Tree apply(ChildNodeEntry entry) {
-                        String childName = entry.getName();
+                    public Tree apply(ChildNodeEntry input) {
+                        String childName = input.getName();
                         TreeImpl child = children.get(childName);
                         if (child == null) {
                             child = new TreeImpl(root, TreeImpl.this, childName);
@@ -243,8 +238,6 @@ public class TreeImpl implements Tree, P
                         return  child;
                     }
                 });
-            }
-        };
     }
 
     @Override
@@ -399,8 +392,10 @@ public class TreeImpl implements Tree, P
     }
 
     private static class Children implements Iterable<TreeImpl> {
-        @SuppressWarnings("unchecked")
-        private final Map<String, TreeImpl> children = new ReferenceMap();
+
+        private final Map<String, TreeImpl> children =
+                CacheBuilder.newBuilder().weakValues().<String, TreeImpl>build().asMap();
+
         private final Lock readLock;
         private final Lock writeLock;
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java?rev=1364067&r1=1364066&r2=1364067&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java
Sat Jul 21 11:40:16 2012
@@ -42,9 +42,10 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeStateDiff;
-import org.apache.jackrabbit.oak.util.Iterators;
 import org.apache.jackrabbit.oak.util.PagedIterator;
 
+import com.google.common.collect.Iterators;
+
 /**
  * Basic {@link NodeState} implementation based on the {@link MicroKernel}
  * interface. This class makes an attempt to load data lazily.
@@ -170,7 +171,7 @@ final class KernelNodeState extends Abst
         return new Iterable<ChildNodeEntry>() {
             @Override
             public Iterator<ChildNodeEntry> iterator() {
-                return Iterators.flatten(
+                return  Iterators.concat(
                     new PagedIterator<ChildNodeEntry>(MAX_CHILD_NODE_NAMES) {
                         @Override
                         protected Iterator<? extends ChildNodeEntry> getPage(long pos,
int size) {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryChildNodeEntry.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryChildNodeEntry.java?rev=1364067&r1=1364066&r2=1364067&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryChildNodeEntry.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryChildNodeEntry.java
Sat Jul 21 11:40:16 2012
@@ -21,8 +21,9 @@ package org.apache.jackrabbit.oak.plugin
 import org.apache.jackrabbit.oak.spi.state.AbstractChildNodeEntry;
 import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.apache.jackrabbit.oak.util.Function1;
-import org.apache.jackrabbit.oak.util.Iterators;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterators;
 
 import java.util.Iterator;
 import java.util.Map;
@@ -37,14 +38,14 @@ public class MemoryChildNodeEntry extend
 
     public static Iterator<ChildNodeEntry> iterator(
             final Iterator<Entry<String, NodeState>> iterator) {
-
-        return Iterators.map(iterator,
-                new Function1<Entry<String, NodeState>, ChildNodeEntry>() {
-            @Override
-            public ChildNodeEntry apply(Entry<String, NodeState> entry) {
-                return new MemoryChildNodeEntry(entry);
-            }
-        });
+        return Iterators.transform(
+                iterator,
+                new Function<Entry<String, NodeState>, ChildNodeEntry>() {
+                    @Override
+                    public ChildNodeEntry apply(Entry<String, NodeState> input) {
+                        return new MemoryChildNodeEntry(input);
+                    }
+                });
     }
 
     /**

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/ModifiedNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/ModifiedNodeState.java?rev=1364067&r1=1364066&r2=1364067&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/ModifiedNodeState.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/ModifiedNodeState.java
Sat Jul 21 11:40:16 2012
@@ -21,9 +21,10 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeStateDiff;
-import org.apache.jackrabbit.oak.util.Iterators;
-import org.apache.jackrabbit.oak.util.Predicate;
-import org.apache.jackrabbit.oak.util.Predicates;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+import com.google.common.collect.Iterators;
 
 import java.util.Iterator;
 import java.util.Map;
@@ -85,13 +86,13 @@ public class ModifiedNodeState extends A
         return new Iterable<PropertyState>() {
             @Override
             public Iterator<PropertyState> iterator() {
-                Iterator<PropertyState> a = Iterators.filter(
+                Iterator<? extends PropertyState> a = Iterators.filter(
                         unmodified.iterator(), new UnmodifiedPropertyPredicate());
 
-                Iterator<PropertyState> b = Iterators.filter(
-                        modified.iterator(), Predicates.nonNull());
+                Iterator<? extends PropertyState> b = Iterators.filter(
+                        modified.iterator(), Predicates.notNull());
 
-                return Iterators.chain(a, b);
+                return Iterators.concat(a, b);
             }
         };
     }
@@ -133,13 +134,13 @@ public class ModifiedNodeState extends A
         return new Iterable<ChildNodeEntry>() {
             @Override
             public Iterator<ChildNodeEntry> iterator() {
-                Iterator<ChildNodeEntry> a = Iterators.filter(
+                Iterator<? extends ChildNodeEntry> a = Iterators.filter(
                         unmodified.iterator(), new UnmodifiedChildNodePredicate());
 
                 Iterator<Entry<String, NodeState>> b = Iterators.filter(
                         modified, new UndeletedChildNodePredicate());
 
-                return Iterators.chain(a, MemoryChildNodeEntry.iterator(b));
+                return Iterators.concat(a, MemoryChildNodeEntry.iterator(b));
             }
         };
     }
@@ -229,21 +230,21 @@ public class ModifiedNodeState extends A
 
     private class UnmodifiedPropertyPredicate implements Predicate<PropertyState> {
         @Override
-        public boolean evaluate(PropertyState property) {
+        public boolean apply(PropertyState property) {
             return !properties.containsKey(property.getName());
         }
     }
 
     private class UnmodifiedChildNodePredicate implements Predicate<ChildNodeEntry>
{
         @Override
-        public boolean evaluate(ChildNodeEntry entry) {
+        public boolean apply(ChildNodeEntry entry) {
             return !nodes.containsKey(entry.getName());
         }
     }
 
     private static class UndeletedChildNodePredicate implements Predicate<Entry<?,
?>> {
         @Override
-        public boolean evaluate(Entry<?, ?> entry) {
+        public boolean apply(Entry<?, ?> entry) {
             return entry.getValue() != null;
         }
     }

Modified: jackrabbit/oak/trunk/oak-it/osgi/src/test/java/org/apache/jackrabbit/oak/osgi/OSGiIT.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-it/osgi/src/test/java/org/apache/jackrabbit/oak/osgi/OSGiIT.java?rev=1364067&r1=1364066&r2=1364067&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-it/osgi/src/test/java/org/apache/jackrabbit/oak/osgi/OSGiIT.java
(original)
+++ jackrabbit/oak/trunk/oak-it/osgi/src/test/java/org/apache/jackrabbit/oak/osgi/OSGiIT.java
Sat Jul 21 11:40:16 2012
@@ -49,7 +49,6 @@ public class OSGiIT {
                 mavenBundle("org.apache.felix", "org.apache.felix.scr", "1.6.0"),
                 bundle(new File(base, "jcr.jar").toURI().toURL().toString()),
                 bundle(new File(base, "commons-io.jar").toURI().toURL().toString()),
-                bundle(new File(base, "commons-collections.jar").toURI().toURL().toString()),
                 bundle(new File(base, "guava.jar").toURI().toURL().toString()),
                 bundle(new File(base, "jackrabbit-api.jar").toURI().toURL().toString()),
                 bundle(new File(base, "jackrabbit-jcr-commons.jar").toURI().toURL().toString()),

Modified: jackrabbit/oak/trunk/oak-it/osgi/test-bundles.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-it/osgi/test-bundles.xml?rev=1364067&r1=1364066&r2=1364067&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-it/osgi/test-bundles.xml (original)
+++ jackrabbit/oak/trunk/oak-it/osgi/test-bundles.xml Sat Jul 21 11:40:16 2012
@@ -30,7 +30,6 @@
       <includes>
         <include>javax.jcr:jcr</include>
         <include>commons-io:commons-io</include>
-        <include>commons-collections:commons-collections</include>
         <include>com.google.guava:guava</include>
         <include>org.apache.jackrabbit:jackrabbit-api</include>
         <include>org.apache.jackrabbit:jackrabbit-jcr-commons</include>

Modified: jackrabbit/oak/trunk/oak-jcr/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/pom.xml?rev=1364067&r1=1364066&r2=1364067&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-jcr/pom.xml Sat Jul 21 11:40:16 2012
@@ -184,9 +184,9 @@ org.apache.jackrabbit.test.api.observati
     </dependency>
 
     <dependency>
-      <groupId>commons-collections</groupId>
-      <artifactId>commons-collections</artifactId>
-      <version>3.2.1</version>
+        <groupId>com.google.guava</groupId>
+        <artifactId>guava</artifactId>
+        <version>${guava.version}</version>
     </dependency>
     <dependency>
       <groupId>commons-io</groupId>

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java?rev=1364067&r1=1364066&r2=1364067&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
Sat Jul 21 11:40:16 2012
@@ -36,9 +36,10 @@ import org.apache.jackrabbit.oak.api.Pro
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.api.Tree.Status;
 import org.apache.jackrabbit.oak.commons.PathUtils;
-import org.apache.jackrabbit.oak.util.Function1;
-import org.apache.jackrabbit.oak.util.Iterators;
-import org.apache.jackrabbit.oak.util.Predicate;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterators;
 
 /**
  * {@code NodeDelegate} serve as internal representations of {@code Node}s.
@@ -227,11 +228,11 @@ public class NodeDelegate extends ItemDe
                             tree.getChildren().iterator(),
                             new Predicate<Tree>() {
                                 @Override
-                                public boolean evaluate(Tree tree) {
+                                public boolean apply(Tree tree) {
                                     return !ordered.containsKey(tree.getName());
                                 }
                             });
-                    return Iterators.chain(
+                    return Iterators.concat(
                             ordered.values().iterator(),
                             nodeDelegateIterator(remaining));
                 }
@@ -351,14 +352,14 @@ public class NodeDelegate extends ItemDe
 
     private Iterator<NodeDelegate> nodeDelegateIterator(
             Iterator<Tree> childNodeStates) {
-        return Iterators.map(
+        return Iterators.transform(
                 Iterators.filter(childNodeStates, new Predicate<Tree>() {
                     @Override
-                    public boolean evaluate(Tree tree) {
+                    public boolean apply(Tree tree) {
                         return !tree.getName().startsWith(":");
                     }
                 }),
-                new Function1<Tree, NodeDelegate>() {
+                new Function<Tree, NodeDelegate>() {
                     @Override
                     public NodeDelegate apply(Tree state) {
                         return new NodeDelegate(sessionDelegate, state);
@@ -368,14 +369,14 @@ public class NodeDelegate extends ItemDe
 
     private Iterator<PropertyDelegate> propertyDelegateIterator(
             Iterator<? extends PropertyState> properties) {
-        return Iterators.map(
+        return Iterators.transform(
                 Iterators.filter(properties, new Predicate<PropertyState>() {
                     @Override
-                    public boolean evaluate(PropertyState property) {
+                    public boolean apply(PropertyState property) {
                         return !property.getName().startsWith(":");
                     }
                 }),
-                new Function1<PropertyState, PropertyDelegate>() {
+                new Function<PropertyState, PropertyDelegate>() {
                     @Override
                     public PropertyDelegate apply(PropertyState propertyState) {
                         return new PropertyDelegate(sessionDelegate, tree,

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java?rev=1364067&r1=1364066&r2=1364067&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
Sat Jul 21 11:40:16 2012
@@ -68,16 +68,16 @@ import org.apache.jackrabbit.oak.commons
 import org.apache.jackrabbit.oak.core.DefaultConflictHandler;
 import org.apache.jackrabbit.oak.jcr.value.ValueConverter;
 import org.apache.jackrabbit.oak.namepath.NameMapper;
-import org.apache.jackrabbit.oak.util.Function1;
-import org.apache.jackrabbit.oak.util.Iterators;
-import org.apache.jackrabbit.oak.util.Predicate;
 import org.apache.jackrabbit.value.ValueHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterators;
+
 import static javax.jcr.Property.JCR_LOCK_IS_DEEP;
 import static javax.jcr.Property.JCR_LOCK_OWNER;
-import static org.apache.jackrabbit.oak.util.Iterators.filter;
 
 /**
  * {@code NodeImpl}...
@@ -465,10 +465,11 @@ public class NodeImpl extends ItemImpl<N
             throws RepositoryException {
         checkStatus();
 
-        Iterator<NodeDelegate> children = filter(dlg.getChildren(),
+        Iterator<NodeDelegate> children = Iterators.filter(
+                dlg.getChildren(),
                 new Predicate<NodeDelegate>() {
                     @Override
-                    public boolean evaluate(NodeDelegate state) {
+                    public boolean apply(NodeDelegate state) {
                         try {
                             return ItemNameMatcher.matches(toJcrPath(state.getName()), namePattern);
                         } catch (InvalidItemStateException e) {
@@ -485,10 +486,11 @@ public class NodeImpl extends ItemImpl<N
     public NodeIterator getNodes(final String[] nameGlobs) throws RepositoryException {
         checkStatus();
 
-        Iterator<NodeDelegate> children = filter(dlg.getChildren(),
+        Iterator<NodeDelegate> children = Iterators.filter(
+                dlg.getChildren(),
                 new Predicate<NodeDelegate>() {
                     @Override
-                    public boolean evaluate(NodeDelegate state) {
+                    public boolean apply(NodeDelegate state) {
                         try {
                             return ItemNameMatcher.matches(toJcrPath(state.getName()), nameGlobs);
                         } catch (InvalidItemStateException e) {
@@ -529,10 +531,11 @@ public class NodeImpl extends ItemImpl<N
     public PropertyIterator getProperties(final String namePattern) throws RepositoryException
{
         checkStatus();
 
-        Iterator<PropertyDelegate> properties = filter(dlg.getProperties(),
+        Iterator<PropertyDelegate> properties = Iterators.filter(
+                dlg.getProperties(),
                 new Predicate<PropertyDelegate>() {
                     @Override
-                    public boolean evaluate(PropertyDelegate entry) {
+                    public boolean apply(PropertyDelegate entry) {
                         try {
                             return ItemNameMatcher.matches(toJcrPath(entry.getName()), namePattern);
                         } catch (InvalidItemStateException e) {
@@ -549,10 +552,11 @@ public class NodeImpl extends ItemImpl<N
     public PropertyIterator getProperties(final String[] nameGlobs) throws RepositoryException
{
         checkStatus();
 
-        Iterator<PropertyDelegate> propertyNames = filter(dlg.getProperties(),
+        Iterator<PropertyDelegate> propertyNames = Iterators.filter(
+                dlg.getProperties(),
                 new Predicate<PropertyDelegate>() {
                     @Override
-                    public boolean evaluate(PropertyDelegate entry) {
+                    public boolean apply(PropertyDelegate entry) {
                         try {
                             return ItemNameMatcher.matches(toJcrPath(entry.getName()), nameGlobs);
                         } catch (InvalidItemStateException e) {
@@ -1180,17 +1184,20 @@ public class NodeImpl extends ItemImpl<N
     //------------------------------------------------------------< private >---
 
     private static Iterator<Node> nodeIterator(Iterator<NodeDelegate> childNodes)
{
-        return Iterators.map(childNodes, new Function1<NodeDelegate, Node>() {
-            @Override
-            public Node apply(NodeDelegate nodeDelegate) {
-                return new NodeImpl(nodeDelegate);
-            }
-        });
+        return Iterators.transform(
+                childNodes,
+                new Function<NodeDelegate, Node>() {
+                    @Override
+                    public Node apply(NodeDelegate nodeDelegate) {
+                        return new NodeImpl(nodeDelegate);
+                    }
+                });
     }
 
     private static Iterator<Property> propertyIterator(Iterator<PropertyDelegate>
properties) {
-        return Iterators.map(properties,
-                new Function1<PropertyDelegate, Property>() {
+        return Iterators.transform(
+                properties,
+                new Function<PropertyDelegate, Property>() {
                     @Override
                     public Property apply(PropertyDelegate propertyDelegate) {
                         return new PropertyImpl(propertyDelegate);

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/observation/ChangeProcessor.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/observation/ChangeProcessor.java?rev=1364067&r1=1364066&r2=1364067&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/observation/ChangeProcessor.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/observation/ChangeProcessor.java
Sat Jul 21 11:40:16 2012
@@ -33,11 +33,9 @@ import org.apache.jackrabbit.oak.namepat
 import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeStateDiff;
-import org.apache.jackrabbit.oak.util.Function1;
-import org.apache.jackrabbit.oak.util.Iterators;
 
-import static org.apache.jackrabbit.commons.iterator.LazyIteratorChain.chain;
-import static org.apache.jackrabbit.oak.util.Iterators.singleton;
+import com.google.common.base.Function;
+import com.google.common.collect.Iterators;
 
 class ChangeProcessor extends TimerTask {
     private final NamePathMapper namePathMapper;
@@ -93,7 +91,7 @@ class ChangeProcessor extends TimerTask 
         }
 
         public void sendEvents() {
-            Iterator<Event> eventIt = Iterators.flatten(events.iterator());
+            Iterator<Event> eventIt = Iterators.concat(events.iterator());
             if (eventIt.hasNext()) {
                 listener.onEvent(new EventIteratorAdapter(eventIt));
                 events = new ArrayList<Iterator<Event>>(PURGE_LIMIT);
@@ -108,7 +106,7 @@ class ChangeProcessor extends TimerTask 
         public void propertyAdded(PropertyState after) {
             if (!stopped && filterRef.get().include(Event.PROPERTY_ADDED, jcrPath(),
associatedParentNode)) {
                 Event event = generatePropertyEvent(Event.PROPERTY_ADDED, path, after);
-                events.add(Iterators.singleton(event));
+                events.add(Iterators.singletonIterator(event));
             }
         }
 
@@ -116,7 +114,7 @@ class ChangeProcessor extends TimerTask 
         public void propertyChanged(PropertyState before, PropertyState after) {
             if (!stopped && filterRef.get().include(Event.PROPERTY_CHANGED, jcrPath(),
associatedParentNode)) {
                 Event event = generatePropertyEvent(Event.PROPERTY_CHANGED, path, after);
-                events.add(Iterators.singleton(event));
+                events.add(Iterators.singletonIterator(event));
             }
         }
 
@@ -124,7 +122,7 @@ class ChangeProcessor extends TimerTask 
         public void propertyDeleted(PropertyState before) {
             if (!stopped && filterRef.get().include(Event.PROPERTY_REMOVED, jcrPath(),
associatedParentNode)) {
                 Event event = generatePropertyEvent(Event.PROPERTY_REMOVED, path, before);
-                events.add(Iterators.singleton(event));
+                events.add(Iterators.singletonIterator(event));
             }
         }
 
@@ -176,10 +174,9 @@ class ChangeProcessor extends TimerTask 
             if (filter.include(eventType, jcrParentPath, associatedParentNode)) {
                 // TODO support userId, identifier, info, date
                 Event event = new EventImpl(eventType, jcrPath, null, null, null, 0);
-                nodeEvent = singleton(event);
-            }
-            else {
-                nodeEvent = Iterators.empty();
+                nodeEvent = Iterators.singletonIterator(event);
+            } else {
+                nodeEvent = Iterators.emptyIterator();
             }
 
             final int propertyEventType = eventType == Event.NODE_ADDED
@@ -188,33 +185,34 @@ class ChangeProcessor extends TimerTask 
 
             Iterator<Event> propertyEvents;
             if (filter.include(propertyEventType, jcrPath, associatedParentNode)) {
-                propertyEvents = Iterators.map(node.getProperties().iterator(),
-                    new Function1<PropertyState, Event>() {
-                        @Override
-                        public Event apply(PropertyState property) {
-                            return generatePropertyEvent(propertyEventType, path, property);
-                        }
-                    });
-            }
-            else {
-                propertyEvents = Iterators.empty();
+                propertyEvents = Iterators.transform(
+                        node.getProperties().iterator(),
+                        new Function<PropertyState, Event>() {
+                            @Override
+                            public Event apply(PropertyState property) {
+                                return generatePropertyEvent(propertyEventType, path, property);
+                            }
+                        });
+            } else {
+                propertyEvents = Iterators.emptyIterator();
             }
 
             Iterator<Event> childNodeEvents = !stopped && filter.includeChildren(jcrPath)
-                    ? chain(generateChildEvents(eventType, path, node))
-                    : Iterators.<Event>empty();
+                    ? Iterators.concat(generateChildEvents(eventType, path, node))
+                    : Iterators.<Event>emptyIterator();
 
-            return chain(nodeEvent, propertyEvents, childNodeEvents);
+            return Iterators.concat(nodeEvent, propertyEvents, childNodeEvents);
         }
 
         private Iterator<Iterator<Event>> generateChildEvents(final int eventType,
final String parentPath, NodeState node) {
-            return Iterators.map(node.getChildNodeEntries().iterator(),
-                new Function1<ChildNodeEntry, Iterator<Event>>() {
-                    @Override
-                    public Iterator<Event> apply(ChildNodeEntry entry) {
-                        return generateNodeEvents(eventType, parentPath, entry.getName(),
entry.getNodeState());
-                    }
-                });
+            return Iterators.transform(
+                    node.getChildNodeEntries().iterator(),
+                    new Function<ChildNodeEntry, Iterator<Event>>() {
+                        @Override
+                        public Iterator<Event> apply(ChildNodeEntry entry) {
+                            return generateNodeEvents(eventType, parentPath, entry.getName(),
entry.getNodeState());
+                        }
+                    });
         }
 
     }

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/MembershipManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/MembershipManager.java?rev=1364067&r1=1364066&r2=1364067&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/MembershipManager.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/MembershipManager.java
Sat Jul 21 11:40:16 2012
@@ -16,9 +16,6 @@
  */
 package org.apache.jackrabbit.oak.jcr.security.user;
 
-import org.apache.commons.collections.iterators.EmptyIterator;
-import org.apache.commons.collections.iterators.IteratorChain;
-import org.apache.commons.collections.iterators.SingletonIterator;
 import org.apache.jackrabbit.api.security.user.Authorizable;
 import org.apache.jackrabbit.api.security.user.Group;
 import org.apache.jackrabbit.api.security.user.UserManager;
@@ -32,6 +29,8 @@ import org.apache.jackrabbit.oak.jcr.Ses
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.collect.Iterators;
+
 import javax.jcr.Node;
 import javax.jcr.Property;
 import javax.jcr.PropertyIterator;
@@ -238,7 +237,8 @@ class MembershipManager {
             @Override
             public Iterator<Authorizable> next() {
                 Authorizable next = authorizables.next();
-                return new IteratorChain(new SingletonIterator(next), inherited(next));
+                return Iterators.concat(
+                        Iterators.singletonIterator(next), inherited(next));
             }
 
             @Override
@@ -254,7 +254,7 @@ class MembershipManager {
                         log.warn("Could not determine members of " + authorizable, e);
                     }
                 }
-                return EmptyIterator.INSTANCE;
+                return Iterators.emptyIterator();
             }
         };
 
@@ -271,7 +271,9 @@ class MembershipManager {
             @Override
             public Iterator<Group> next() {
                 Group next = (Group) membership.next();
-                return new IteratorChain(new SingletonIterator(next), inherited((AuthorizableImpl)
next));
+                return Iterators.concat(
+                        Iterators.singletonIterator(next),
+                        inherited((AuthorizableImpl) next));
             }
 
             @Override
@@ -287,7 +289,7 @@ class MembershipManager {
                         log.warn("Could not determine members of " + authorizable, e);
                     }
                 }
-                return EmptyIterator.INSTANCE;
+                return Iterators.emptyIterator();
             }
         };
 

Modified: jackrabbit/oak/trunk/oak-parent/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-parent/pom.xml?rev=1364067&r1=1364066&r2=1364067&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-parent/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-parent/pom.xml Sat Jul 21 11:40:16 2012
@@ -41,6 +41,7 @@
       ${project.build.sourceEncoding}
     </project.reporting.outputEncoding>
     <jackrabbit.version>2.6-SNAPSHOT</jackrabbit.version>
+    <guava.version>12.0.1</guava.version>
   </properties>
 
   <issueManagement>



Mime
View raw message