Return-Path: Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: (qmail 34427 invoked from network); 21 Oct 2009 11:39:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 21 Oct 2009 11:39:47 -0000 Received: (qmail 52358 invoked by uid 500); 21 Oct 2009 11:39:47 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 52287 invoked by uid 500); 21 Oct 2009 11:39:47 -0000 Mailing-List: contact commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list commits@jackrabbit.apache.org Received: (qmail 52278 invoked by uid 99); 21 Oct 2009 11:39:47 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Oct 2009 11:39:47 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Oct 2009 11:39:41 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 30B1D23889E6; Wed, 21 Oct 2009 11:38:52 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r827966 [11/15] - in /jackrabbit/sandbox/JCR-1456: ./ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/management/ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/security... Date: Wed, 21 Oct 2009 11:38:44 -0000 To: commits@jackrabbit.apache.org From: jukka@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20091021113852.30B1D23889E6@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/pom.xml URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/pom.xml?rev=827966&r1=827965&r2=827966&view=diff ============================================================================== --- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/pom.xml (original) +++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/pom.xml Wed Oct 21 11:38:31 2009 @@ -34,6 +34,7 @@ jackrabbit-jcr2spi Jackrabbit JCR to SPI + bundle @@ -48,6 +49,19 @@ + org.apache.felix + maven-bundle-plugin + true + + + + org.apache.jackrabbit.jcr2spi;version=${pom.version};include:=Jcr2spiRepositoryFactory, + org.apache.jackrabbit.jcr2spi.config;version=${pom.version} + + + + + maven-assembly-plugin @@ -110,6 +124,7 @@ concurrent concurrent + test junit Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemCacheImpl.java URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemCacheImpl.java?rev=827966&r1=827965&r2=827966&view=diff ============================================================================== --- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemCacheImpl.java (original) +++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemCacheImpl.java Wed Oct 21 11:38:31 2009 @@ -25,7 +25,6 @@ import javax.jcr.Item; import javax.jcr.RepositoryException; import java.util.Map; -import java.util.Iterator; import java.io.PrintStream; /** @@ -35,7 +34,7 @@ private static Logger log = LoggerFactory.getLogger(ItemCacheImpl.class); - private final Map cache; + private final Map cache; ItemCacheImpl(int maxSize) { cache = new LRUMap(maxSize); @@ -46,7 +45,7 @@ * @see ItemCache#getItem(ItemState) */ public Item getItem(ItemState state) { - return (Item) cache.get(state); + return cache.get(state); } /** @@ -141,10 +140,9 @@ * @see Dumpable#dump(PrintStream) */ public void dump(PrintStream ps) { - Iterator iter = cache.keySet().iterator(); - while (iter.hasNext()) { - ItemState state = (ItemState) iter.next(); - Item item = (Item) cache.get(state); + for (Map.Entry entry : cache.entrySet()) { + ItemState state = entry.getKey(); + Item item = entry.getValue(); if (item.isNode()) { ps.print("Node: "); } else { Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java?rev=827966&r1=827965&r2=827966&view=diff ============================================================================== --- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java (original) +++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java Wed Oct 21 11:38:31 2009 @@ -69,7 +69,8 @@ /** * Listeners (weak references) */ - protected final Map listeners = Collections.synchronizedMap(new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.WEAK)); + protected final Map listeners = + Collections.synchronizedMap(new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.WEAK)); public ItemImpl(SessionImpl session, ItemState state, ItemLifeCycleListener[] listeners) { @@ -365,7 +366,7 @@ */ private void notifyCreated() { // copy listeners to array to avoid ConcurrentModificationException - ItemLifeCycleListener[] la = (ItemLifeCycleListener[]) listeners.values().toArray(new ItemLifeCycleListener[listeners.size()]); + ItemLifeCycleListener[] la = listeners.values().toArray(new ItemLifeCycleListener[listeners.size()]); for (int i = 0; i < la.length; i++) { la[i].itemCreated(this); } @@ -376,7 +377,7 @@ */ private void notifyUpdated(boolean modified) { // copy listeners to array to avoid ConcurrentModificationException - ItemLifeCycleListener[] la = (ItemLifeCycleListener[]) listeners.values().toArray(new ItemLifeCycleListener[listeners.size()]); + ItemLifeCycleListener[] la = listeners.values().toArray(new ItemLifeCycleListener[listeners.size()]); for (int i = 0; i < la.length; i++) { if (la[i] != null) { la[i].itemUpdated(this, modified); @@ -389,7 +390,7 @@ */ private void notifyDestroyed() { // copy listeners to array to avoid ConcurrentModificationException - ItemLifeCycleListener[] la = (ItemLifeCycleListener[]) listeners.values().toArray(new ItemLifeCycleListener[listeners.size()]); + ItemLifeCycleListener[] la = listeners.values().toArray(new ItemLifeCycleListener[listeners.size()]); for (int i = 0; i < la.length; i++) { if (la[i] != null) { la[i].itemDestroyed(this); Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java?rev=827966&r1=827965&r2=827966&view=diff ============================================================================== --- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java (original) +++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java Wed Oct 21 11:38:31 2009 @@ -225,11 +225,11 @@ // check sanity of session session.checkIsAlive(); - Iterator iter = parentEntry.getNodeEntries(); + Iterator iter = parentEntry.getNodeEntries(); while (iter.hasNext()) { try { // check read access by accessing the nodeState (implicit validation check) - NodeEntry entry = (NodeEntry) iter.next(); + NodeEntry entry = iter.next(); entry.getNodeState(); return true; } catch (ItemNotFoundException e) { @@ -248,7 +248,7 @@ // check sanity of session session.checkIsAlive(); - Iterator it = parentEntry.getNodeEntries(); + Iterator it = parentEntry.getNodeEntries(); return new LazyItemIterator(this, it); } @@ -260,10 +260,10 @@ // check sanity of session session.checkIsAlive(); - Iterator iter = parentEntry.getPropertyEntries(); + Iterator iter = parentEntry.getPropertyEntries(); while (iter.hasNext()) { try { - PropertyEntry entry = (PropertyEntry) iter.next(); + PropertyEntry entry = iter.next(); // check read access by accessing the propState (also implicit validation). entry.getPropertyState(); return true; @@ -283,7 +283,7 @@ // check sanity of session session.checkIsAlive(); - Iterator propEntries = parentEntry.getPropertyEntries(); + Iterator propEntries = parentEntry.getPropertyEntries(); return new LazyItemIterator(this, propEntries); } Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrVersionManager.java URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrVersionManager.java?rev=827966&r1=827965&r2=827966&view=diff ============================================================================== --- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrVersionManager.java (original) +++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrVersionManager.java Wed Oct 21 11:38:31 2009 @@ -214,7 +214,7 @@ // make sure the workspace exists and is accessible for this session. session.checkAccessibleWorkspace(srcWorkspace); - Iterator failedIds = session.getVersionStateManager().merge((NodeState) n.getItemState(), srcWorkspace, bestEffort, isShallow); + Iterator failedIds = session.getVersionStateManager().merge((NodeState) n.getItemState(), srcWorkspace, bestEffort, isShallow); return new LazyItemIterator(itemManager, session.getHierarchyManager(), failedIds); } @@ -322,7 +322,7 @@ public NodeIterator merge(Node activityNode) throws VersionException, AccessDeniedException, MergeException, LockException, InvalidItemStateException, RepositoryException { session.checkIsAlive(); NodeImpl activity = getValidActivity(activityNode, "merge"); - Iterator failedIds = vMgr.mergeActivity((NodeState) activity.getItemState()); + Iterator failedIds = vMgr.mergeActivity((NodeState) activity.getItemState()); return new LazyItemIterator(itemManager, session.getHierarchyManager(), failedIds); } Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/LazyItemIterator.java URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/LazyItemIterator.java?rev=827966&r1=827965&r2=827966&view=diff ============================================================================== --- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/LazyItemIterator.java (original) +++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/LazyItemIterator.java Wed Oct 21 11:38:31 2009 @@ -60,7 +60,7 @@ private final ItemManager itemMgr; /** Iterator over HierarchyEntry elements */ - private final Iterator iter; + private final Iterator iter; /** * The number of items. @@ -81,7 +81,7 @@ * @param itemMgr item manager * @param hierarchyEntryIterator Iterator over HierarchyEntries */ - public LazyItemIterator(ItemManager itemMgr, Iterator hierarchyEntryIterator) { + public LazyItemIterator(ItemManager itemMgr, Iterator hierarchyEntryIterator) { this.itemMgr = itemMgr; this.iter = hierarchyEntryIterator; if (hierarchyEntryIterator instanceof RangeIterator) { @@ -102,12 +102,12 @@ * @param itemIds */ public LazyItemIterator(ItemManager itemMgr, HierarchyManager hierarchyMgr, - Iterator itemIds) + Iterator itemIds) throws ItemNotFoundException, RepositoryException { this.itemMgr = itemMgr; - List entries = new ArrayList(); + List entries = new ArrayList(); while (itemIds.hasNext()) { - ItemId id = (ItemId) itemIds.next(); + ItemId id = itemIds.next(); HierarchyEntry entry; if (id.denotesNode()) { entry = hierarchyMgr.getNodeEntry((NodeId) id); @@ -125,14 +125,14 @@ /** * Prefetches next item. - *

+ *

* {@link #next} is set to the next available item in this iterator or to * null in case there are no more items. */ private Item prefetchNext() { Item nextItem = null; while (nextItem == null && iter.hasNext()) { - HierarchyEntry entry = (HierarchyEntry) iter.next(); + HierarchyEntry entry = iter.next(); try { nextItem = itemMgr.getItem(entry); } catch (RepositoryException e) { @@ -182,7 +182,7 @@ /** * Returns the number of Items in this iterator or -1 if the - * size is unkown. + * size is unknown. *

* Note: The number returned by this method may differ from the number * of Items actually returned by calls to hasNext() / getNextNode(). @@ -216,11 +216,11 @@ // skip the first (skipNum - 1) items without actually retrieving them while (--skipNum > 0) { pos++; - HierarchyEntry entry = (HierarchyEntry) iter.next(); + HierarchyEntry entry = iter.next(); // check if item exists but don't build Item instance. while (!itemMgr.itemExists(entry)) { log.debug("Ignoring nonexistent item " + entry); - entry = (HierarchyEntry) iter.next(); + entry = iter.next(); } } // prefetch final item (the one to be returned on next()) Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceRegistryImpl.java URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceRegistryImpl.java?rev=827966&r1=827965&r2=827966&view=diff ============================================================================== --- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceRegistryImpl.java (original) +++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceRegistryImpl.java Wed Oct 21 11:38:31 2009 @@ -65,16 +65,16 @@ * @see javax.jcr.NamespaceRegistry#getPrefixes() */ public String[] getPrefixes() throws RepositoryException { - Collection prefixes = storage.getRegisteredNamespaces().keySet(); - return (String[]) prefixes.toArray(new String[prefixes.size()]); + Collection prefixes = storage.getRegisteredNamespaces().keySet(); + return prefixes.toArray(new String[prefixes.size()]); } /** * @see javax.jcr.NamespaceRegistry#getURIs() */ public String[] getURIs() throws RepositoryException { - Collection uris = storage.getRegisteredNamespaces().values(); - return (String[]) uris.toArray(new String[uris.size()]); + Collection uris = storage.getRegisteredNamespaces().values(); + return uris.toArray(new String[uris.size()]); } /** Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceStorage.java URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceStorage.java?rev=827966&r1=827965&r2=827966&view=diff ============================================================================== --- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceStorage.java (original) +++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceStorage.java Wed Oct 21 11:38:31 2009 @@ -28,7 +28,7 @@ */ public interface NamespaceStorage { - public Map getRegisteredNamespaces() throws RepositoryException; + public Map getRegisteredNamespaces() throws RepositoryException; public String getPrefix(String uri) throws NamespaceException, RepositoryException; Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java?rev=827966&r1=827965&r2=827966&view=diff ============================================================================== --- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java (original) +++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java Wed Oct 21 11:38:31 2009 @@ -712,7 +712,7 @@ // get mixin types present in the jcr:mixintypes property without // modifying the NodeState. - List mixinValue = getMixinTypes(); + List mixinValue = getMixinTypes(); if (!mixinValue.contains(mixinQName) && !isNodeType(mixinQName)) { if (!canAddMixin(mixinQName)) { throw new ConstraintViolationException("Cannot add '" + mixinName + "' mixin type."); @@ -720,7 +720,7 @@ mixinValue.add(mixinQName); // perform the operation - Operation op = SetMixin.create(getNodeState(), (Name[]) mixinValue.toArray(new Name[mixinValue.size()])); + Operation op = SetMixin.create(getNodeState(), mixinValue.toArray(new Name[mixinValue.size()])); session.getSessionItemStateManager().execute(op); } } @@ -732,7 +732,7 @@ VersionException, ConstraintViolationException, LockException, RepositoryException { checkIsWritable(); Name ntName = getQName(mixinName); - List mixinValue = getMixinTypes(); + List mixinValue = getMixinTypes(); // remove name of target mixin if (!mixinValue.remove(ntName)) { throw new NoSuchNodeTypeException("Cannot remove mixin '" + mixinName + "': Nodetype is not present on this node."); @@ -763,7 +763,7 @@ } // delegate to operation - Name[] mixins = (Name[]) mixinValue.toArray(new Name[mixinValue.size()]); + Name[] mixins = mixinValue.toArray(new Name[mixinValue.size()]); Operation op = SetMixin.create(getNodeState(), mixins); session.getSessionItemStateManager().execute(op); } @@ -777,7 +777,7 @@ * * @return mixin names present with the jcr:mixinTypes property. */ - private List getMixinTypes() { + private List getMixinTypes() { Name[] mixinValue; if (getNodeState().getStatus() == Status.EXISTING) { // jcr:mixinTypes must correspond to the mixins present on the nodestate. @@ -799,7 +799,7 @@ mixinValue = new Name[0]; } } - List l = new ArrayList(); + List l = new ArrayList(); l.addAll(Arrays.asList(mixinValue)); return l; } @@ -812,9 +812,9 @@ * @throws ConstraintViolationException * @throws NoSuchNodeTypeException */ - private EffectiveNodeType getRemainingENT(List remainingMixins) + private EffectiveNodeType getRemainingENT(List remainingMixins) throws ConstraintViolationException, NoSuchNodeTypeException { - Name[] allRemaining = (Name[]) remainingMixins.toArray(new Name[remainingMixins.size() + 1]); + Name[] allRemaining = remainingMixins.toArray(new Name[remainingMixins.size() + 1]); allRemaining[remainingMixins.size()] = getPrimaryNodeTypeName(); return session.getEffectiveNodeTypeProvider().getEffectiveNodeType(allRemaining); } @@ -829,7 +829,7 @@ } try { // first check if node is writable regarding protection status, - // locks, versioning, acces restriction. + // locks, versioning, access restriction. session.getValidator().checkIsWritable(getNodeState(), ItemStateValidator.CHECK_ALL); // then make sure the new mixin would not conflict. return canAddMixin(getQName(mixinName)); @@ -1012,7 +1012,7 @@ } // if root is common ancestor, corresponding path is same as ours - // otherwise access referenceable ancestor and calcuate correspond. path. + // otherwise access referenceable ancestor and calculate correspond. path. String correspondingPath; if (referenceableNode.getDepth() == Path.ROOT_DEPTH) { if (!srcSession.getItemManager().nodeExists(getQPath())) { @@ -1434,8 +1434,8 @@ session.getSessionItemStateManager().execute(an); // finally retrieve the new node - List addedStates = ((AddNode) an).getAddedStates(); - ItemState nState = (ItemState) addedStates.get(0); + List addedStates = ((AddNode) an).getAddedStates(); + ItemState nState = addedStates.get(0); return (Node) getItemManager().getItem(nState.getHierarchyEntry()); } Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/RepositoryImpl.java URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/RepositoryImpl.java?rev=827966&r1=827965&r2=827966&view=diff ============================================================================== --- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/RepositoryImpl.java (original) +++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/RepositoryImpl.java Wed Oct 21 11:38:31 2009 @@ -80,7 +80,7 @@ }); Map descr = config.getRepositoryService().getRepositoryDescriptors(); - descriptors = new HashMap(descr.size()); + descriptors = new HashMap(descr.size()); for (String key : descr.keySet()) { QValue[] qvs = descr.get(key); Value[] vs = new Value[qvs.length]; @@ -172,8 +172,8 @@ if (reference == null) { reference = new Reference(RepositoryImpl.class.getName(), RepositoryImpl.Factory.class.getName(), null); // carry over all addresses from referenceable config - for (Enumeration en = confref.getReference().getAll(); en.hasMoreElements(); ) { - reference.add((RefAddr)(en.nextElement())); + for (Enumeration en = confref.getReference().getAll(); en.hasMoreElements(); ) { + reference.add(en.nextElement()); } // also add the information required by factory class @@ -223,7 +223,7 @@ public static final String RCF = RepositoryImpl.class.getName() + ".factory"; public static final String RCC = RepositoryImpl.class.getName() + ".class"; - public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception { + public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception { Object res = null; if (obj instanceof Reference) { @@ -255,8 +255,8 @@ configFactoryClassName, null); // carry over all arguments except our own - for (Enumeration en = ref.getAll(); en.hasMoreElements(); ){ - RefAddr ra = (RefAddr)en.nextElement(); + for (Enumeration en = ref.getAll(); en.hasMoreElements(); ){ + RefAddr ra = en.nextElement(); String type = ra.getType(); if (! RCF.equals(type) && ! RCC.equals(type)) { newref.add(ra); Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java?rev=827966&r1=827965&r2=827966&view=diff ============================================================================== --- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java (original) +++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java Wed Oct 21 11:38:31 2009 @@ -16,107 +16,104 @@ */ package org.apache.jackrabbit.jcr2spi; -import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeRegistryImpl; -import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeRegistry; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.Semaphore; + +import javax.jcr.AccessDeniedException; +import javax.jcr.InvalidItemStateException; +import javax.jcr.ItemExistsException; +import javax.jcr.ItemNotFoundException; +import javax.jcr.MergeException; +import javax.jcr.NamespaceException; +import javax.jcr.NamespaceRegistry; +import javax.jcr.NoSuchWorkspaceException; +import javax.jcr.PathNotFoundException; +import javax.jcr.ReferentialIntegrityException; +import javax.jcr.RepositoryException; +import javax.jcr.UnsupportedRepositoryOperationException; +import javax.jcr.lock.LockException; +import javax.jcr.nodetype.ConstraintViolationException; +import javax.jcr.nodetype.NoSuchNodeTypeException; +import javax.jcr.query.InvalidQueryException; +import javax.jcr.version.VersionException; + +import org.apache.jackrabbit.jcr2spi.config.CacheBehaviour; +import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyEventListener; +import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyManager; +import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyManagerImpl; +import org.apache.jackrabbit.jcr2spi.nodetype.EffectiveNodeTypeProvider; import org.apache.jackrabbit.jcr2spi.nodetype.ItemDefinitionProvider; import org.apache.jackrabbit.jcr2spi.nodetype.ItemDefinitionProviderImpl; -import org.apache.jackrabbit.jcr2spi.nodetype.EffectiveNodeTypeProvider; import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeCache; -import org.apache.jackrabbit.jcr2spi.state.ItemState; -import org.apache.jackrabbit.jcr2spi.state.ChangeLog; -import org.apache.jackrabbit.jcr2spi.state.UpdatableItemStateManager; -import org.apache.jackrabbit.jcr2spi.state.ItemStateFactory; -import org.apache.jackrabbit.jcr2spi.state.WorkspaceItemStateFactory; -import org.apache.jackrabbit.jcr2spi.state.NodeState; -import org.apache.jackrabbit.jcr2spi.state.TransientItemStateFactory; -import org.apache.jackrabbit.jcr2spi.state.TransientISFactory; -import org.apache.jackrabbit.jcr2spi.state.Status; -import org.apache.jackrabbit.jcr2spi.operation.OperationVisitor; +import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeRegistry; +import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeRegistryImpl; +import org.apache.jackrabbit.jcr2spi.observation.InternalEventListener; +import org.apache.jackrabbit.jcr2spi.operation.AddLabel; import org.apache.jackrabbit.jcr2spi.operation.AddNode; import org.apache.jackrabbit.jcr2spi.operation.AddProperty; +import org.apache.jackrabbit.jcr2spi.operation.Checkin; +import org.apache.jackrabbit.jcr2spi.operation.Checkout; +import org.apache.jackrabbit.jcr2spi.operation.Checkpoint; import org.apache.jackrabbit.jcr2spi.operation.Clone; import org.apache.jackrabbit.jcr2spi.operation.Copy; -import org.apache.jackrabbit.jcr2spi.operation.Move; -import org.apache.jackrabbit.jcr2spi.operation.Remove; -import org.apache.jackrabbit.jcr2spi.operation.SetMixin; -import org.apache.jackrabbit.jcr2spi.operation.SetPropertyValue; -import org.apache.jackrabbit.jcr2spi.operation.ReorderNodes; -import org.apache.jackrabbit.jcr2spi.operation.Operation; -import org.apache.jackrabbit.jcr2spi.operation.Checkout; -import org.apache.jackrabbit.jcr2spi.operation.Checkin; -import org.apache.jackrabbit.jcr2spi.operation.Update; -import org.apache.jackrabbit.jcr2spi.operation.Restore; -import org.apache.jackrabbit.jcr2spi.operation.ResolveMergeConflict; -import org.apache.jackrabbit.jcr2spi.operation.Merge; +import org.apache.jackrabbit.jcr2spi.operation.CreateActivity; +import org.apache.jackrabbit.jcr2spi.operation.CreateConfiguration; import org.apache.jackrabbit.jcr2spi.operation.LockOperation; import org.apache.jackrabbit.jcr2spi.operation.LockRefresh; import org.apache.jackrabbit.jcr2spi.operation.LockRelease; -import org.apache.jackrabbit.jcr2spi.operation.AddLabel; +import org.apache.jackrabbit.jcr2spi.operation.Merge; +import org.apache.jackrabbit.jcr2spi.operation.Move; +import org.apache.jackrabbit.jcr2spi.operation.Operation; +import org.apache.jackrabbit.jcr2spi.operation.OperationVisitor; +import org.apache.jackrabbit.jcr2spi.operation.Remove; +import org.apache.jackrabbit.jcr2spi.operation.RemoveActivity; import org.apache.jackrabbit.jcr2spi.operation.RemoveLabel; import org.apache.jackrabbit.jcr2spi.operation.RemoveVersion; -import org.apache.jackrabbit.jcr2spi.operation.WorkspaceImport; -import org.apache.jackrabbit.jcr2spi.operation.Checkpoint; -import org.apache.jackrabbit.jcr2spi.operation.CreateActivity; -import org.apache.jackrabbit.jcr2spi.operation.CreateConfiguration; -import org.apache.jackrabbit.jcr2spi.operation.RemoveActivity; +import org.apache.jackrabbit.jcr2spi.operation.ReorderNodes; +import org.apache.jackrabbit.jcr2spi.operation.ResolveMergeConflict; +import org.apache.jackrabbit.jcr2spi.operation.Restore; +import org.apache.jackrabbit.jcr2spi.operation.SetMixin; import org.apache.jackrabbit.jcr2spi.operation.SetPrimaryType; +import org.apache.jackrabbit.jcr2spi.operation.SetPropertyValue; +import org.apache.jackrabbit.jcr2spi.operation.Update; +import org.apache.jackrabbit.jcr2spi.operation.WorkspaceImport; import org.apache.jackrabbit.jcr2spi.security.AccessManager; -import org.apache.jackrabbit.jcr2spi.observation.InternalEventListener; -import org.apache.jackrabbit.jcr2spi.config.CacheBehaviour; -import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyEventListener; -import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyManager; -import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyManagerImpl; -import org.apache.jackrabbit.spi.Path; -import org.apache.jackrabbit.spi.Name; -import org.apache.jackrabbit.spi.RepositoryService; -import org.apache.jackrabbit.spi.SessionInfo; -import org.apache.jackrabbit.spi.NodeId; -import org.apache.jackrabbit.spi.IdFactory; -import org.apache.jackrabbit.spi.LockInfo; -import org.apache.jackrabbit.spi.QueryInfo; -import org.apache.jackrabbit.spi.ItemId; -import org.apache.jackrabbit.spi.PropertyId; +import org.apache.jackrabbit.jcr2spi.state.ChangeLog; +import org.apache.jackrabbit.jcr2spi.state.ItemState; +import org.apache.jackrabbit.jcr2spi.state.ItemStateFactory; +import org.apache.jackrabbit.jcr2spi.state.NodeState; +import org.apache.jackrabbit.jcr2spi.state.Status; +import org.apache.jackrabbit.jcr2spi.state.TransientISFactory; +import org.apache.jackrabbit.jcr2spi.state.TransientItemStateFactory; +import org.apache.jackrabbit.jcr2spi.state.UpdatableItemStateManager; +import org.apache.jackrabbit.jcr2spi.state.WorkspaceItemStateFactory; import org.apache.jackrabbit.spi.Batch; +import org.apache.jackrabbit.spi.Event; import org.apache.jackrabbit.spi.EventBundle; import org.apache.jackrabbit.spi.EventFilter; -import org.apache.jackrabbit.spi.QNodeTypeDefinition; -import org.apache.jackrabbit.spi.QValue; -import org.apache.jackrabbit.spi.Event; +import org.apache.jackrabbit.spi.IdFactory; +import org.apache.jackrabbit.spi.ItemId; +import org.apache.jackrabbit.spi.LockInfo; +import org.apache.jackrabbit.spi.Name; import org.apache.jackrabbit.spi.NameFactory; +import org.apache.jackrabbit.spi.NodeId; +import org.apache.jackrabbit.spi.Path; import org.apache.jackrabbit.spi.PathFactory; +import org.apache.jackrabbit.spi.PropertyId; +import org.apache.jackrabbit.spi.QNodeTypeDefinition; +import org.apache.jackrabbit.spi.QValue; +import org.apache.jackrabbit.spi.QueryInfo; +import org.apache.jackrabbit.spi.RepositoryService; +import org.apache.jackrabbit.spi.SessionInfo; import org.apache.jackrabbit.spi.Subscription; import org.apache.jackrabbit.spi.commons.nodetype.NodeTypeStorage; -import org.slf4j.LoggerFactory; import org.slf4j.Logger; - -import javax.jcr.RepositoryException; -import javax.jcr.NamespaceRegistry; -import javax.jcr.UnsupportedRepositoryOperationException; -import javax.jcr.AccessDeniedException; -import javax.jcr.PathNotFoundException; -import javax.jcr.ItemNotFoundException; -import javax.jcr.NamespaceException; -import javax.jcr.NoSuchWorkspaceException; -import javax.jcr.ItemExistsException; -import javax.jcr.InvalidItemStateException; -import javax.jcr.MergeException; -import javax.jcr.ReferentialIntegrityException; -import javax.jcr.query.InvalidQueryException; -import javax.jcr.version.VersionException; -import javax.jcr.lock.LockException; -import javax.jcr.nodetype.NoSuchNodeTypeException; -import javax.jcr.nodetype.ConstraintViolationException; - -import java.util.List; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.Set; -import java.util.HashSet; -import java.util.Map; -import java.util.Collection; - -import EDU.oswego.cs.dl.util.concurrent.Sync; -import EDU.oswego.cs.dl.util.concurrent.Mutex; +import org.slf4j.LoggerFactory; /** * WorkspaceManager... @@ -141,11 +138,11 @@ private final ItemDefinitionProvider definitionProvider; /** - * Mutex to synchronize the feed thread with client + * Semaphore to synchronize the feed thread with client * threads that call {@link #execute(Operation)} or {@link * #execute(ChangeLog)}. */ - private final Sync updateSync = new Mutex(); + private final Semaphore updateSync = new Semaphore(1); /** * This is the event polling for changes. If null @@ -162,7 +159,7 @@ * List of event listener that are set on this WorkspaceManager to get * notifications about local and external changes. */ - private final Set listeners = new HashSet(); + private final List listeners = new LinkedList(); /** * The current subscription for change events if there are listeners. @@ -173,6 +170,7 @@ CacheBehaviour cacheBehaviour, int pollTimeout, boolean enableObservation) throws RepositoryException { + this.service = service; this.sessionInfo = sessionInfo; this.cacheBehaviour = cacheBehaviour; @@ -188,7 +186,18 @@ TransientItemStateFactory stateFactory = createItemStateFactory(); this.isf = stateFactory; this.hierarchyManager = createHierarchyManager(stateFactory, idFactory); - createHierarchyListener(hierarchyManager); + + // If cache behavior is observation register a hierarchy listener which is + // notified about all changes. Otherwise just add a hierarchy listener which + // is only notified on changes for which client event listeners have been + // installed. Note: this listener has to be the first one called in order + // for the hierarchy to be consistent with the event (See JCR-2293). + InternalEventListener listener = createHierarchyListener(hierarchyManager); + if (cacheBehaviour == CacheBehaviour.OBSERVATION) { + addEventListener(listener); + } else { + listeners.add(listener); + } } public NamespaceRegistryImpl getNamespaceRegistryImpl() { @@ -241,7 +250,7 @@ * @return lock tokens present with the SessionInfo. * @throws UnsupportedRepositoryOperationException * @throws RepositoryException - * @see org.apache.jackrabbit.spi.SessionInfo#getLockTokens() + * @see org.apache.jackrabbit.spi.SessionInfo#getLockTokens() */ public String[] getLockTokens() throws UnsupportedRepositoryOperationException, RepositoryException { return sessionInfo.getLockTokens(); @@ -306,7 +315,7 @@ */ public String[] checkQueryStatement(String statement, String language, - Map namespaces) + Map namespaces) throws InvalidQueryException, RepositoryException { return service.checkQueryStatement(sessionInfo, statement, language, namespaces); } @@ -322,7 +331,7 @@ * @return * @throws RepositoryException */ - public QueryInfo executeQuery(String statement, String language, Map namespaces, + public QueryInfo executeQuery(String statement, String language, Map namespaces, long limit, long offset, Map boundValues) throws RepositoryException { return service.executeQuery(sessionInfo, statement, language, namespaces, limit, offset, boundValues); } @@ -339,12 +348,12 @@ synchronized (listeners) { listeners.add(listener); EventFilter[] filters = getEventFilters(listeners); - if (listeners.size() == 1) { + if (subscription == null) { subscription = service.createSubscription(sessionInfo, filters); } else { service.updateEventFilters(subscription, filters); } - listeners.notify(); + listeners.notifyAll(); } } @@ -430,13 +439,12 @@ * * @param listeners the internal event listeners. */ - private static EventFilter[] getEventFilters(Collection listeners) { - List filters = new ArrayList(); - for (Iterator it = listeners.iterator(); it.hasNext(); ) { - InternalEventListener listener = (InternalEventListener) it.next(); + private static EventFilter[] getEventFilters(Collection listeners) { + List filters = new ArrayList(); + for (InternalEventListener listener : listeners) { filters.addAll(listener.getEventFilters()); } - return (EventFilter[]) filters.toArray(new EventFilter[filters.size()]); + return filters.toArray(new EventFilter[filters.size()]); } /** @@ -469,10 +477,10 @@ */ private NodeTypeRegistryImpl createNodeTypeRegistry(NamespaceRegistry nsRegistry) { NodeTypeStorage ntst = new NodeTypeStorage() { - public Iterator getAllDefinitions() throws RepositoryException { + public Iterator getAllDefinitions() throws RepositoryException { return service.getQNodeTypeDefinitions(sessionInfo); } - public Iterator getDefinitions(Name[] nodeTypeNames) throws NoSuchNodeTypeException, RepositoryException { + public Iterator getDefinitions(Name[] nodeTypeNames) throws NoSuchNodeTypeException, RepositoryException { return service.getQNodeTypeDefinitions(sessionInfo, nodeTypeNames); } public void registerNodeTypes(QNodeTypeDefinition[] nodeTypeDefs, boolean allowUpdate) throws RepositoryException { @@ -533,7 +541,7 @@ /** * Deletes the workspace with the specified name. - * + * * @param name * @throws RepositoryException */ @@ -596,6 +604,11 @@ public synchronized void dispose() { try { updateSync.acquire(); + } catch (InterruptedException e) { + log.warn("Exception while disposing WorkspaceManager: " + e); + return; + } + try { if (changeFeed != null) { disposeChangeFeed = true; changeFeed.interrupt(); @@ -681,7 +694,7 @@ //---------------------------------------------------< NamespaceStorage >--- - public Map getRegisteredNamespaces() throws RepositoryException { + public Map getRegisteredNamespaces() throws RepositoryException { return service.getRegisteredNamespaces(sessionInfo); } @@ -730,8 +743,8 @@ log.debug("received {} event bundles.", new Integer(eventBundles.length)); for (int i = 0; i < eventBundles.length; i++) { log.debug("IsLocal: {}", Boolean.valueOf(eventBundles[i].isLocal())); - for (Iterator it = eventBundles[i].getEvents(); it.hasNext(); ) { - Event e = (Event) it.next(); + for (Iterator it = eventBundles[i].getEvents(); it.hasNext(); ) { + Event e = it.next(); String type; switch (e.getType()) { case Event.NODE_ADDED: @@ -802,9 +815,7 @@ try { ItemState target = changeLog.getTarget(); batch = service.createBatch(sessionInfo, target.getId()); - Iterator it = changeLog.getOperations().iterator(); - while (it.hasNext()) { - Operation op = (Operation) it.next(); + for (Operation op : changeLog.getOperations()) { log.debug("executing " + op.getName()); op.accept(this); } @@ -1015,7 +1026,7 @@ */ public void visit(Merge operation) throws NoSuchWorkspaceException, AccessDeniedException, MergeException, LockException, InvalidItemStateException, RepositoryException { NodeId nId = operation.getNodeId(); - Iterator failed; + Iterator failed; if (operation.isActivityMerge()) { failed = service.mergeActivity(sessionInfo, nId); } else { @@ -1148,10 +1159,10 @@ InternalEventListener[] iel; Subscription subscr; synchronized (listeners) { - while (listeners.isEmpty()) { + while (subscription == null) { listeners.wait(); } - iel = (InternalEventListener[]) listeners.toArray(new InternalEventListener[0]); + iel = listeners.toArray(new InternalEventListener[0]); subscr = subscription; } @@ -1187,4 +1198,5 @@ } } } + } Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeAttic.java URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeAttic.java?rev=827966&r1=827965&r2=827966&view=diff ============================================================================== --- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeAttic.java (original) +++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeAttic.java Wed Oct 21 11:38:31 2009 @@ -20,9 +20,9 @@ import org.slf4j.LoggerFactory; import org.apache.jackrabbit.spi.Name; +import java.util.Iterator; import java.util.Set; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.ArrayList; @@ -33,7 +33,7 @@ private static Logger log = LoggerFactory.getLogger(ChildNodeAttic.class); - private Set attic = new HashSet(); + private Set attic = new HashSet(); ChildNodeAttic() { } @@ -43,8 +43,7 @@ } boolean contains(Name name, int index) { - for (Iterator it = attic.iterator(); it.hasNext();) { - NodeEntryImpl ne = (NodeEntryImpl) it.next(); + for (NodeEntryImpl ne : attic) { if (ne.matches(name, index)) { return true; } @@ -53,8 +52,7 @@ } boolean contains(Name name, int index, String uniqueId) { - for (Iterator it = attic.iterator(); it.hasNext();) { - NodeEntryImpl ne = (NodeEntryImpl) it.next(); + for (NodeEntryImpl ne : attic) { if (uniqueId != null && uniqueId.equals(ne.getUniqueID())) { return true; } else if (ne.matches(name, index)) { @@ -65,10 +63,9 @@ return false; } - List get(Name name) { - List l = new ArrayList(); - for (Iterator it = attic.iterator(); it.hasNext();) { - NodeEntryImpl ne = (NodeEntryImpl) it.next(); + List get(Name name) { + List l = new ArrayList(); + for (NodeEntryImpl ne : attic) { if (ne.matches(name)) { l.add(ne); } @@ -83,8 +80,7 @@ * @return */ NodeEntry get(Name name, int index) { - for (Iterator it = attic.iterator(); it.hasNext();) { - NodeEntryImpl ne = (NodeEntryImpl) it.next(); + for (NodeEntryImpl ne : attic) { if (ne.matches(name, index)) { return ne; } @@ -102,8 +98,7 @@ if (uniqueId == null) { throw new IllegalArgumentException(); } - for (Iterator it = attic.iterator(); it.hasNext();) { - NodeEntryImpl ne = (NodeEntryImpl) it.next(); + for (NodeEntryImpl ne : attic) { if (uniqueId.equals(ne.getUniqueID())) { return ne; } @@ -123,7 +118,7 @@ return false; } - Iterator iterator() { + Iterator iterator() { return attic.iterator(); } Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntries.java URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntries.java?rev=827966&r1=827965&r2=827966&view=diff ============================================================================== --- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntries.java (original) +++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntries.java Wed Oct 21 11:38:31 2009 @@ -53,7 +53,7 @@ * * @return Iterator over all NodeEntry object */ - Iterator iterator(); + Iterator iterator(); /** * Returns a List of NodeEntrys for the @@ -63,7 +63,7 @@ * @param nodeName the child node name. * @return same name sibling nodes with the given nodeName. */ - List get(Name nodeName); + List get(Name nodeName); /** * Returns the NodeEntry with the given Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java?rev=827966&r1=827965&r2=827966&view=diff ============================================================================== --- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java (original) +++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java Wed Oct 21 11:38:31 2009 @@ -78,13 +78,13 @@ * and the complete list will be retrieved only to answer {@link #iterator()} * if the passed boolean is true. */ - ChildNodeEntriesImpl(NodeEntry parent, EntryFactory factory, Iterator childNodeInfos) { + ChildNodeEntriesImpl(NodeEntry parent, EntryFactory factory, Iterator childNodeInfos) { this.parent = parent; this.factory = factory; if (childNodeInfos != null) { while (childNodeInfos.hasNext()) { - ChildInfo ci = (ChildInfo) childNodeInfos.next(); + ChildInfo ci = childNodeInfos.next(); NodeEntry entry = factory.createNodeEntry(parent, ci.getName(), ci.getUniqueID()); add(entry, ci.getIndex()); } @@ -137,7 +137,7 @@ } NodeId id = parent.getWorkspaceId(); - Iterator childNodeInfos = factory.getItemStateFactory().getChildNodeInfos(id); + Iterator childNodeInfos = factory.getItemStateFactory().getChildNodeInfos(id); update(childNodeInfos); } @@ -158,11 +158,11 @@ * @see org.apache.jackrabbit.jcr2spi.operation.Move * @see org.apache.jackrabbit.jcr2spi.operation.ReorderNodes */ - synchronized void update(Iterator childNodeInfos) { + synchronized void update(Iterator childNodeInfos) { // insert missing entries and reorder all if necessary. LinkedEntries.LinkNode prevLN = null; while (childNodeInfos.hasNext()) { - ChildInfo ci = (ChildInfo) childNodeInfos.next(); + ChildInfo ci = childNodeInfos.next(); LinkedEntries.LinkNode ln = entriesByName.getLinkNode(ci.getName(), ci.getIndex(), ci.getUniqueID()); if (ln == null) { // add missing at the correct position. @@ -188,10 +188,10 @@ /** * @see ChildNodeEntries#iterator() */ - public Iterator iterator() { - List l = new ArrayList(entries.size()); - for (Iterator it = entries.linkNodeIterator(); it.hasNext();) { - l.add(((LinkedEntries.LinkNode)it.next()).getNodeEntry()); + public Iterator iterator() { + List l = new ArrayList(entries.size()); + for (Iterator it = entries.linkNodeIterator(); it.hasNext();) { + l.add(it.next().getNodeEntry()); } return Collections.unmodifiableList(l).iterator(); } @@ -199,7 +199,7 @@ /** * @see ChildNodeEntries#get(Name) */ - public List get(Name nodeName) { + public List get(Name nodeName) { return entriesByName.getList(nodeName); } @@ -220,9 +220,7 @@ if (uniqueID == null || nodeName == null) { throw new IllegalArgumentException(); } - Iterator cneIter = get(nodeName).iterator(); - while (cneIter.hasNext()) { - NodeEntry cne = (NodeEntry) cneIter.next(); + for (NodeEntry cne : get(nodeName)) { if (uniqueID.equals(cne.getUniqueID())) { return cne; } @@ -413,8 +411,8 @@ // determine the new position of the reordered node regarding // his siblings. position = 0; - for (Iterator it = entries.linkNodeIterator(); it.hasNext(); ) { - LinkedEntries.LinkNode ln = (LinkedEntries.LinkNode) it.next(); + for (Iterator it = entries.linkNodeIterator(); it.hasNext(); ) { + LinkedEntries.LinkNode ln = it.next(); if (ln == beforeLN) { break; } else if (ln != insertLN && insertName.equals(ln.qName)) { @@ -462,8 +460,8 @@ // determine the new position of the reordered node regarding // his siblings. position = 0; - for (Iterator it = entries.linkNodeIterator(); it.hasNext(); ) { - LinkedEntries.LinkNode ln = (LinkedEntries.LinkNode) it.next(); + for (Iterator it = entries.linkNodeIterator(); it.hasNext(); ) { + LinkedEntries.LinkNode ln = it.next(); if (insertName.equals(ln.qName) && (ln != insertLN)) { position++; } @@ -502,8 +500,8 @@ * @return the matching LinkNode or null */ private LinkedEntries.LinkNode getLinkNode(NodeEntry nodeEntry) { - for (Iterator it = linkNodeIterator(); it.hasNext();) { - LinkedEntries.LinkNode ln = (LinkedEntries.LinkNode) it.next(); + for (Iterator it = linkNodeIterator(); it.hasNext();) { + LinkedEntries.LinkNode ln = it.next(); if (ln.getNodeEntry() == nodeEntry) { return ln; } @@ -608,7 +606,7 @@ /** * @return iterator over all LinkNode entries in this list. */ - private Iterator linkNodeIterator() { + private Iterator linkNodeIterator() { return new LinkNodeIterator(); } @@ -650,7 +648,7 @@ // create a new NodeEntry in order to avoid returning null. if (ne == null && this != header) { ne = factory.createNodeEntry(parent, qName, null); - super.setValue(new SoftReference(ne)); + super.setValue(new SoftReference(ne)); } return ne; } @@ -685,7 +683,7 @@ } //---------------------------------------------------------------------- - private class LinkNodeIterator implements Iterator { + private class LinkNodeIterator implements Iterator { private LinkedEntries.LinkNode next = ((LinkedEntries.LinkNode) header).getNextLinkNode(); private final int expectedModCount = modCount; @@ -695,7 +693,7 @@ return next != header; } - public Object next() { + public LinkedEntries.LinkNode next() { checkModCount(); if (!hasNext()) { throw new NoSuchElementException(); @@ -725,8 +723,8 @@ */ private static class NameMap { - private final Map snsMap = new HashMap(); - private final Map nameMap = new HashMap(); + private final Map snsMap = new HashMap(); + private final Map nameMap = new HashMap(); /** * Return true if more than one NodeEnty with the given name exists. @@ -751,9 +749,9 @@ if (val != null) { return ((LinkedEntries.LinkNode) val).getNodeEntry(); } else { - List l = (List) snsMap.get(qName); + List l = snsMap.get(qName); if (l != null) { - List nodeEntries = new ArrayList(l.size()); + List nodeEntries = new ArrayList(l.size()); for (Iterator it = l.iterator(); it.hasNext();) { LinkedEntries.LinkNode ln = (LinkedEntries.LinkNode) it.next(); nodeEntries.add(ln.getNodeEntry()); @@ -772,16 +770,16 @@ * @param name * @return list of entries or an empty list. */ - public List getList(Name name) { + public List getList(Name name) { Object obj = get(name); if (obj == null) { - return Collections.EMPTY_LIST; + return Collections.emptyList(); } else if (obj instanceof List) { - List l = new ArrayList((List)obj); + List l = new ArrayList((List)obj); return Collections.unmodifiableList(l); } else { // NodeEntry - return Collections.singletonList(obj); + return Collections.singletonList((NodeEntry)obj); } } @@ -807,12 +805,12 @@ throw new IllegalArgumentException("Illegal index " + index); } - LinkedEntries.LinkNode val = (LinkedEntries.LinkNode) nameMap.get(name); + LinkedEntries.LinkNode val = nameMap.get(name); if (val != null) { return (index == Path.INDEX_DEFAULT) ? val : null; } else { // look in snsMap - List l = (List) snsMap.get(name); + List l = snsMap.get(name); int pos = index - 1; // Index of NodeEntry is 1-based return (l != null && pos < l.size()) ? (LinkedEntries.LinkNode) l.get(pos) : null; } @@ -823,14 +821,14 @@ // -> try if any entry matches. // if none matches it be might that entry doesn't have uniqueID // set yet -> search without uniqueID - LinkedEntries.LinkNode val = (LinkedEntries.LinkNode) nameMap.get(name); + LinkedEntries.LinkNode val = nameMap.get(name); if (val != null) { if (uniqueID.equals(val.getNodeEntry().getUniqueID())) { return val; } } else { // look in snsMap - List l = (List) snsMap.get(name); + List l = snsMap.get(name); if (l != null) { for (Iterator it = l.iterator(); it.hasNext();) { LinkedEntries.LinkNode ln = (LinkedEntries.LinkNode) it.next(); @@ -848,15 +846,15 @@ public void put(Name name, int index, LinkedEntries.LinkNode value) { // if 'nameMap' already contains a single entry -> move it to snsMap - LinkedEntries.LinkNode single = (LinkedEntries.LinkNode) nameMap.remove(name); - List l; + LinkedEntries.LinkNode single = nameMap.remove(name); + List l; if (single != null) { - l = new ArrayList(); + l = new ArrayList(); l.add(single); snsMap.put(name, l); } else { // if 'snsMap' already contains list - l = (List) snsMap.get(name); + l = snsMap.get(name); } if (l == null) { @@ -874,18 +872,18 @@ } public LinkedEntries.LinkNode remove(Name name, LinkedEntries.LinkNode value) { - Object rm = nameMap.remove(name); + LinkedEntries.LinkNode rm = nameMap.remove(name); if (rm == null) { - List l = (List) snsMap.get(name); + List l = snsMap.get(name); if (l != null && l.remove(value)) { rm = value; } } - return ((LinkedEntries.LinkNode) rm); + return rm; } public void reorder(Name name, LinkedEntries.LinkNode insertValue, int position) { - List sns = (List) snsMap.get(name); + List sns = snsMap.get(name); if (sns == null) { // no same name siblings -> no special handling required return; @@ -906,12 +904,12 @@ * @param index * @return matching entry or null. */ - private static NodeEntry findMatchingEntry(List siblings, int index) { + private static NodeEntry findMatchingEntry(List siblings, int index) { // shortcut if index can never match if (index > siblings.size()) { return null; } else { - return (NodeEntry) siblings.get(index - 1); + return siblings.get(index - 1); } } } Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildPropertyEntries.java URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildPropertyEntries.java?rev=827966&r1=827965&r2=827966&view=diff ============================================================================== --- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildPropertyEntries.java (original) +++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildPropertyEntries.java Wed Oct 21 11:38:31 2009 @@ -48,14 +48,14 @@ * * @return Collection of all PropertyEntry objects present. */ - public Collection getPropertyEntries(); + public Collection getPropertyEntries(); /** * Returns an unmodifiable collection containing all existing property names. * * @return Collection of Name */ - public Collection getPropertyNames(); + public Collection getPropertyNames(); /** * Adds the new PropertyEntry to this ChildPropertyEntries. @@ -70,7 +70,7 @@ * * @param propertyEntries */ - public void addAll(Collection propertyEntries); + public void addAll(Collection propertyEntries); /** * Remove the collection entry with the given Name. Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildPropertyEntriesImpl.java URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildPropertyEntriesImpl.java?rev=827966&r1=827965&r2=827966&view=diff ============================================================================== --- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildPropertyEntriesImpl.java (original) +++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildPropertyEntriesImpl.java Wed Oct 21 11:38:31 2009 @@ -21,7 +21,6 @@ import org.apache.jackrabbit.spi.Name; import java.util.Map; -import java.util.Iterator; import java.util.Collection; import java.util.HashMap; import java.util.Set; @@ -37,12 +36,12 @@ private static Logger log = LoggerFactory.getLogger(ChildPropertyEntriesImpl.class); - private final Map properties; + private final Map> properties; private final NodeEntry parent; private final EntryFactory factory; ChildPropertyEntriesImpl(NodeEntry parent, EntryFactory factory) { - properties = new HashMap(); + this.properties = new HashMap>(); this.parent = parent; this.factory = factory; } @@ -58,13 +57,13 @@ * @see ChildPropertyEntries#get(Name) */ public PropertyEntry get(Name propertyName) { - Object ref = properties.get(propertyName); + Reference ref = properties.get(propertyName); if (ref == null) { // no entry exists with the given name return null; } - PropertyEntry entry = (PropertyEntry) ((Reference) ref).get(); + PropertyEntry entry = ref.get(); if (entry == null) { // entry has been g-collected -> create new entry and return it. entry = factory.createPropertyEntry(parent, propertyName); @@ -76,11 +75,10 @@ /** * @see ChildPropertyEntries#getPropertyEntries() */ - public Collection getPropertyEntries() { + public Collection getPropertyEntries() { synchronized (properties) { - Set entries = new HashSet(properties.size()); - for (Iterator it = properties.keySet().iterator(); it.hasNext();) { - Name propName = (Name) it.next(); + Set entries = new HashSet(properties.size()); + for (Name propName : properties.keySet()) { entries.add(get(propName)); } return Collections.unmodifiableCollection(entries); @@ -90,7 +88,7 @@ /** * @see ChildPropertyEntries#getPropertyNames() */ - public Collection getPropertyNames() { + public Collection getPropertyNames() { return Collections.unmodifiableCollection(properties.keySet()); } @@ -99,7 +97,7 @@ */ public void add(PropertyEntry propertyEntry) { synchronized (properties) { - Reference ref = new SoftReference(propertyEntry); + Reference ref = new SoftReference(propertyEntry); properties.put(propertyEntry.getName(), ref); } } @@ -107,12 +105,9 @@ /** * @see ChildPropertyEntries#addAll(Collection) */ - public void addAll(Collection propertyEntries) { - for (Iterator it = propertyEntries.iterator(); it.hasNext();) { - Object pe = it.next(); - if (pe instanceof PropertyEntry) { - add((PropertyEntry) pe); - } + public void addAll(Collection propertyEntries) { + for (PropertyEntry pe : propertyEntries) { + add(pe); } } Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/EntryValidation.java URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/EntryValidation.java?rev=827966&r1=827965&r2=827966&view=diff ============================================================================== --- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/EntryValidation.java (original) +++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/EntryValidation.java Wed Oct 21 11:38:31 2009 @@ -39,10 +39,10 @@ * @return true if one of the entries is valid; otherwise * false. */ - static boolean containsValidNodeEntry(Iterator nodeEntries) { + static boolean containsValidNodeEntry(Iterator nodeEntries) { boolean hasValid = false; while (nodeEntries.hasNext() && !hasValid) { - NodeEntry cne = (NodeEntry) nodeEntries.next(); + NodeEntry cne = nodeEntries.next(); hasValid = isValidNodeEntry(cne); } return hasValid; Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEventListener.java URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEventListener.java?rev=827966&r1=827965&r2=827966&view=diff ============================================================================== --- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEventListener.java (original) +++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEventListener.java Wed Oct 21 11:38:31 2009 @@ -16,26 +16,27 @@ */ package org.apache.jackrabbit.jcr2spi.hierarchy; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.apache.jackrabbit.jcr2spi.observation.InternalEventListener; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import javax.jcr.RepositoryException; + import org.apache.jackrabbit.jcr2spi.WorkspaceManager; import org.apache.jackrabbit.jcr2spi.config.CacheBehaviour; -import org.apache.jackrabbit.spi.EventFilter; +import org.apache.jackrabbit.jcr2spi.observation.InternalEventListener; import org.apache.jackrabbit.spi.Event; import org.apache.jackrabbit.spi.EventBundle; +import org.apache.jackrabbit.spi.EventFilter; +import org.apache.jackrabbit.spi.ItemId; import org.apache.jackrabbit.spi.NodeId; import org.apache.jackrabbit.spi.Path; -import org.apache.jackrabbit.spi.ItemId; - -import javax.jcr.RepositoryException; -import java.util.Collection; -import java.util.Collections; -import java.util.Set; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.ArrayList; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * HierarchyEventListener... @@ -59,17 +60,13 @@ filter = wspManager.createEventFilter(Event.ALL_TYPES, root, true, null, null, true); } catch (RepositoryException e) { // spi does not support observation, or another error occurred. + log.debug("Creating event filter for cache behavoir observation failed", e); } if (filter == null) { this.eventFilter = Collections.emptyList(); } else { this.eventFilter = Collections.singletonList(filter); } - try { - wspManager.addEventListener(this); - } catch (RepositoryException e) { - // spi does not support observation, or another error occurred. - } } else { this.eventFilter = Collections.emptyList(); } @@ -85,9 +82,8 @@ /** * Processes events and invalidates cached ItemStates - * accordingly. Note that this performed for both local and non-local changes, - * since workspace operations are reported as local changes as well and - * might have invoked changes (autocreated items etc.). + * accordingly. Note that this is performed for local changes only, + * since workspace operations are reported as local and have been applied already. * * @param eventBundle the events. * @see InternalEventListener#onEvent(EventBundle) @@ -119,8 +115,8 @@ // separately collect the add events Set addEvents = new HashSet(); - for (Iterator it = events.iterator(); it.hasNext();) { - Event event = (Event) it.next(); + for (Iterator it = events.iterator(); it.hasNext();) { + Event event = it.next(); int type = event.getType(); if (type == Event.NODE_REMOVED) { // remember removed nodes separately for proper handling later on. @@ -148,8 +144,8 @@ boolean progress = true; while (!addEvents.isEmpty() && progress) { progress = false; - for (Iterator it = addEvents.iterator(); it.hasNext();) { - Event ev = (Event) it.next(); + for (Iterator it = addEvents.iterator(); it.hasNext();) { + Event ev = it.next(); NodeId parentId = ev.getParentId(); HierarchyEntry parent = null; if (parentId != null) { Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java?rev=827966&r1=827965&r2=827966&view=diff ============================================================================== --- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java (original) +++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java Wed Oct 21 11:38:31 2009 @@ -17,6 +17,7 @@ package org.apache.jackrabbit.jcr2spi.hierarchy; import org.apache.jackrabbit.jcr2spi.state.NodeState; +import org.apache.jackrabbit.spi.ChildInfo; import org.apache.jackrabbit.spi.Name; import org.apache.jackrabbit.spi.Path; import org.apache.jackrabbit.spi.NodeId; @@ -180,7 +181,7 @@ * @return iterator of NodeEntry objects * @throws RepositoryException If an unexpected error occurs. */ - public Iterator getNodeEntries() throws RepositoryException; + public Iterator getNodeEntries() throws RepositoryException; /** * Returns a unmodifiable List of NodeEntrys with the @@ -190,7 +191,7 @@ * @return list of NodeEntry objects * @throws RepositoryException If an unexpected error occurs. */ - public List getNodeEntries(Name nodeName) throws RepositoryException; + public List getNodeEntries(Name nodeName) throws RepositoryException; /** * Creates or updates the ChildNodeEntries of this node. @@ -198,7 +199,7 @@ * @param childInfos * @throws RepositoryException */ - public void setNodeEntries(Iterator childInfos) throws RepositoryException; + public void setNodeEntries(Iterator childInfos) throws RepositoryException; /** * Adds a child NodeEntry to this entry if it not yet present with this @@ -266,7 +267,7 @@ * @return an unmodifiable Iterator over those children that represent valid * PropertyEntries. */ - public Iterator getPropertyEntries(); + public Iterator getPropertyEntries(); /** * Add an existing PropertyEntry with the given name if it is @@ -291,7 +292,7 @@ * @throws ItemExistsException * @throws RepositoryException if an unexpected error occurs. */ - public void setPropertyEntries(Collection propNames) throws ItemExistsException, RepositoryException; + public void setPropertyEntries(Collection propNames) throws ItemExistsException, RepositoryException; /** * Add a new, transient PropertyEntry to this NodeEntry