jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r785116 - in /jackrabbit/trunk/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/ main/java/org/apache/jackrabbit/core/state/ test/java/org/apache/jackrabbit/core/ test/java/org/apache/jackrabbit/core/data/
Date Tue, 16 Jun 2009 08:53:12 GMT
Author: thomasm
Date: Tue Jun 16 08:53:11 2009
New Revision: 785116

URL: http://svn.apache.org/viewvc?rev=785116&view=rev
Log:
JCR-2087 Upgrade to Java 5 as the base platform

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/BatchedItemOperations.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/CachingHierarchyManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/HierarchyManagerImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/LazyItemIterator.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NamespaceRegistryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/SessionGarbageCollectedTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GarbageCollectorTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/BatchedItemOperations.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/BatchedItemOperations.java?rev=785116&r1=785115&r2=785116&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/BatchedItemOperations.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/BatchedItemOperations.java Tue Jun 16 08:53:11 2009
@@ -434,7 +434,7 @@
 
         // adjust references that refer to uuid's which have been mapped to
         // newly generated uuid's on copy/clone
-        Iterator iter = refTracker.getProcessedReferences();
+        Iterator<Object> iter = refTracker.getProcessedReferences();
         while (iter.hasNext()) {
             PropertyState prop = (PropertyState) iter.next();
             // being paranoid...
@@ -547,8 +547,8 @@
         // 2. check if target state can be removed from old/added to new parent
 
         checkRemoveNode(target, srcParent.getNodeId(),
-                CHECK_ACCESS | CHECK_LOCK | CHECK_VERSIONING | CHECK_CONSTRAINTS |
-                        CHECK_HOLD | CHECK_RETENTION);
+                CHECK_ACCESS | CHECK_LOCK | CHECK_VERSIONING | CHECK_CONSTRAINTS
+                | CHECK_HOLD | CHECK_RETENTION);
         checkAddNode(destParent, destName.getName(),
                 target.getNodeTypeName(), CHECK_ACCESS | CHECK_LOCK
                 | CHECK_VERSIONING | CHECK_CONSTRAINTS | CHECK_HOLD | CHECK_RETENTION);
@@ -1122,7 +1122,7 @@
         }
         NodeState node = stateMgr.createNew(id, nodeTypeName, parent.getNodeId());
         if (mixinNames != null && mixinNames.length > 0) {
-            node.setMixinTypeNames(new HashSet(Arrays.asList(mixinNames)));
+            node.setMixinTypeNames(new HashSet<Name>(Arrays.asList(mixinNames)));
         }
         node.setDefinitionId(def.getId());
 
@@ -1144,16 +1144,12 @@
         }
 
         // add 'auto-create' properties defined in node type
-        PropDef[] pda = ent.getAutoCreatePropDefs();
-        for (int i = 0; i < pda.length; i++) {
-            PropDef pd = pda[i];
+        for (PropDef pd : ent.getAutoCreatePropDefs()) {
             createPropertyState(node, pd.getName(), pd.getRequiredType(), pd);
         }
 
         // recursively add 'auto-create' child nodes defined in node type
-        NodeDef[] nda = ent.getAutoCreateNodeDefs();
-        for (int i = 0; i < nda.length; i++) {
-            NodeDef nd = nda[i];
+        for (NodeDef nd : ent.getAutoCreateNodeDefs()) {
             createNodeState(node, nd.getName(), nd.getDefaultPrimaryType(),
                     null, null, nd);
         }
@@ -1539,13 +1535,12 @@
                 genValues = new InternalValue[]{InternalValue.create(parent.getNodeTypeName())};
             } else if (NameConstants.JCR_MIXINTYPES.equals(name)) {
                 // jcr:mixinTypes property
-                Set mixins = parent.getMixinTypeNames();
-                ArrayList values = new ArrayList(mixins.size());
-                Iterator iter = mixins.iterator();
-                while (iter.hasNext()) {
-                    values.add(InternalValue.create((Name) iter.next()));
+                Set<Name> mixins = parent.getMixinTypeNames();
+                ArrayList<InternalValue> values = new ArrayList<InternalValue>(mixins.size());
+                for (Name n : mixins) {
+                    values.add(InternalValue.create(n));
                 }
-                genValues = (InternalValue[]) values.toArray(new InternalValue[values.size()]);
+                genValues = values.toArray(new InternalValue[values.size()]);
             }
         } else if (NameConstants.NT_HIERARCHYNODE.equals(declaringNT)) {
             // nt:hierarchyNode node type
@@ -1591,10 +1586,10 @@
         if (targetState.hasChildNodeEntries()) {
             // remove child nodes
             // use temp array to avoid ConcurrentModificationException
-            ArrayList tmp = new ArrayList(targetState.getChildNodeEntries());
+            ArrayList<ChildNodeEntry> tmp = new ArrayList<ChildNodeEntry>(targetState.getChildNodeEntries());
             // remove from tail to avoid problems with same-name siblings
             for (int i = tmp.size() - 1; i >= 0; i--) {
-                ChildNodeEntry entry = (ChildNodeEntry) tmp.get(i);
+                ChildNodeEntry entry = tmp.get(i);
                 NodeId nodeId = entry.getId();
                 try {
                     NodeState nodeState = (NodeState) stateMgr.getItemState(nodeId);
@@ -1625,9 +1620,8 @@
 
         // remove properties
         // use temp set to avoid ConcurrentModificationException
-        HashSet tmp = new HashSet(targetState.getPropertyNames());
-        for (Iterator iter = tmp.iterator(); iter.hasNext();) {
-            Name propName = (Name) iter.next();
+        HashSet<Name> tmp = new HashSet<Name>(targetState.getPropertyNames());
+        for (Name propName : tmp) {
             PropertyId propId =
                     new PropertyId(targetState.getNodeId(), propName);
             try {
@@ -1758,9 +1752,7 @@
                 newState.addShare(destParentId);
             }
             // copy child nodes
-            Iterator iter = srcState.getChildNodeEntries().iterator();
-            while (iter.hasNext()) {
-                ChildNodeEntry entry = (ChildNodeEntry) iter.next();
+            for (ChildNodeEntry entry : srcState.getChildNodeEntries()) {
                 Path srcChildPath = PathFactoryImpl.getInstance().create(srcPath, entry.getName(), true);
                 if (!srcAccessMgr.isGranted(srcChildPath, Permission.READ)) {
                     continue;
@@ -1826,9 +1818,7 @@
                 history = manager.getVersionHistory(session, newState, copiedFrom);
             }
             // copy properties
-            iter = srcState.getPropertyNames().iterator();
-            while (iter.hasNext()) {
-                Name propName = (Name) iter.next();
+            for (Name propName : srcState.getPropertyNames()) {
                 Path propPath = PathFactoryImpl.getInstance().create(srcPath, propName, true);
                 if (!srcAccessMgr.canRead(propPath)) {
                     continue;
@@ -1967,7 +1957,7 @@
     private boolean isShareable(NodeState state) throws RepositoryException {
         // shortcut: check some wellknown built-in types first
         Name primary = state.getNodeTypeName();
-        Set mixins = state.getMixinTypeNames();
+        Set<Name> mixins = state.getMixinTypeNames();
         if (mixins.contains(NameConstants.MIX_SHAREABLE)) {
             return true;
         }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/CachingHierarchyManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/CachingHierarchyManager.java?rev=785116&r1=785115&r2=785116&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/CachingHierarchyManager.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/CachingHierarchyManager.java Tue Jun 16 08:53:11 2009
@@ -308,9 +308,8 @@
                 // Item not cached, ignore
                 return;
             }
-            PathMap.Element[] elements = entry.getElements();
-            for (int i = 0; i < elements.length; i++) {
-                Iterator iter = elements[i].getChildren();
+            for (PathMap.Element element : entry.getElements()) {
+                Iterator iter = element.getChildren();
                 while (iter.hasNext()) {
                     PathMap.Element child = (PathMap.Element) iter.next();
                     ChildNodeEntry cne = modified.getChildNodeEntry(
@@ -393,12 +392,11 @@
             if (entry == null) {
                 return;
             }
-            PathMap.Element[] parents = entry.getElements();
-            for (int i = 0; i < parents.length; i++) {
-                HashMap newChildrenOrder = new HashMap();
+            for (PathMap.Element parent : entry.getElements()) {
+                HashMap<Path.Element, PathMap.Element> newChildrenOrder = new HashMap<Path.Element, PathMap.Element>();
                 boolean orderChanged = false;
 
-                Iterator iter = parents[i].getChildren();
+                Iterator iter = parent.getChildren();
                 while (iter.hasNext()) {
                     PathMap.Element child = (PathMap.Element) iter.next();
                     LRUEntry childEntry = (LRUEntry) child.get();
@@ -436,7 +434,7 @@
 
                 if (orderChanged) {
                     /* If at least one child changed its position, reorder */
-                    parents[i].setChildren(newChildrenOrder);
+                    parent.setChildren(newChildrenOrder);
                 }
             }
             checkConsistency();

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/HierarchyManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/HierarchyManagerImpl.java?rev=785116&r1=785115&r2=785116&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/HierarchyManagerImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/HierarchyManagerImpl.java Tue Jun 16 08:53:11 2009
@@ -17,7 +17,6 @@
 package org.apache.jackrabbit.core;
 
 import java.util.Collections;
-import java.util.Iterator;
 import java.util.LinkedHashSet;
 import java.util.Set;
 
@@ -186,7 +185,7 @@
      * @return set of parent <code>NodeId</code>s. If state has no parent,
      *         array has length <code>0</code>.
      */
-    protected Set getParentIds(ItemState state, boolean useOverlayed) {
+    protected Set<NodeId> getParentIds(ItemState state, boolean useOverlayed) {
         if (state.isNode()) {
             // if this is a node, quickly check whether it is shareable and
             // whether it contains more than one parent
@@ -194,18 +193,18 @@
             if (ns.isShareable() && useOverlayed && ns.hasOverlayedState()) {
                 ns = (NodeState) ns.getOverlayedState();
             }
-            Set s = ns.getSharedSet();
+            Set<NodeId> s = ns.getSharedSet();
             if (s.size() > 1) {
                 return s;
             }
         }
         NodeId parentId = getParentId(state);
         if (parentId != null) {
-            LinkedHashSet s = new LinkedHashSet();
+            LinkedHashSet<NodeId> s = new LinkedHashSet<NodeId>();
             s.add(parentId);
             return s;
         }
-        return Collections.EMPTY_SET;
+        return Collections.emptySet();
     }
 
     /**
@@ -577,15 +576,13 @@
         }
         try {
             ItemState state = getItemState(descendant);
-            Set parentIds = getParentIds(state, false);
+            Set<NodeId> parentIds = getParentIds(state, false);
             while (parentIds.size() > 0) {
                 if (parentIds.contains(ancestor)) {
                     return true;
                 }
-                Set grandparentIds = new LinkedHashSet();
-                Iterator iter = parentIds.iterator();
-                while (iter.hasNext()) {
-                    NodeId parentId = (NodeId) iter.next();
+                Set<NodeId> grandparentIds = new LinkedHashSet<NodeId>();
+                for (NodeId parentId : parentIds) {
                     grandparentIds.addAll(getParentIds(getItemState(parentId), false));
                 }
                 parentIds = grandparentIds;
@@ -617,16 +614,14 @@
         int depth = 1;
         try {
             ItemState state = getItemState(descendant);
-            Set parentIds = getParentIds(state, true);
+            Set<NodeId> parentIds = getParentIds(state, true);
             while (parentIds.size() > 0) {
                 if (parentIds.contains(ancestor)) {
                     return depth;
                 }
                 depth++;
-                Set grandparentIds = new LinkedHashSet();
-                Iterator iter = parentIds.iterator();
-                while (iter.hasNext()) {
-                    NodeId parentId = (NodeId) iter.next();
+                Set<NodeId> grandparentIds = new LinkedHashSet<NodeId>();
+                for (NodeId parentId : parentIds) {
                     state = getItemState(parentId);
                     grandparentIds.addAll(getParentIds(state, true));
                 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java?rev=785116&r1=785115&r2=785116&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java Tue Jun 16 08:53:11 2009
@@ -222,17 +222,17 @@
      * @throws InvalidItemStateException
      * @throws RepositoryException
      */
-    private Collection getTransientStates()
+    private Collection<ItemState> getTransientStates()
             throws InvalidItemStateException, RepositoryException {
         // list of transient states that should be persisted
-        ArrayList dirty = new ArrayList();
+        ArrayList<ItemState> dirty = new ArrayList<ItemState>();
         ItemState transientState;
 
         if (isNode()) {
             // build list of 'new' or 'modified' descendants
-            Iterator iter = stateMgr.getDescendantTransientItemStates((NodeId) id);
+            Iterator<ItemState> iter = stateMgr.getDescendantTransientItemStates((NodeId) id);
             while (iter.hasNext()) {
-                transientState = (ItemState) iter.next();
+                transientState = iter.next();
                 // fail-fast test: check status of transient state
                 switch (transientState.getStatus()) {
                     case ItemState.STATUS_NEW:
@@ -312,15 +312,15 @@
      * @throws InvalidItemStateException
      * @throws RepositoryException
      */
-    private Collection getRemovedStates()
+    private Collection<ItemState> getRemovedStates()
             throws InvalidItemStateException, RepositoryException {
-        ArrayList removed = new ArrayList();
+        ArrayList<ItemState> removed = new ArrayList<ItemState>();
         ItemState transientState;
 
         if (isNode()) {
-            Iterator iter = stateMgr.getDescendantTransientItemStatesInAttic((NodeId) id);
+            Iterator<ItemState> iter = stateMgr.getDescendantTransientItemStatesInAttic((NodeId) id);
             while (iter.hasNext()) {
-                transientState = (ItemState) iter.next();
+                transientState = iter.next();
                 // check if stale
                 if (transientState.getStatus() == ItemState.STATUS_STALE_MODIFIED) {
                     String msg = transientState.getId()
@@ -340,7 +340,7 @@
         return removed;
     }
 
-    private void validateTransientItems(Iterator dirtyIter, Iterator removedIter)
+    private void validateTransientItems(Iterator<ItemState> dirtyIter, Iterator<ItemState> removedIter)
             throws AccessDeniedException, ConstraintViolationException,
             RepositoryException {
         /**
@@ -368,7 +368,7 @@
         NodeTypeManagerImpl ntMgr = session.getNodeTypeManager();
         // walk through list of dirty transient items and validate each
         while (dirtyIter.hasNext()) {
-            ItemState itemState = (ItemState) dirtyIter.next();
+            ItemState itemState = dirtyIter.next();
             ItemDefinition def;
             if (itemState.isNode()) {
                 def = ntMgr.getNodeDefinition(((NodeState) itemState).getDefinitionId());
@@ -577,7 +577,7 @@
 
         // walk through list of removed transient items and check REMOVE permission
         while (removedIter.hasNext()) {
-            ItemState itemState = (ItemState) removedIter.next();
+            ItemState itemState = removedIter.next();
             ItemDefinition def;
             if (itemState.isNode()) {
                 def = ntMgr.getNodeDefinition(((NodeState) itemState).getDefinitionId());
@@ -598,14 +598,14 @@
         }
     }
 
-    private void removeTransientItems(Iterator iter) {
+    private void removeTransientItems(Iterator<ItemState> iter) {
 
         /**
          * walk through list of transient items marked 'removed' and
          * definitively remove each one
          */
         while (iter.hasNext()) {
-            ItemState transientState = (ItemState) iter.next();
+            ItemState transientState = iter.next();
             ItemState persistentState = transientState.getOverlayedState();
             /**
              * remove persistent state
@@ -617,22 +617,22 @@
         }
     }
 
-    private void persistTransientItems(Iterator iter)
+    private void persistTransientItems(Iterator<ItemState> iter)
             throws RepositoryException {
 
         // walk through list of transient items and persist each one
         while (iter.hasNext()) {
-            ItemState state = (ItemState) iter.next();
+            ItemState state = iter.next();
             ItemImpl item = itemMgr.getItem(state.getId());
             // persist state of transient item
             item.makePersistent();
         }
     }
 
-    private void restoreTransientItems(Iterator iter) {
+    private void restoreTransientItems(Iterator<ItemState> iter) {
         // walk through list of transient states and re-apply transient changes
         while (iter.hasNext()) {
-            ItemState itemState = (ItemState) iter.next();
+            ItemState itemState = iter.next();
             ItemId id = itemState.getId();
             ItemImpl item;
 
@@ -685,9 +685,9 @@
      * has been removed, throw.</li>
      * </ul>
      */
-    private void processShareableNodes(Iterator iter) throws RepositoryException {
+    private void processShareableNodes(Iterator<ItemState> iter) throws RepositoryException {
         while (iter.hasNext()) {
-            ItemState is = (ItemState) iter.next();
+            ItemState is = iter.next();
             if (is.isNode()) {
                 NodeState ns = (NodeState) is;
                 boolean wasShareable = false;
@@ -723,11 +723,11 @@
      * @return true if this call generated new transient state; otherwise false
      * @throws RepositoryException
      */
-    private boolean initVersionHistories(Iterator iter) throws RepositoryException {
+    private boolean initVersionHistories(Iterator<ItemState> iter) throws RepositoryException {
         // walk through list of transient items and search for new versionable nodes
         boolean createdTransientState = false;
         while (iter.hasNext()) {
-            ItemState itemState = (ItemState) iter.next();
+            ItemState itemState = iter.next();
             if (itemState.isNode()) {
                 NodeState nodeState = (NodeState) itemState;
                 EffectiveNodeType nt = getEffectiveNodeType(nodeState);
@@ -944,7 +944,7 @@
              * build list of transient (i.e. new & modified) states that
              * should be persisted
              */
-            Collection dirty = getTransientStates();
+            Collection<ItemState> dirty = getTransientStates();
             if (dirty.size() == 0) {
                 // no transient items, nothing to do here
                 return;
@@ -954,17 +954,17 @@
              * build list of transient descendants in the attic
              * (i.e. those marked as 'removed')
              */
-            Collection removed = getRemovedStates();
+            Collection<ItemState> removed = getRemovedStates();
 
             /**
              * build set of item id's which are within the scope of
              * (i.e. affected by) this save operation
              */
-            Set affectedIds = new HashSet(dirty.size() + removed.size());
-            for (Iterator it =
+            Set<ItemId> affectedIds = new HashSet<ItemId>(dirty.size() + removed.size());
+            for (Iterator<ItemState> it =
                     new IteratorChain(dirty.iterator(), removed.iterator());
                  it.hasNext();) {
-                affectedIds.add(((ItemState) it.next()).getId());
+                affectedIds.add(it.next().getId());
             }
 
             /**
@@ -974,13 +974,13 @@
              * (e.g. moving a node requires that the target node including both
              * old and new parents are saved)
              */
-            for (Iterator it =
+            for (Iterator<ItemState> it =
                     new IteratorChain(dirty.iterator(), removed.iterator());
                  it.hasNext();) {
-                ItemState transientState = (ItemState) it.next();
+                ItemState transientState = it.next();
                 if (transientState.isNode()) {
                     NodeState nodeState = (NodeState) transientState;
-                    Set dependentIDs = new HashSet();
+                    Set<NodeId> dependentIDs = new HashSet<NodeId>();
                     if (nodeState.hasOverlayedState()) {
                         NodeState overlayedState =
                                 (NodeState) nodeState.getOverlayedState();
@@ -1009,11 +1009,11 @@
                                         try {
                                             NodeState parent = (NodeState) stateMgr.getTransientItemState(newParentId);
                                             // check parent's renamed child node entries
-                                            for (Iterator cneIt =
+                                            for (Iterator<ChildNodeEntry> cneIt =
                                                     parent.getRenamedChildNodeEntries().iterator();
                                                  cneIt.hasNext();) {
                                                 ChildNodeEntry cne =
-                                                        (ChildNodeEntry) cneIt.next();
+                                                        cneIt.next();
                                                 if (cne.getId().equals(nodeState.getId())) {
                                                     // node has been renamed,
                                                     // add parent to dependencies
@@ -1031,25 +1031,25 @@
                     }
 
                     // removed child node entries
-                    for (Iterator cneIt =
+                    for (Iterator<ChildNodeEntry> cneIt =
                             nodeState.getRemovedChildNodeEntries().iterator();
                          cneIt.hasNext();) {
-                        ChildNodeEntry cne = (ChildNodeEntry) cneIt.next();
+                        ChildNodeEntry cne = cneIt.next();
                         dependentIDs.add(cne.getId());
                     }
                     // added child node entries
-                    for (Iterator cneIt =
+                    for (Iterator<ChildNodeEntry> cneIt =
                             nodeState.getAddedChildNodeEntries().iterator();
                          cneIt.hasNext();) {
-                        ChildNodeEntry cne = (ChildNodeEntry) cneIt.next();
+                        ChildNodeEntry cne = cneIt.next();
                         dependentIDs.add(cne.getId());
                     }
 
                     // now walk through dependencies and check whether they
                     // are within the scope of this save operation
-                    Iterator depIt = dependentIDs.iterator();
+                    Iterator<NodeId> depIt = dependentIDs.iterator();
                     while (depIt.hasNext()) {
-                        NodeId id = (NodeId) depIt.next();
+                        NodeId id = depIt.next();
                         if (!affectedIds.contains(id)) {
                             // JCR-1359 workaround: check whether unresolved
                             // dependencies originate from 'this' session;
@@ -1109,8 +1109,8 @@
                 // transient item states must be removed now. otherwise
                 // the session item state provider will return an orphaned
                 // item state which is not referenced by any node instance.
-                for (Iterator it = dirty.iterator(); it.hasNext();) {
-                    ItemState transientState = (ItemState) it.next();
+                for (Iterator<ItemState> it = dirty.iterator(); it.hasNext();) {
+                    ItemState transientState = it.next();
                     // dispose the transient state, it is no longer used
                     stateMgr.disposeTransientItemState(transientState);
                 }
@@ -1143,8 +1143,8 @@
             // item states in attic are removed after store, because
             // the observation mechanism needs to build paths of removed
             // items in store().
-            for (Iterator it = removed.iterator(); it.hasNext();) {
-                ItemState transientState = (ItemState) it.next();
+            for (Iterator<ItemState> it = removed.iterator(); it.hasNext();) {
+                ItemState transientState = it.next();
                 // dispose the transient state, it is no longer used
                 stateMgr.disposeTransientItemStateInAttic(transientState);
             }
@@ -1176,7 +1176,7 @@
         }
 
         // list of transient items that should be discarded
-        ArrayList list = new ArrayList();
+        ArrayList<ItemState> list = new ArrayList<ItemState>();
         ItemState transientState;
 
         // check status of this item's state
@@ -1213,9 +1213,9 @@
 
         if (isNode()) {
             // build list of 'new', 'modified' or 'stale' descendants
-            Iterator iter = stateMgr.getDescendantTransientItemStates((NodeId) id);
+            Iterator<ItemState> iter = stateMgr.getDescendantTransientItemStates((NodeId) id);
             while (iter.hasNext()) {
-                transientState = (ItemState) iter.next();
+                transientState = iter.next();
                 switch (transientState.getStatus()) {
                     case ItemState.STATUS_STALE_MODIFIED:
                     case ItemState.STATUS_STALE_DESTROYED:
@@ -1234,9 +1234,9 @@
         }
 
         // process list of 'new', 'modified' or 'stale' transient states
-        Iterator iter = list.iterator();
+        Iterator<ItemState> iter = list.iterator();
         while (iter.hasNext()) {
-            transientState = (ItemState) iter.next();
+            transientState = iter.next();
             // dispose the transient state, it is no longer used;
             // this will indirectly (through stateDiscarded listener method)
             // either restore or permanently invalidate the wrapping Item instances
@@ -1248,7 +1248,7 @@
             // as 'removed'); this will resurrect the removed items
             iter = stateMgr.getDescendantTransientItemStatesInAttic((NodeId) id);
             while (iter.hasNext()) {
-                transientState = (ItemState) iter.next();
+                transientState = iter.next();
                 // dispose the transient state; this will indirectly (through
                 // stateDiscarded listener method) resurrect the wrapping Item instances
                 stateMgr.disposeTransientItemStateInAttic(transientState);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/LazyItemIterator.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/LazyItemIterator.java?rev=785116&r1=785115&r2=785116&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/LazyItemIterator.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/LazyItemIterator.java Tue Jun 16 08:53:11 2009
@@ -71,7 +71,7 @@
      * @param itemMgr item manager
      * @param idList  list of item id's
      */
-    public LazyItemIterator(ItemManager itemMgr, List<ItemId> idList) {
+    public LazyItemIterator(ItemManager itemMgr, List< ? extends ItemId> idList) {
         this(itemMgr, idList, null);
     }
 
@@ -84,7 +84,7 @@
      * @param idList  list of item id's
      * @param parentId parent id.
      */
-    public LazyItemIterator(ItemManager itemMgr, List<ItemId> idList, NodeId parentId) {
+    public LazyItemIterator(ItemManager itemMgr, List< ? extends ItemId> idList, NodeId parentId) {
         this.itemMgr = itemMgr;
         this.idList = new ArrayList<ItemId>(idList);
         this.parentId = parentId;

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NamespaceRegistryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NamespaceRegistryImpl.java?rev=785116&r1=785115&r2=785116&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NamespaceRegistryImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NamespaceRegistryImpl.java Tue Jun 16 08:53:11 2009
@@ -30,7 +30,6 @@
 import java.io.OutputStream;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.Properties;
 
 import javax.jcr.AccessDeniedException;
@@ -50,8 +49,8 @@
     private static final String NS_REG_RESOURCE = "ns_reg.properties";
     private static final String NS_IDX_RESOURCE = "ns_idx.properties";
 
-    private static final HashSet reservedPrefixes = new HashSet();
-    private static final HashSet reservedURIs = new HashSet();
+    private static final HashSet<String> reservedPrefixes = new HashSet<String>();
+    private static final HashSet<String> reservedURIs = new HashSet<String>();
 
     static {
         // reserved prefixes
@@ -74,13 +73,13 @@
         reservedURIs.add(Name.NS_SV_URI);
     }
 
-    private HashMap prefixToURI = new HashMap();
-    private HashMap uriToPrefix = new HashMap();
+    private HashMap<String, String> prefixToURI = new HashMap<String, String>();
+    private HashMap<String, String> uriToPrefix = new HashMap<String, String>();
 
-    private HashMap indexToURI = new HashMap();
-    private HashMap uriToIndex = new HashMap();
+    private HashMap<Integer, String> indexToURI = new HashMap<Integer, String>();
+    private HashMap<String, Integer> uriToIndex = new HashMap<String, Integer>();
 
-    private int lastIndex = 0;
+    private int lastIndex;
 
     private final FileSystem nsRegStore;
 
@@ -133,7 +132,7 @@
         uriToPrefix.put(uri, prefix);
         if (!uriToIndex.containsKey(uri)) {
             if (idx == null) {
-                idx = new Integer(++lastIndex);
+                idx = ++lastIndex;
             } else {
                 if (idx.intValue() > lastIndex) {
                     lastIndex = idx.intValue();
@@ -196,9 +195,8 @@
                 clear();
 
                 // read mappings from properties
-                Iterator iter = props.keySet().iterator();
-                while (iter.hasNext()) {
-                    String prefix = (String) iter.next();
+                for (Object p : props.keySet()) {
+                    String prefix = (String) p;
                     String uri = props.getProperty(prefix);
                     String idx = indexes.getProperty(uri);
                     if (idx != null) {
@@ -229,10 +227,8 @@
             Properties props = new Properties();
 
             // store mappings in properties
-            Iterator iter = prefixToURI.keySet().iterator();
-            while (iter.hasNext()) {
-                String prefix = (String) iter.next();
-                String uri = (String) prefixToURI.get(prefix);
+            for (String prefix : prefixToURI.keySet()) {
+                String uri = prefixToURI.get(prefix);
                 props.setProperty(prefix, uri);
             }
 
@@ -256,9 +252,7 @@
             Properties props = new Properties();
 
             // store mappings in properties
-            Iterator iter = uriToIndex.keySet().iterator();
-            while (iter.hasNext()) {
-                String uri = (String) iter.next();
+            for (String uri : uriToIndex.keySet()) {
                 String index = uriToIndex.get(uri).toString();
                 props.setProperty(uri, index);
             }
@@ -296,7 +290,7 @@
      * @throws IllegalArgumentException if the namespace is not registered
      */
     public int stringToIndex(String uri) {
-        Integer idx = (Integer) uriToIndex.get(uri);
+        Integer idx = uriToIndex.get(uri);
         if (idx == null) {
             throw new IllegalArgumentException("Namespace not registered: " + uri);
         }
@@ -311,7 +305,7 @@
      * @throws IllegalArgumentException if the given index is invalid
      */
     public String indexToString(int idx) {
-        String uri = (String) indexToURI.get(new Integer(idx));
+        String uri = indexToURI.get(idx);
         if (uri == null) {
             throw new IllegalArgumentException("Invalid namespace index: " + idx);
         }
@@ -351,7 +345,7 @@
         }
 
         // check existing mappings
-        String oldPrefix = (String) uriToPrefix.get(uri);
+        String oldPrefix = uriToPrefix.get(uri);
         if (prefix.equals(oldPrefix)) {
             throw new NamespaceException("failed to register namespace "
                     + prefix + " -> " + uri + ": mapping already exists");
@@ -409,14 +403,14 @@
      * {@inheritDoc}
      */
     public String[] getPrefixes() throws RepositoryException {
-        return (String[]) prefixToURI.keySet().toArray(new String[prefixToURI.keySet().size()]);
+        return prefixToURI.keySet().toArray(new String[prefixToURI.keySet().size()]);
     }
 
     /**
      * {@inheritDoc}
      */
     public String[] getURIs() throws RepositoryException {
-        return (String[]) uriToPrefix.keySet().toArray(new String[uriToPrefix.keySet().size()]);
+        return uriToPrefix.keySet().toArray(new String[uriToPrefix.keySet().size()]);
     }
 
     //---------------------------------------------------< NamespaceRegistry >
@@ -424,7 +418,7 @@
      * {@inheritDoc}
      */
     public String getURI(String prefix) throws NamespaceException {
-        String uri = (String) prefixToURI.get(prefix);
+        String uri = prefixToURI.get(prefix);
         if (uri == null) {
             throw new NamespaceException(prefix
                     + ": is not a registered namespace prefix.");
@@ -436,7 +430,7 @@
      * {@inheritDoc}
      */
     public String getPrefix(String uri) throws NamespaceException {
-        String prefix = (String) uriToPrefix.get(uri);
+        String prefix = uriToPrefix.get(uri);
         if (prefix == null) {
             throw new NamespaceException(uri
                     + ": is not a registered namespace uri.");

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java?rev=785116&r1=785115&r2=785116&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java Tue Jun 16 08:53:11 2009
@@ -251,7 +251,7 @@
         if (isTransient()) {
             return true;
         }
-        Iterator iter = stateMgr.getDescendantTransientItemStates((NodeId) id);
+        Iterator<ItemState> iter = stateMgr.getDescendantTransientItemStates((NodeId) id);
         return iter.hasNext();
     }
 
@@ -353,13 +353,12 @@
                 genValues = new InternalValue[]{InternalValue.create(thisState.getNodeTypeName())};
             } else if (name.equals(NameConstants.JCR_MIXINTYPES)) {
                 // jcr:mixinTypes property
-                Set mixins = thisState.getMixinTypeNames();
-                ArrayList values = new ArrayList(mixins.size());
-                Iterator iter = mixins.iterator();
-                while (iter.hasNext()) {
-                    values.add(InternalValue.create((Name) iter.next()));
+                Set<Name> mixins = thisState.getMixinTypeNames();
+                ArrayList<InternalValue> values = new ArrayList<InternalValue>(mixins.size());
+                for (Name n : mixins) {
+                    values.add(InternalValue.create(n));
                 }
-                genValues = (InternalValue[]) values.toArray(new InternalValue[values.size()]);
+                genValues = values.toArray(new InternalValue[values.size()]);
             }
         }
 
@@ -654,11 +653,11 @@
         if (thisState.hasChildNodeEntries()) {
             // remove child nodes
             // use temp array to avoid ConcurrentModificationException
-            ArrayList tmp = new ArrayList(thisState.getChildNodeEntries());
+            ArrayList<ChildNodeEntry> tmp = new ArrayList<ChildNodeEntry>(thisState.getChildNodeEntries());
             // remove from tail to avoid problems with same-name siblings
             for (int i = tmp.size() - 1; i >= 0; i--) {
                 ChildNodeEntry entry =
-                        (ChildNodeEntry) tmp.get(i);
+                        tmp.get(i);
                 // recursively remove child node
                 NodeId childId = entry.getId();
                 //NodeImpl childNode = (NodeImpl) itemMgr.getItem(childId);
@@ -671,9 +670,8 @@
 
         // remove properties
         // use temp set to avoid ConcurrentModificationException
-        HashSet tmp = new HashSet(thisState.getPropertyNames());
-        for (Iterator iter = tmp.iterator(); iter.hasNext();) {
-            Name propName = (Name) iter.next();
+        HashSet<Name> tmp = new HashSet<Name>(thisState.getPropertyNames());
+        for (Name propName : tmp) {
             // remove the property entry
             thisState.removePropertyName(propName);
             // remove property
@@ -803,8 +801,8 @@
         }
 
         // check protected flag of parent (i.e. this) node and retention/hold
-        int options = ItemValidator.CHECK_CONSTRAINTS | ItemValidator.CHECK_HOLD |
-                ItemValidator.CHECK_RETENTION;
+        int options = ItemValidator.CHECK_CONSTRAINTS | ItemValidator.CHECK_HOLD
+                | ItemValidator.CHECK_RETENTION;
         session.getValidator().checkModify(this, options, Permission.NONE);
 
         // now do create the child node
@@ -833,10 +831,10 @@
         // call internalSetValue for setting the jcr:mixinTypes property
         // to avoid checking of the 'protected' flag
         InternalValue[] vals = new InternalValue[mixinNames.size()];
-        Iterator iter = mixinNames.iterator();
+        Iterator<Name> iter = mixinNames.iterator();
         int cnt = 0;
         while (iter.hasNext()) {
-            vals[cnt++] = InternalValue.create((Name) iter.next());
+            vals[cnt++] = InternalValue.create(iter.next());
         }
         prop.internalSetValue(vals, PropertyType.NAME);
     }
@@ -846,7 +844,7 @@
      *
      * @return a set of the <code>Name</code>s of this node's mixin types.
      */
-    public Set getMixinTypeNames() {
+    public Set<Name> getMixinTypeNames() {
         return data.getNodeState().getMixinTypeNames();
     }
 
@@ -1012,8 +1010,8 @@
         // check state of this instance
         sanityCheck();
 
-        int options = ItemValidator.CHECK_LOCK | ItemValidator.CHECK_VERSIONING |
-                ItemValidator.CHECK_CONSTRAINTS | ItemValidator.CHECK_HOLD;
+        int options = ItemValidator.CHECK_LOCK | ItemValidator.CHECK_VERSIONING
+                | ItemValidator.CHECK_CONSTRAINTS | ItemValidator.CHECK_HOLD;
         int permissions = Permission.NODE_TYPE_MNGMT;
         // special handling of mix:(simple)versionable. since adding the mixin alters
         // the version storage jcr:versionManagement privilege is required
@@ -1042,7 +1040,7 @@
         EffectiveNodeType entExisting;
         try {
             // existing mixin's
-            Set mixins = new HashSet(data.getNodeState().getMixinTypeNames());
+            Set<Name> mixins = new HashSet<Name>(data.getNodeState().getMixinTypeNames());
 
             // build effective node type representing primary type including existing mixin's
             entExisting = ntReg.getEffectiveNodeType(primaryTypeName, mixins);
@@ -1065,7 +1063,7 @@
             // modify the state of this node
             NodeState thisState = (NodeState) getOrCreateTransientItemState();
             // add mixin name
-            Set mixins = new HashSet(thisState.getMixinTypeNames());
+            Set<Name> mixins = new HashSet<Name>(thisState.getMixinTypeNames());
             mixins.add(mixinName);
             thisState.setMixinTypeNames(mixins);
 
@@ -1118,8 +1116,8 @@
         // check state of this instance
         sanityCheck();
 
-        int options = ItemValidator.CHECK_LOCK | ItemValidator.CHECK_VERSIONING |
-                ItemValidator.CHECK_CONSTRAINTS | ItemValidator.CHECK_HOLD;
+        int options = ItemValidator.CHECK_LOCK | ItemValidator.CHECK_VERSIONING
+                | ItemValidator.CHECK_CONSTRAINTS | ItemValidator.CHECK_HOLD;
         int permissions = Permission.NODE_TYPE_MNGMT;
         session.getValidator().checkModify(this, options, permissions);
 
@@ -1133,7 +1131,7 @@
         NodeTypeRegistry ntReg = ntMgr.getNodeTypeRegistry();
 
         // build effective node type of remaining mixin's & primary type
-        Set remainingMixins = new HashSet<Name>(state.getMixinTypeNames());
+        Set<Name> remainingMixins = new HashSet<Name>(state.getMixinTypeNames());
         // remove name of target mixin
         remainingMixins.remove(mixinName);
         EffectiveNodeType entResulting;
@@ -1195,9 +1193,8 @@
         boolean success = false;
         try {
             // use temp set to avoid ConcurrentModificationException
-            HashSet set = new HashSet<Name>(thisState.getPropertyNames());
-            for (Iterator iter = set.iterator(); iter.hasNext();) {
-                Name propName = (Name) iter.next();
+            HashSet<Name> set = new HashSet<Name>(thisState.getPropertyNames());
+            for (Name propName : set) {
                 PropertyState propState = (PropertyState) stateMgr.getItemState(new PropertyId(thisState.getNodeId(), propName));
                 // check if property has been defined by mixin type (or one of its supertypes)
                 PropertyDefinition def = ntMgr.getPropertyDefinition(propState.getDefinitionId());
@@ -1259,10 +1256,10 @@
                 }
             }
             // use temp array to avoid ConcurrentModificationException
-            ArrayList list = new ArrayList<ChildNodeEntry>(thisState.getChildNodeEntries());
+            ArrayList<ChildNodeEntry> list = new ArrayList<ChildNodeEntry>(thisState.getChildNodeEntries());
             // start from tail to avoid problems with same-name siblings
             for (int i = list.size() - 1; i >= 0; i--) {
-                ChildNodeEntry entry = (ChildNodeEntry) list.get(i);
+                ChildNodeEntry entry = list.get(i);
                 NodeState nodeState = (NodeState) stateMgr.getItemState(entry.getId());
                 NodeDefinition def = ntMgr.getNodeDefinition(nodeState.getDefinitionId());
                 // check if node has been defined by mixin type (or one of its supertypes)
@@ -1317,7 +1314,7 @@
         if (ntName.equals(primary)) {
             return true;
         }
-        Set mixins = data.getNodeState().getMixinTypeNames();
+        Set<Name> mixins = data.getNodeState().getMixinTypeNames();
         if (mixins.contains(ntName)) {
             return true;
         }
@@ -1853,14 +1850,14 @@
         }
 
         // make sure this node is checked-out and neither protected nor locked
-        int options = ItemValidator.CHECK_LOCK | ItemValidator.CHECK_VERSIONING |
-                ItemValidator.CHECK_CONSTRAINTS;
+        int options = ItemValidator.CHECK_LOCK | ItemValidator.CHECK_VERSIONING
+                | ItemValidator.CHECK_CONSTRAINTS;
         session.getValidator().checkModify(this, options, Permission.NONE);
 
-        ArrayList list = new ArrayList(data.getNodeState().getChildNodeEntries());
+        ArrayList<ChildNodeEntry> list = new ArrayList<ChildNodeEntry>(data.getNodeState().getChildNodeEntries());
         int srcInd = -1, destInd = -1;
         for (int i = 0; i < list.size(); i++) {
-            ChildNodeEntry entry = (ChildNodeEntry) list.get(i);
+            ChildNodeEntry entry = list.get(i);
             if (srcInd == -1) {
                 if (entry.getName().equals(srcName.getName())
                         && (entry.getIndex() == srcName.getIndex()
@@ -1953,7 +1950,7 @@
             throw new ItemNotFoundException(
                     this + ": no child node entry with id " + id);
         }
-        List cneList = new ArrayList(state.getChildNodeEntries());
+        List<ChildNodeEntry> cneList = new ArrayList<ChildNodeEntry>(state.getChildNodeEntries());
 
         // remove existing
         existing.remove();
@@ -1977,8 +1974,7 @@
             // replace child node entry with different name
             // but preserving original position
             state.removeAllChildNodeEntries();
-            for (Iterator iter = cneList.iterator(); iter.hasNext();) {
-                ChildNodeEntry cne = (ChildNodeEntry) iter.next();
+            for (ChildNodeEntry cne : cneList) {
                 if (cne.getId().equals(id)) {
                     // replace entry with different name
                     state.addChildNodeEntry(nodeName, id);
@@ -2796,15 +2792,15 @@
         // check state of this instance
         sanityCheck();
 
-        Set mixinNames = data.getNodeState().getMixinTypeNames();
+        Set<Name> mixinNames = data.getNodeState().getMixinTypeNames();
         if (mixinNames.isEmpty()) {
             return new NodeType[0];
         }
         NodeType[] nta = new NodeType[mixinNames.size()];
-        Iterator iter = mixinNames.iterator();
+        Iterator<Name> iter = mixinNames.iterator();
         int i = 0;
         while (iter.hasNext()) {
-            nta[i++] = session.getNodeTypeManager().getNodeType((Name) iter.next());
+            nta[i++] = session.getNodeTypeManager().getNodeType(iter.next());
         }
         return nta;
     }
@@ -2851,9 +2847,9 @@
         if (!mixin.isMixin()) {
             return false;
         }
-        
-        int options = ItemValidator.CHECK_LOCK | ItemValidator.CHECK_VERSIONING |
-                ItemValidator.CHECK_CONSTRAINTS | ItemValidator.CHECK_HOLD;
+
+        int options = ItemValidator.CHECK_LOCK | ItemValidator.CHECK_VERSIONING
+                | ItemValidator.CHECK_CONSTRAINTS | ItemValidator.CHECK_HOLD;
         int permissions = Permission.NODE_TYPE_MNGMT;
         // special handling of mix:(simple)versionable. since adding the mixin alters
         // the version storage jcr:versionManagement privilege is required
@@ -2880,7 +2876,7 @@
         EffectiveNodeType entExisting;
         try {
             // existing mixin's
-            Set mixins = new HashSet(data.getNodeState().getMixinTypeNames());
+            Set<Name> mixins = new HashSet<Name>(data.getNodeState().getMixinTypeNames());
 
             // build effective node type representing primary type including existing mixin's
             entExisting = ntReg.getEffectiveNodeType(primaryTypeName, mixins);
@@ -3102,15 +3098,13 @@
         // check state of this instance
         sanityCheck();
 
-        ArrayList list = new ArrayList();
+        ArrayList<NodeImpl> list = new ArrayList<NodeImpl>();
 
         if (!isShareable()) {
             list.add(this);
         } else {
             NodeState state = data.getNodeState();
-            Iterator iter = state.getSharedSet().iterator();
-            while (iter.hasNext()) {
-                NodeId parentId = (NodeId) iter.next();
+            for (NodeId parentId : state.getSharedSet()) {
                 list.add(itemMgr.getNode(getNodeId(), parentId));
             }
         }
@@ -3497,7 +3491,7 @@
         // do checks
         sanityCheck();
         checkVersionable();
-        int options = ItemValidator.CHECK_PENDING_CHANGES | ItemValidator.CHECK_LOCK| ItemValidator.CHECK_HOLD;
+        int options = ItemValidator.CHECK_PENDING_CHANGES | ItemValidator.CHECK_LOCK | ItemValidator.CHECK_HOLD;
         session.getValidator().checkModify(this, options, Permission.NONE);
 
         // check if 'own' version
@@ -3568,7 +3562,7 @@
 
         // do checks
         sanityCheck();
-        int options = ItemValidator.CHECK_PENDING_CHANGES | ItemValidator.CHECK_LOCK| ItemValidator.CHECK_HOLD;
+        int options = ItemValidator.CHECK_PENDING_CHANGES | ItemValidator.CHECK_LOCK | ItemValidator.CHECK_HOLD;
         session.getValidator().checkModify(this, options, Permission.NONE);
 
         Version v = getVersionHistory().getVersionByLabel(versionLabel);
@@ -3757,7 +3751,7 @@
      * @throws RepositoryException if an error occurs.
      * @throws AccessDeniedException if access is denied
      */
-    private NodeImpl doMergeTest(SessionImpl srcSession, List failedIds, boolean bestEffort)
+    private NodeImpl doMergeTest(SessionImpl srcSession, List<ItemId> failedIds, boolean bestEffort)
             throws RepositoryException, AccessDeniedException {
 
         // If N does not have a corresponding node then the merge result for N is leave.
@@ -3795,7 +3789,7 @@
             // thus determining the result of a merge is non-trivial.
             if (bestEffort) {
                 // add 'offending' version to jcr:mergeFailed property
-                Set set = internalGetMergeFailed();
+                Set<String> set = internalGetMergeFailed();
                 set.add(srcNode.getBaseVersion().getUUID());
                 internalSetMergeFailed(set);
                 failedIds.add(id);
@@ -3827,7 +3821,7 @@
         session.getValidator().checkModify(this, options, Permission.VERSION_MNGMT);
 
         // check if version is in mergeFailed list
-        Set failed = internalGetMergeFailed();
+        Set<String> failed = internalGetMergeFailed();
         if (!failed.remove(version.getUUID())) {
             String msg =
                 "Unable to finish merge. Specified version is not in"
@@ -3869,8 +3863,8 @@
      * @return
      * @throws RepositoryException
      */
-    private Set internalGetMergeFailed() throws RepositoryException {
-        HashSet set = new HashSet();
+    private Set<String> internalGetMergeFailed() throws RepositoryException {
+        HashSet<String> set = new HashSet<String>();
         if (hasProperty(NameConstants.JCR_MERGEFAILED)) {
             Value[] vals = getProperty(NameConstants.JCR_MERGEFAILED).getValues();
             for (int i = 0; i < vals.length; i++) {
@@ -3884,15 +3878,15 @@
      * @param set
      * @throws RepositoryException
      */
-    private void internalSetMergeFailed(Set set) throws RepositoryException {
+    private void internalSetMergeFailed(Set<String> set) throws RepositoryException {
         if (set.isEmpty()) {
             internalSetProperty(NameConstants.JCR_MERGEFAILED, (InternalValue[]) null);
         } else {
             InternalValue[] vals = new InternalValue[set.size()];
-            Iterator iter = set.iterator();
+            Iterator<String> iter = set.iterator();
             int i = 0;
             while (iter.hasNext()) {
-                String uuid = (String) iter.next();
+                String uuid = iter.next();
                 vals[i++] = InternalValue.create(UUID.fromString(uuid));
             }
             internalSetProperty(NameConstants.JCR_MERGEFAILED, vals);
@@ -4048,7 +4042,7 @@
      * @throws RepositoryException
      */
     private void internalMerge(String srcWorkspaceName,
-                               List failedIds, boolean bestEffort,
+                               List<ItemId> failedIds, boolean bestEffort,
                                boolean shallow)
             throws NoSuchWorkspaceException, AccessDeniedException,
             LockException, InvalidItemStateException, RepositoryException {
@@ -4101,7 +4095,7 @@
      * @throws LockException
      * @throws RepositoryException
      */
-    private void internalMerge(SessionImpl srcSession, List failedIds,
+    private void internalMerge(SessionImpl srcSession, List<ItemId> failedIds,
                                boolean bestEffort, boolean removeExisting,
                                boolean replaceExisting, boolean shallow)
             throws LockException, RepositoryException {
@@ -4317,7 +4311,7 @@
      * @param removeExisting remove existing flag
      * @throws RepositoryException if an error occurs
      */
-    public void restoreFrozenState(InternalFrozenNode freeze, VersionSelector vsel, 
+    public void restoreFrozenState(InternalFrozenNode freeze, VersionSelector vsel,
                             Set<Version> restored, boolean removeExisting)
             throws RepositoryException {
 
@@ -4633,7 +4627,7 @@
             if (stateMgr.hasNodeReferences(targetId)) {
                 NodeReferences refs = stateMgr.getNodeReferences(targetId);
                 // refs.getReferences() returns a list of PropertyId's
-                List idList = refs.getReferences();
+                List<PropertyId> idList = refs.getReferences();
                 if (name != null) {
                     Name qName;
                     try {
@@ -4641,9 +4635,8 @@
                     } catch (NameException e) {
                         throw new RepositoryException("invalid property name: " + name, e);
                     }
-                    ArrayList filteredList = new ArrayList(idList.size());
-                    for (Iterator iter = idList.iterator(); iter.hasNext();) {
-                        PropertyId propId = (PropertyId) iter.next();
+                    ArrayList<PropertyId> filteredList = new ArrayList<PropertyId>(idList.size());
+                    for (PropertyId propId : filteredList) {
                         if (propId.getName().equals(qName)) {
                             filteredList.add(propId);
                         }
@@ -4676,17 +4669,17 @@
         // check state of this instance
         sanityCheck();
 
-        // TODO tweak query implemention in order to support WEAKREFERENCE reverse lookup 
+        // TODO tweak query implemention in order to support WEAKREFERENCE reverse lookup
         try {
             Query q = session.getWorkspace().getQueryManager().createQuery(
                     "//*[jcr:contains(., '" + data.getId() + "')]",
                     //"//*[@*='" + data.getId() + "']",
                     Query.XPATH);
             QueryResult result = q.execute();
-            ArrayList l = new ArrayList<Property>();
-            for (NodeIterator nit = result.getNodes(); nit.hasNext(); ) {
+            ArrayList<Property> l = new ArrayList<Property>();
+            for (NodeIterator nit = result.getNodes(); nit.hasNext();) {
                 Node n = nit.nextNode();
-                for (PropertyIterator pit = n.getProperties(); pit.hasNext(); ) {
+                for (PropertyIterator pit = n.getProperties(); pit.hasNext();) {
                     Property p = pit.nextProperty();
                     if (p.getType() == PropertyType.WEAKREFERENCE
                             && p.getString().equals(getIdentifier())) {
@@ -4751,8 +4744,8 @@
 
         // make sure this node is checked-out, neither protected nor locked and
         // the editing session has sufficient permission to change the primary type.
-        int options = ItemValidator.CHECK_VERSIONING | ItemValidator.CHECK_LOCK |
-                ItemValidator.CHECK_CONSTRAINTS | ItemValidator.CHECK_HOLD;
+        int options = ItemValidator.CHECK_VERSIONING | ItemValidator.CHECK_LOCK
+                | ItemValidator.CHECK_CONSTRAINTS | ItemValidator.CHECK_HOLD;
         session.getValidator().checkModify(this, options, Permission.NODE_TYPE_MNGMT);
 
         final NodeState state = data.getNodeState();
@@ -4805,12 +4798,12 @@
             onRedefine(defId);
         }
 
-        Set oldDefs = new HashSet(Arrays.asList(entOld.getAllItemDefs()));
-        Set newDefs = new HashSet(Arrays.asList(entNew.getAllItemDefs()));
-        Set allDefs = new HashSet(Arrays.asList(entAll.getAllItemDefs()));
+        Set<ItemDef> oldDefs = new HashSet<ItemDef>(Arrays.asList(entOld.getAllItemDefs()));
+        Set<ItemDef> newDefs = new HashSet<ItemDef>(Arrays.asList(entNew.getAllItemDefs()));
+        Set<ItemDef> allDefs = new HashSet<ItemDef>(Arrays.asList(entAll.getAllItemDefs()));
 
         // added child item definitions
-        Set addedDefs = new HashSet(newDefs);
+        Set<ItemDef> addedDefs = new HashSet<ItemDef>(newDefs);
         addedDefs.removeAll(oldDefs);
 
         // referential integrity check
@@ -4840,9 +4833,8 @@
         // walk through properties and child nodes and change definition as necessary
 
         // use temp set to avoid ConcurrentModificationException
-        HashSet set = new HashSet(thisState.getPropertyNames());
-        for (Iterator iter = set.iterator(); iter.hasNext();) {
-            Name propName = (Name) iter.next();
+        HashSet<Name> set = new HashSet<Name>(thisState.getPropertyNames());
+        for (Name propName : set) {
             try {
                 PropertyState propState =
                         (PropertyState) stateMgr.getItemState(
@@ -4909,10 +4901,10 @@
         }
 
         // use temp array to avoid ConcurrentModificationException
-        ArrayList list = new ArrayList(thisState.getChildNodeEntries());
+        ArrayList<ChildNodeEntry> list = new ArrayList<ChildNodeEntry>(thisState.getChildNodeEntries());
         // start from tail to avoid problems with same-name siblings
         for (int i = list.size() - 1; i >= 0; i--) {
-            ChildNodeEntry entry = (ChildNodeEntry) list.get(i);
+            ChildNodeEntry entry = list.get(i);
             try {
                 NodeState nodeState = (NodeState) stateMgr.getItemState(entry.getId());
                 if (!allDefs.contains(ntReg.getNodeDef(nodeState.getDefinitionId()))) {
@@ -4947,8 +4939,8 @@
 
         // create items that are defined as auto-created by the new primary node
         // type and at the same time were not present with the old nt
-        for (Iterator iter = addedDefs.iterator(); iter.hasNext();) {
-            ItemDef def = (ItemDef) iter.next();
+        for (Iterator<ItemDef> iter = addedDefs.iterator(); iter.hasNext();) {
+            ItemDef def = iter.next();
             if (def.isAutoCreated()) {
                 if (def.definesNode()) {
                     NodeDefinitionImpl ndi = ntMgr.getNodeDefinition(((NodeDef) def).getId());

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java?rev=785116&r1=785115&r2=785116&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java Tue Jun 16 08:53:11 2009
@@ -383,10 +383,11 @@
      *                                   deleted externally
      * @throws RepositoryException       if another error occurs
      */
-    public Iterator getDescendantTransientItemStates(NodeId parentId)
+    public Iterator<ItemState> getDescendantTransientItemStates(NodeId parentId)
             throws InvalidItemStateException, RepositoryException {
         if (transientStore.isEmpty()) {
-            return Collections.EMPTY_LIST.iterator();
+            List<ItemState> empty = Collections.emptyList();
+            return empty.iterator();
         }
 
         // build ordered collection of descendant transient states
@@ -460,7 +461,8 @@
          * situation
          */
         if (resultIter.getIterators().isEmpty()) {
-            return Collections.EMPTY_LIST.iterator();
+            List<ItemState> empty = Collections.emptyList();
+            return empty.iterator();
         }
         return resultIter;
     }
@@ -473,9 +475,10 @@
      *                 instances to be returned.
      * @return an iterator over descendant transient item state instances in the attic
      */
-    public Iterator getDescendantTransientItemStatesInAttic(NodeId parentId) {
+    public Iterator<ItemState> getDescendantTransientItemStatesInAttic(NodeId parentId) {
         if (atticStore.isEmpty()) {
-            return Collections.EMPTY_LIST.iterator();
+            List<ItemState> empty = Collections.emptyList();
+            return empty.iterator();
         }
 
         // build ordered collection of descendant transient states in attic
@@ -489,9 +492,7 @@
         // the depth is used as array index
         List[] la = new List[10];
         try {
-            Iterator iter = atticStore.values().iterator();
-            while (iter.hasNext()) {
-                ItemState state = (ItemState) iter.next();
+            for (ItemState state : atticStore.values()) {
                 // determine relative depth: > 0 means it's a descendant
                 //int depth = zombieHierMgr.getRelativeDepth(parentId, state.getId());
                 int depth = zombieHierMgr.getShareRelativeDepth(parentId, state.getId());
@@ -534,7 +535,8 @@
          * situation
          */
         if (resultIter.getIterators().isEmpty()) {
-            return Collections.EMPTY_LIST.iterator();
+            List<ItemState> empty = Collections.emptyList();
+            return empty.iterator();
         }
         return resultIter;
     }
@@ -729,16 +731,12 @@
     public void disposeAllTransientItemStates() {
         // dispose item states in transient map & attic
         // (use temp collection to avoid ConcurrentModificationException)
-        Collection tmp = new ArrayList(transientStore.values());
-        Iterator iter = tmp.iterator();
-        while (iter.hasNext()) {
-            ItemState state = (ItemState) iter.next();
+        Collection<ItemState> tmp = new ArrayList<ItemState>(transientStore.values());
+        for (ItemState state : tmp) {
             disposeTransientItemState(state);
         }
-        tmp = new ArrayList(atticStore.values());
-        iter = tmp.iterator();
-        while (iter.hasNext()) {
-            ItemState state = (ItemState) iter.next();
+        tmp = new ArrayList<ItemState>(atticStore.values());
+        for (ItemState state : tmp) {
             disposeTransientItemStateInAttic(state);
         }
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/SessionGarbageCollectedTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/SessionGarbageCollectedTest.java?rev=785116&r1=785115&r2=785116&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/SessionGarbageCollectedTest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/SessionGarbageCollectedTest.java Tue Jun 16 08:53:11 2009
@@ -33,8 +33,8 @@
 public class SessionGarbageCollectedTest extends AbstractJCRTest {
 
     public void testSessionsGetGarbageCollected() throws RepositoryException {
-        ArrayList list = new ArrayList();
-        ReferenceQueue detect = new ReferenceQueue();
+        ArrayList<WeakReference<Session>> list = new ArrayList<WeakReference<Session>>();
+        ReferenceQueue<Session> detect = new ReferenceQueue<Session>();
         Error error = null;
         try {
             for (int i = 0;; i++) {
@@ -43,7 +43,7 @@
                 // (or quickly runs out of memory)
                 Node n = s.getRootNode().addNode("n" + i);
                 n.setProperty("x", new String(new char[1000000]));
-                list.add(new WeakReference(s, detect));
+                list.add(new WeakReference<Session>(s, detect));
                 if (detect.poll() != null) {
                     break;
                 }
@@ -52,8 +52,8 @@
             error = e;
         }
         for (int i = 0; i < list.size(); i++) {
-            Reference ref = (Reference) list.get(i);
-            Session s = (Session) ref.get();
+            Reference<Session> ref = list.get(i);
+            Session s = ref.get();
             if (s != null) {
                 s.logout();
             }

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java?rev=785116&r1=785115&r2=785116&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java Tue Jun 16 08:53:11 2009
@@ -947,10 +947,10 @@
 
         // commit
         utx.commit();
-        
+
         // Check if it is locked in other session
         Session other = helper.getSuperuserSession();
-        Node nOther = other.getNodeByUUID(n.getUUID());        
+        Node nOther = other.getNodeByUUID(n.getUUID());
         assertTrue(nOther.isLocked());
 
         // Check if it is also locked in other transaction
@@ -958,16 +958,19 @@
         // start new Transaction and try to add locktoken
         utx = new UserTransactionImpl(other2);
         utx.begin();
-        
-        Node nOther2 = other2.getNodeByUUID(n.getUUID());        
+
+        Node nOther2 = other2.getNodeByUUID(n.getUUID());
         assertTrue(nOther2.isLocked());
-        
+
         utx.commit();
-    
+
+        other.logout();
+        other2.logout();
+
     }
 
     /**
-     * Test add and remove lock tokens in a transaction 
+     * Test add and remove lock tokens in a transaction
      * @throws Exception
      */
     public void testAddRemoveLockToken() throws Exception {
@@ -976,18 +979,18 @@
         utx.begin();
 
         // add node that is both lockable and referenceable, save
-        Node rootNode = superuser.getRootNode(); 
+        Node rootNode = superuser.getRootNode();
         Node n = rootNode.addNode(nodeName1);
         n.addMixin(mixLockable);
         n.addMixin(mixReferenceable);
         rootNode.save();
 
         String uuid = n.getUUID();
-        
+
         // lock this new node
         Lock lock = n.lock(true, false);
         String lockToken = lock.getLockToken();
-        
+
         // assert: session must get a non-null lock token
         assertNotNull("session must get a non-null lock token", lockToken);
 
@@ -996,10 +999,10 @@
 
         superuser.removeLockToken(lockToken);
         assertNull("session must get a null lock token", lock.getLockToken());
-        
+
         // commit
         utx.commit();
-        
+
         // refresh Lock Info
         lock = n.getLock();
 
@@ -1009,8 +1012,8 @@
         // start new Transaction and try to add lock token
         utx = new UserTransactionImpl(other);
         utx.begin();
-        
-        Node otherNode = other.getNodeByUUID(uuid); 
+
+        Node otherNode = other.getNodeByUUID(uuid);
         assertTrue("Node not locked", otherNode.isLocked());
         try {
             otherNode.setProperty(propertyName1, "foo");
@@ -1018,20 +1021,20 @@
         } catch (LockException e) {
             // expected
         }
-        
+
         // add lock token
         other.addLockToken(lockToken);
-        
+
         // refresh Lock Info
         lock = otherNode.getLock();
 
         // assert: session must hold lock token
-        assertTrue("session must hold lock token", containsLockToken(other, lock.getLockToken()));        
-        
+        assertTrue("session must hold lock token", containsLockToken(other, lock.getLockToken()));
+
         otherNode.unlock();
-        
+
         assertFalse("Node is locked", otherNode.isLocked());
-        
+
         otherNode.setProperty(propertyName1, "foo");
         other.save();
         utx.commit();
@@ -1742,7 +1745,7 @@
 
         utx.commit();
     }
-    
+
     /**
      * Return a flag indicating whether the indicated session contains
      * a specific lock token
@@ -1755,5 +1758,5 @@
             }
         }
         return false;
-    }    
+    }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GarbageCollectorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GarbageCollectorTest.java?rev=785116&r1=785115&r2=785116&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GarbageCollectorTest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GarbageCollectorTest.java Tue Jun 16 08:53:11 2009
@@ -123,7 +123,7 @@
 
         n.remove();
         session.save();
-        
+
         GarbageCollector gc = ((SessionImpl)session).createDataStoreGarbageCollector();
 
         if (gc.getDataStore() instanceof FileDataStore) {
@@ -212,6 +212,8 @@
         }
 
         deleteMyNodes();
+
+        s2.logout();
     }
 
     public void afterScanning(Node n) throws RepositoryException {



Mime
View raw message