sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1764054 - /sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/observation/ResourceChangeListImpl.java
Date Mon, 10 Oct 2016 10:35:22 GMT
Author: cziegeler
Date: Mon Oct 10 10:35:22 2016
New Revision: 1764054

URL: http://svn.apache.org/viewvc?rev=1764054&view=rev
Log:
SLING-6123 : Pass additional information like the search path to the listeners

Modified:
    sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/observation/ResourceChangeListImpl.java
  (contents, props changed)

Modified: sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/observation/ResourceChangeListImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/observation/ResourceChangeListImpl.java?rev=1764054&r1=1764053&r2=1764054&view=diff
==============================================================================
--- sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/observation/ResourceChangeListImpl.java
(original)
+++ sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/observation/ResourceChangeListImpl.java
Mon Oct 10 10:35:22 2016
@@ -18,14 +18,205 @@
  */
 package org.apache.sling.resourceresolver.impl.observation;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
 import org.apache.sling.api.resource.observation.ResourceChange;
-import java.util.LinkedList;
+import org.apache.sling.api.resource.observation.ResourceChangeList;
+
+public class ResourceChangeListImpl implements ResourceChangeList {
+
+    private final String[] searchPath;
+
+    private boolean locked = false;
+
+    private final ArrayList<ResourceChange> list = new ArrayList<>();
+
+    public ResourceChangeListImpl(final String[] searchPath) {
+        this.searchPath = searchPath;
+    }
+
+    public void lock() {
+        this.locked = true;
+    }
+
+    @Override
+    public int size() {
+        return list.size();
+    }
+
+    @Override
+    public boolean isEmpty() {
+        return list.isEmpty();
+    }
+
+    @Override
+    public boolean contains(final Object o) {
+        return list.contains(o);
+    }
+
+    @Override
+    public Iterator<ResourceChange> iterator() {
+        return list.iterator();
+    }
+
+    @Override
+    public Object[] toArray() {
+        return list.toArray();
+    }
+
+    @Override
+    public <T> T[] toArray(final T[] a) {
+        return list.toArray(a);
+    }
+
+    @Override
+    public boolean add(final ResourceChange e) {
+        if ( this.locked ) {
+            throw new UnsupportedOperationException();
+        }
+        return list.add(e);
+    }
+
+    @Override
+    public boolean remove(final Object o) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public boolean containsAll(final Collection<?> c) {
+        return list.containsAll(c);
+    }
+
+    @Override
+    public boolean addAll(final Collection<? extends ResourceChange> c) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public boolean addAll(final int index, final Collection<? extends ResourceChange>
c) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public boolean removeAll(final Collection<?> c) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public boolean retainAll(final Collection<?> c) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void clear() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public ResourceChange get(final int index) {
+        return list.get(index);
+    }
+
+    @Override
+    public ResourceChange set(final int index, final ResourceChange element) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void add(final int index, final ResourceChange element) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public ResourceChange remove(final int index) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public int indexOf(final Object o) {
+        return list.indexOf(o);
+    }
+
+    @Override
+    public int lastIndexOf(final Object o) {
+        return list.lastIndexOf(o);
+    }
+
+    @Override
+    public ListIterator<ResourceChange> listIterator() {
+        return new UnmodifiableListIterator(list.listIterator());
+    }
+
+    @Override
+    public ListIterator<ResourceChange> listIterator(final int index) {
+        return new UnmodifiableListIterator(list.listIterator(index));
+    }
+
+    @Override
+    public List<ResourceChange> subList(final int fromIndex, final int toIndex) {
+        return list.subList(fromIndex, toIndex);
+    }
+
+    @Override
+    public String[] getSearchPath() {
+        return this.searchPath.clone();
+    }
+
+    private static final class UnmodifiableListIterator implements ListIterator<ResourceChange>
{
+
+        private final ListIterator<ResourceChange> iterator;
+
+        public UnmodifiableListIterator(final ListIterator<ResourceChange> i) {
+            this.iterator = i;
+        }
+
+        @Override
+        public boolean hasNext() {
+            return iterator.hasNext();
+        }
+
+        @Override
+        public ResourceChange next() {
+            return iterator.next();
+        }
+
+        @Override
+        public boolean hasPrevious() {
+            return iterator.hasPrevious();
+        }
+
+        @Override
+        public ResourceChange previous() {
+            return iterator.previous();
+        }
+
+        @Override
+        public int nextIndex() {
+            return iterator.nextIndex();
+        }
+
+        @Override
+        public int previousIndex() {
+            return iterator.previousIndex();
+        }
+
+        @Override
+        public void remove() {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public void set(final ResourceChange e) {
+            throw new UnsupportedOperationException();
+        }
 
-/** TODO fake ResourceChangeListImpl as it's missing from revision 1763899 */
-class ResourceChangeListImpl extends LinkedList<ResourceChange> {
-	ResourceChangeListImpl(String [] ignored) {
-	}
-	
-	void lock() {
-	}
+        @Override
+        public void add(final ResourceChange e) {
+            throw new UnsupportedOperationException();
+        }
+    }
 }

Propchange: sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/observation/ResourceChangeListImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/observation/ResourceChangeListImpl.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url



Mime
View raw message