jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r785540 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: ./ cluster/ fs/db/ fs/local/ lock/ observation/ persistence/mem/ persistence/obj/ retention/ state/ xml/
Date Wed, 17 Jun 2009 10:25:00 GMT
Author: thomasm
Date: Wed Jun 17 10:24:59 2009
New Revision: 785540

URL: http://svn.apache.org/viewvc?rev=785540&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/ItemManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryFactoryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TransactionContext.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/UpdateEventListener.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/OracleFileSystem.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/local/HandleMonitor.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/local/LocalFileSystem.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/DispatchAction.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventConsumer.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/FilteredEventIterator.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ObservationDispatcher.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/mem/InMemPersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/obj/ObjectPersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/retention/RetentionRegistryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeStateMerger.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/StateChangeDispatcher.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/ClonedInputSource.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java?rev=785540&r1=785539&r2=785540&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java Wed Jun 17 10:24:59 2009
@@ -93,7 +93,7 @@
     /**
      * A cache for item instances created by this <code>ItemManager</code>
      */
-    private final Map itemCache;
+    private final Map<ItemId, ItemData> itemCache;
 
     /**
      * Shareable node cache.
@@ -200,7 +200,7 @@
             if (!itemStateProvider.hasItemState(itemId)) {
                 return false;
             }
-            ItemData data = getItemData(itemId, path, true);
+            getItemData(itemId, path, true);
             return true;
         } catch (RepositoryException re) {
             return false;
@@ -589,11 +589,11 @@
             log.debug(msg);
             throw new RepositoryException(msg);
         }
-        ArrayList childIds = new ArrayList();
-        Iterator iter = ((NodeState) data.getState()).getChildNodeEntries().iterator();
+        ArrayList<ItemId> childIds = new ArrayList<ItemId>();
+        Iterator<ChildNodeEntry> iter = ((NodeState) data.getState()).getChildNodeEntries().iterator();
 
         while (iter.hasNext()) {
-            ChildNodeEntry entry = (ChildNodeEntry) iter.next();
+            ChildNodeEntry entry = iter.next();
             // delay check for read-access until item is being built
             // thus avoid duplicate check
             childIds.add(entry.getId());
@@ -620,10 +620,10 @@
             log.debug(msg);
             throw new RepositoryException(msg);
         }
-        Iterator iter = ((NodeState) data.getState()).getPropertyNames().iterator();
+        Iterator<Name> iter = ((NodeState) data.getState()).getPropertyNames().iterator();
 
         while (iter.hasNext()) {
-            Name propName = (Name) iter.next();
+            Name propName = iter.next();
             // make sure any of the properties can be read.
             if (canRead(new PropertyId(parentId, propName))) {
                 return true;
@@ -651,11 +651,11 @@
             log.debug(msg);
             throw new RepositoryException(msg);
         }
-        ArrayList childIds = new ArrayList();
-        Iterator iter = ((NodeState) data.getState()).getPropertyNames().iterator();
+        ArrayList<PropertyId> childIds = new ArrayList<PropertyId>();
+        Iterator<Name> iter = ((NodeState) data.getState()).getPropertyNames().iterator();
 
         while (iter.hasNext()) {
-            Name propName = (Name) iter.next();
+            Name propName = iter.next();
             PropertyId id = new PropertyId(parentId, propName);
             // delay check for read-access until item is being built
             // thus avoid duplicate check
@@ -738,7 +738,7 @@
      */
     private ItemData retrieveItem(ItemId id) {
         synchronized (itemCache) {
-            ItemData data = (ItemData) itemCache.get(id);
+            ItemData data = itemCache.get(id);
             if (data == null && id.denotesNode()) {
                 data = shareableNodesCache.retrieveFirst((NodeId) id);
             }
@@ -821,7 +821,7 @@
             if (data.isNode()) {
                 shareableNodesCache.evict((AbstractNodeData) data);
             }
-            ItemData cached = (ItemData) itemCache.get(data.getId());
+            ItemData cached = itemCache.get(data.getId());
             if (cached == data) {
                 itemCache.remove(data.getId());
             }
@@ -899,10 +899,8 @@
         ps.println("Items in cache:");
         ps.println();
         synchronized (itemCache) {
-            Iterator iter = itemCache.keySet().iterator();
-            while (iter.hasNext()) {
-                ItemId id = (ItemId) iter.next();
-                ItemData item = (ItemData) itemCache.get(id);
+            for (ItemId id : itemCache.keySet()) {
+                ItemData item = itemCache.get(id);
                 if (item.isNode()) {
                     ps.print("Node: ");
                 } else {
@@ -1070,10 +1068,10 @@
         public AbstractNodeData retrieveFirst(NodeId id) {
             ReferenceMap map = (ReferenceMap) cache.get(id);
             if (map != null) {
-                Iterator iter = map.values().iterator();
+                Iterator<AbstractNodeData> iter = map.values().iterator();
                 try {
                     while (iter.hasNext()) {
-                        AbstractNodeData data = (AbstractNodeData) iter.next();
+                        AbstractNodeData data = iter.next();
                         if (data != null) {
                             return data;
                         }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryFactoryImpl.java?rev=785540&r1=785539&r2=785540&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryFactoryImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryFactoryImpl.java Wed Jun 17 10:24:59 2009
@@ -47,7 +47,7 @@
      * Map of repository instances. Key = repository home, value = repository
      * instance.
      */
-    private static final Map REPOSITORY_INSTANCES = new HashMap();
+    private static final Map<String, JackrabbitRepository> REPOSITORY_INSTANCES = new HashMap<String, JackrabbitRepository>();
 
     public Repository getRepository(Map parameters) throws RepositoryException {
         JackrabbitRepository repo;
@@ -80,7 +80,7 @@
     private JackrabbitRepository getOrCreateRepository(String conf,
                                                        String home)
             throws RepositoryException {
-        JackrabbitRepository repo = (JackrabbitRepository) REPOSITORY_INSTANCES.get(home);
+        JackrabbitRepository repo = REPOSITORY_INSTANCES.get(home);
         if (repo == null) {
             if (home == null) {
                 repo = new TransientRepository();

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java?rev=785540&r1=785539&r2=785540&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java Wed Jun 17 10:24:59 2009
@@ -49,6 +49,7 @@
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.nodetype.virtual.VirtualNodeTypeStateManager;
 import org.apache.jackrabbit.core.observation.DelegatingObservationDispatcher;
+import org.apache.jackrabbit.core.observation.EventState;
 import org.apache.jackrabbit.core.observation.EventStateCollection;
 import org.apache.jackrabbit.core.observation.ObservationDispatcher;
 import org.apache.jackrabbit.core.persistence.PMContext;
@@ -64,7 +65,6 @@
 import org.apache.jackrabbit.core.state.ManagedMLRUItemStateCacheFactory;
 import org.apache.jackrabbit.core.state.SharedItemStateManager;
 import org.apache.jackrabbit.core.util.RepositoryLockMechanism;
-import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.core.version.VersionManager;
 import org.apache.jackrabbit.core.version.VersionManagerImpl;
 import org.apache.jackrabbit.core.xml.ClonedInputSource;
@@ -197,7 +197,7 @@
     /**
      * map of workspace names and <code>WorkspaceInfo<code>s.
      */
-    private final HashMap wspInfos = new HashMap();
+    private final HashMap<String, WorkspaceInfo> wspInfos = new HashMap<String, WorkspaceInfo>();
 
     /**
      * active sessions (weak references)
@@ -206,11 +206,11 @@
             new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.WEAK);
 
     // misc. statistics
-    private long nodesCount = 0;
-    private long propsCount = 0;
+    private long nodesCount;
+    private long propsCount;
 
     // flag indicating if repository has been shut down
-    private boolean disposed = false;
+    private boolean disposed;
 
     /**
      * The repository lock mechanism ensures that a repository is only instantiated once.
@@ -298,9 +298,7 @@
             dataStore = repConfig.getDataStore();
 
             // init workspace configs
-            Iterator iter = repConfig.getWorkspaceConfigs().iterator();
-            while (iter.hasNext()) {
-                WorkspaceConfig config = (WorkspaceConfig) iter.next();
+            for (WorkspaceConfig config : repConfig.getWorkspaceConfigs()) {
                 WorkspaceInfo info = createWorkspaceInfo(config);
                 wspInfos.put(config.getName(), info);
             }
@@ -491,7 +489,7 @@
            secWspName = smc.getWorkspaceName();
         }
         try {
-            ((WorkspaceInfo) wspInfos.get(wspName)).initialize();
+            (wspInfos.get(wspName)).initialize();
             if (secWspName != null && !wspInfos.containsKey(secWspName)) {
                 createWorkspace(secWspName);
                 log.info("created system workspace: {}", secWspName);
@@ -709,7 +707,7 @@
      */
     protected String[] getWorkspaceNames() {
         synchronized (wspInfos) {
-            return (String[]) wspInfos.keySet().toArray(new String[wspInfos.keySet().size()]);
+            return wspInfos.keySet().toArray(new String[wspInfos.keySet().size()]);
         }
     }
 
@@ -730,7 +728,7 @@
 
         WorkspaceInfo wspInfo;
         synchronized (wspInfos) {
-            wspInfo = (WorkspaceInfo) wspInfos.get(workspaceName);
+            wspInfo = wspInfos.get(workspaceName);
             if (wspInfo == null) {
                 throw new NoSuchWorkspaceException(workspaceName);
             }
@@ -831,9 +829,7 @@
 
         if (createWorkspaceEventChannel == null) {
             createWorkspaceInternal(workspaceName, configTemplate);
-        }
-        else {
-
+        } else {
             ClonedInputSource template = new ClonedInputSource(configTemplate);
             createWorkspaceInternal(workspaceName, template.cloneInputSource());
             createWorkspaceEventChannel.workspaceCreated(workspaceName, template);
@@ -1114,8 +1110,8 @@
         synchronized (activeSessions) {
             int cnt = 0;
             sa = new SessionImpl[activeSessions.size()];
-            for (Iterator it = activeSessions.values().iterator(); it.hasNext(); cnt++) {
-                sa[cnt] = (SessionImpl) it.next();
+            for (Iterator<SessionImpl> it = activeSessions.values().iterator(); it.hasNext(); cnt++) {
+                sa[cnt] = it.next();
             }
         }
         for (int i = 0; i < sa.length; i++) {
@@ -1131,8 +1127,7 @@
 
         // shut down workspaces
         synchronized (wspInfos) {
-            for (Iterator it = wspInfos.values().iterator(); it.hasNext();) {
-                WorkspaceInfo wspInfo = (WorkspaceInfo) it.next();
+            for (WorkspaceInfo wspInfo : wspInfos.values()) {
                 wspInfo.dispose();
             }
         }
@@ -2183,7 +2178,7 @@
          * {@inheritDoc}
          */
         public void externalUpdate(ChangeLog external,
-                                   List events,
+                                   List<EventState> events,
                                    long timestamp,
                                    String userData) throws RepositoryException {
             try {
@@ -2257,9 +2252,9 @@
                     }
                 }
                 // get names of workspaces
-                Set wspNames;
+                Set<String> wspNames;
                 synchronized (wspInfos) {
-                    wspNames = new HashSet(wspInfos.keySet());
+                    wspNames = new HashSet<String>(wspInfos.keySet());
                 }
                 // remove default workspace (will never be shutdown when idle)
                 wspNames.remove(repConfig.getDefaultWorkspaceName());
@@ -2274,10 +2269,10 @@
 
                 // remaining names denote workspaces which currently have not
                 // active sessions
-                for (Iterator it = wspNames.iterator(); it.hasNext();) {
+                for (String wspName : wspNames) {
                     WorkspaceInfo wspInfo;
                     synchronized (wspInfos) {
-                        wspInfo = (WorkspaceInfo) wspInfos.get(it.next());
+                        wspInfo = wspInfos.get(wspName);
                     }
                     wspInfo.disposeIfIdle(maxIdleTime);
                 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TransactionContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TransactionContext.java?rev=785540&r1=785539&r2=785540&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TransactionContext.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TransactionContext.java Wed Jun 17 10:24:59 2009
@@ -52,7 +52,7 @@
     /**
      * The per thread associated Xid
      */
-    private static ThreadLocal CURRENT_XID = new ThreadLocal();
+    private static final ThreadLocal<Xid> CURRENT_XID = new ThreadLocal<Xid>();
 
     /**
      * Create a global timer for all transaction contexts.
@@ -73,11 +73,11 @@
     * The Xid
     */
    private final Xid xid;
-   
+
     /**
      * Transaction attributes.
      */
-    private final Map attributes = new HashMap();
+    private final Map<String, Object> attributes = new HashMap<String, Object>();
 
     /**
      * Status.
@@ -315,7 +315,7 @@
     public void setSuspended(boolean suspended) {
         this.suspended = suspended;
     }
-    
+
     /**
      * Helper Method to bind the {@link Xid} associated with this {@link TransactionContext}
      * to the {@link #CURRENT_XID} ThreadLocal.
@@ -331,25 +331,25 @@
     private void cleanCurrentXid() {
         CURRENT_XID.set(null);
     }
-    
+
     /**
      * Returns the {@link Xid} bind to the {@link #CURRENT_XID} ThreadLocal
      * @return current Xid or null
      */
     public static Xid getCurrentXid() {
-        return (Xid) CURRENT_XID.get();
+        return CURRENT_XID.get();
     }
-    
+
     /**
      * Helper Method to check if the given {@link Xid} has the same globalTransactionId
      * as the current {@link Xid} bind to the {@link #CURRENT_XID} ThreadLocal
      * @param xid Xid to check
-     * @param fallback if either the given {@link Xid} or the current {@link Xid} is null we can not check if they 
+     * @param fallback if either the given {@link Xid} or the current {@link Xid} is null we can not check if they
      *        are same, the fallback value will be returned
      * @return true if the same otherwise false
      */
     public static boolean isCurrentXid(Xid xid, boolean fallback) {
-        Xid currentXid = (Xid) CURRENT_XID.get();
-        return fallback ? true : (currentXid == null || xid == null) ? fallback : Arrays.equals(xid.getGlobalTransactionId(), currentXid.getGlobalTransactionId());  
+        Xid currentXid = CURRENT_XID.get();
+        return fallback ? true : (currentXid == null || xid == null) ? fallback : Arrays.equals(xid.getGlobalTransactionId(), currentXid.getGlobalTransactionId());
     }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java?rev=785540&r1=785539&r2=785540&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java Wed Jun 17 10:24:59 2009
@@ -17,7 +17,6 @@
 package org.apache.jackrabbit.core;
 
 import java.util.HashMap;
-import java.util.Iterator;
 
 import javax.jcr.AccessDeniedException;
 import javax.jcr.InvalidItemStateException;
@@ -794,22 +793,21 @@
         sanityCheck();
 
         // add all versions to map of versions to restore
-        final HashMap toRestore = new HashMap();
-        for (int i = 0; i < versions.length; i++) {
-            VersionImpl v = (VersionImpl) versions[i];
+        final HashMap<String, VersionImpl> toRestore = new HashMap<String, VersionImpl>();
+        for (Version v : versions) {
             VersionHistory vh = v.getContainingHistory();
             // check for collision
             if (toRestore.containsKey(vh.getUUID())) {
                 throw new VersionException("Unable to restore. Two or more versions have same version history.");
             }
-            toRestore.put(vh.getUUID(), v);
+            toRestore.put(vh.getUUID(), (VersionImpl) v);
         }
 
         // create a version selector to the set of versions
         VersionSelector vsel = new VersionSelector() {
             public Version select(VersionHistory versionHistory) throws RepositoryException {
                 // try to select version as specified
-                Version v = (Version) toRestore.get(versionHistory.getUUID());
+                Version v = toRestore.get(versionHistory.getUUID());
                 if (v == null) {
                     // select latest one
                     v = DateVersionSelector.selectByDate(versionHistory, null);
@@ -831,15 +829,13 @@
             int numRestored = 0;
             while (toRestore.size() > 0) {
                 Version[] restored = null;
-                Iterator iter = toRestore.values().iterator();
-                while (iter.hasNext()) {
-                    VersionImpl v = (VersionImpl) iter.next();
+                for (VersionImpl v : toRestore.values()) {
                     try {
                         NodeImpl node = (NodeImpl) session.getNodeByUUID(v.getInternalFrozenNode().getFrozenUUID());
                         restored = node.internalRestore(v, vsel, removeExisting);
                         // remove restored versions from set
-                        for (int i = 0; i < restored.length; i++) {
-                            toRestore.remove(restored[i].getContainingHistory().getUUID());
+                        for (Version r : restored) {
+                            toRestore.remove(r.getContainingHistory().getUUID());
                         }
                         numRestored += restored.length;
                         break;

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/UpdateEventListener.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/UpdateEventListener.java?rev=785540&r1=785539&r2=785540&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/UpdateEventListener.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/UpdateEventListener.java Wed Jun 17 10:24:59 2009
@@ -17,6 +17,8 @@
 package org.apache.jackrabbit.core.cluster;
 
 import java.util.List;
+
+import org.apache.jackrabbit.core.observation.EventState;
 import org.apache.jackrabbit.core.state.ChangeLog;
 import javax.jcr.RepositoryException;
 
@@ -34,7 +36,7 @@
      * @param userData the user data associated with this update.
      * @throws RepositoryException if the update cannot be processed
      */
-    void externalUpdate(ChangeLog changes, List events, long timestamp, String userData)
+    void externalUpdate(ChangeLog changes, List<EventState> events, long timestamp, String userData)
             throws RepositoryException;
 
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/OracleFileSystem.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/OracleFileSystem.java?rev=785540&r1=785539&r2=785540&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/OracleFileSystem.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/OracleFileSystem.java Wed Jun 17 10:24:59 2009
@@ -81,7 +81,7 @@
      */
     private static Logger log = LoggerFactory.getLogger(OracleFileSystem.class);
 
-    private Class blobClass;
+    private Class< ? > blobClass;
     private Integer durationSessionConstant;
     private Integer modeReadWriteConstant;
 
@@ -574,7 +574,7 @@
         open.invoke(blob, new Object[]{modeReadWriteConstant});
         Method getBinaryOutputStream =
                 blobClass.getMethod("getBinaryOutputStream", new Class[0]);
-        OutputStream out = (OutputStream) getBinaryOutputStream.invoke(blob, null);
+        OutputStream out = (OutputStream) getBinaryOutputStream.invoke(blob);
         try {
             IOUtils.copy(in, out);
         } finally {
@@ -585,7 +585,7 @@
             out.close();
         }
         Method close = blobClass.getMethod("close", new Class[0]);
-        close.invoke(blob, null);
+        close.invoke(blob);
         return (Blob) blob;
     }
 
@@ -595,6 +595,6 @@
     protected void freeTemporaryBlob(Object blob) throws Exception {
         // blob.freeTemporary();
         Method freeTemporary = blobClass.getMethod("freeTemporary", new Class[0]);
-        freeTemporary.invoke(blob, null);
+        freeTemporary.invoke(blob);
     }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/local/HandleMonitor.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/local/HandleMonitor.java?rev=785540&r1=785539&r2=785540&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/local/HandleMonitor.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/local/HandleMonitor.java Wed Jun 17 10:24:59 2009
@@ -26,7 +26,6 @@
 import java.io.InputStream;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
 
 /**
  * This Class implements a very simple open handle monitor for the local
@@ -44,7 +43,7 @@
     /**
      * the map of open handles (key=File, value=Handle)
      */
-    private HashMap openHandles = new HashMap();
+    private HashMap<File, Handle> openHandles = new HashMap<File, Handle>();
 
     /**
      * Opens a file and returns an InputStream
@@ -82,7 +81,7 @@
      * @return
      */
     private Handle getHandle(File file) {
-        Handle handle = (Handle) openHandles.get(file);
+        Handle handle = openHandles.get(file);
         if (handle == null) {
             handle = new Handle(file);
             openHandles.put(file, handle);
@@ -95,10 +94,8 @@
      */
     public void dump() {
         log.info("Number of open files: " + openHandles.size());
-        Iterator iter = openHandles.keySet().iterator();
-        while (iter.hasNext()) {
-            File file = (File) iter.next();
-            Handle handle = (Handle) openHandles.get(file);
+        for (File file : openHandles.keySet()) {
+            Handle handle = openHandles.get(file);
             handle.dump();
         }
     }
@@ -108,7 +105,7 @@
      * @param file
      */
     public void dump(File file) {
-        Handle handle = (Handle) openHandles.get(file);
+        Handle handle = openHandles.get(file);
         if (handle != null) {
             handle.dump(true);
         }
@@ -127,7 +124,7 @@
         /**
          * all open streams of this handle
          */
-        private HashSet streams = new HashSet();
+        private HashSet<Handle.MonitoredInputStream> streams = new HashSet<Handle.MonitoredInputStream>();
 
         /**
          * Creates a new handle for a file
@@ -172,9 +169,7 @@
         private void dump(boolean detailed) {
             if (detailed) {
                 log.info("- " + file.getPath() + ", " + streams.size());
-                Iterator iter = streams.iterator();
-                while (iter.hasNext()) {
-                    Handle.MonitoredInputStream in = (Handle.MonitoredInputStream) iter.next();
+                for (Handle.MonitoredInputStream in : streams) {
                     in.dump();
                 }
             } else {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/local/LocalFileSystem.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/local/LocalFileSystem.java?rev=785540&r1=785539&r2=785540&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/local/LocalFileSystem.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/local/LocalFileSystem.java Wed Jun 17 10:24:59 2009
@@ -41,7 +41,7 @@
 
     private File root;
 
-    private HandleMonitor monitor = null;
+    private HandleMonitor monitor;
 
     /**
      * Default constructor

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java?rev=785540&r1=785539&r2=785540&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java Wed Jun 17 10:24:59 2009
@@ -93,22 +93,25 @@
     private final PathMap lockMap = new PathMap();
 
     private final ReentrantLock lockMapLock = new ReentrantLock(){
-        
+
         private Xid activeXid;
-        
+
         public void acquire() throws InterruptedException {
-            if (Thread.interrupted()) throw new InterruptedException();
+            if (Thread.interrupted()) {
+                throw new InterruptedException();
+            }
             Thread caller = Thread.currentThread();
-            synchronized(this) {
+            synchronized (this) {
                 boolean allow = TransactionContext.isCurrentXid(activeXid, caller == owner_);
                 if (allow) {
                     ++holds_;
                 } else {
-                    try {  
-                        while (owner_ != null) 
-                            wait(); 
+                    try {
+                        while (owner_ != null) {
+                            wait();
+                        }
                         owner_ = caller;
-                        activeXid = (Xid) TransactionContext.getCurrentXid();
+                        activeXid = TransactionContext.getCurrentXid();
                         holds_ = 1;
                     } catch (InterruptedException ex) {
                         notify();
@@ -117,18 +120,18 @@
                 }
             }
         }
-        
+
         public synchronized void release()  {
             boolean allow = TransactionContext.isCurrentXid(activeXid, Thread.currentThread() == owner_);
-            if (!allow)
-                throw new Error("Illegal Lock usage"); 
-
+            if (!allow) {
+                throw new Error("Illegal Lock usage");
+            }
             if (--holds_ == 0) {
                 owner_ = null;
                 activeXid = null;
-                notify(); 
+                notify();
             }
-        }       
+        }
     };
 
     /**
@@ -257,7 +260,7 @@
             writer = new BufferedWriter(
                     new OutputStreamWriter(locksFile.getOutputStream()));
             for (int i = 0; i < list.size(); i++) {
-                AbstractLockInfo info = (AbstractLockInfo) list.get(i);
+                AbstractLockInfo info = list.get(i);
                 writer.write(info.lockToken.toString());
                 writer.newLine();
             }
@@ -388,7 +391,7 @@
             }
 
             getSessionLockManager(session).lockTokenRemoved(info.getLockToken(session));
-            
+
             element.set(null);
             info.setLive(false);
 
@@ -423,7 +426,7 @@
                 }
             }
         }, false);
-        return (AbstractLockInfo[]) infos.toArray(new AbstractLockInfo[infos.size()]);
+        return infos.toArray(new AbstractLockInfo[infos.size()]);
     }
 
     /**
@@ -1020,7 +1023,7 @@
      * its position.
      */
     private void refresh(PathMap.Element element) {
-        final ArrayList infos = new ArrayList();
+        final ArrayList<LockInfo> infos = new ArrayList<LockInfo>();
         boolean needsSave = false;
 
         // save away non-empty children
@@ -1037,7 +1040,7 @@
         // now re-insert at appropriate location or throw away if node
         // does no longer exist
         for (int i = 0; i < infos.size(); i++) {
-            LockInfo info = (LockInfo) infos.get(i);
+            LockInfo info = infos.get(i);
             try {
                 NodeImpl node = (NodeImpl) sysSession.getItemManager().
                         getItem(info.getId());

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/DispatchAction.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/DispatchAction.java?rev=785540&r1=785539&r2=785540&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/DispatchAction.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/DispatchAction.java Wed Jun 17 10:24:59 2009
@@ -34,13 +34,13 @@
      * <code>EventStates</code> are dispatched to these
      * <code>EventConsumer</code>s.
      */
-    private final Collection eventConsumers;
+    private final Collection<EventConsumer> eventConsumers;
 
     /**
      * Creates a new <code>DispatchAction</code> struct with
      * <code>eventStates</code> and <code>eventConsumers</code>.
      */
-    DispatchAction(EventStateCollection eventStates, Collection eventConsumers) {
+    DispatchAction(EventStateCollection eventStates, Collection<EventConsumer> eventConsumers) {
         this.eventStates = eventStates;
         this.eventConsumers = eventConsumers;
     }
@@ -60,7 +60,7 @@
      *
      * @return a <code>Collection</code> of {@link EventConsumer}s.
      */
-    Collection getEventConsumers() {
+    Collection<EventConsumer> getEventConsumers() {
         return eventConsumers;
     }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventConsumer.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventConsumer.java?rev=785540&r1=785539&r2=785540&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventConsumer.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventConsumer.java Wed Jun 17 10:24:59 2009
@@ -74,7 +74,7 @@
      * <code>ItemId</code>s of denied <code>ItemState</code>s. The map uses the
      * <code>EventStateCollection</code> as the key to reference a deny Set.
      */
-    private final Map accessDenied = Collections.synchronizedMap(new WeakHashMap());
+    private final Map<EventStateCollection, Set<ItemId>> accessDenied = Collections.synchronizedMap(new WeakHashMap<EventStateCollection, Set<ItemId>>());
 
     /**
      * cached hash code value
@@ -137,10 +137,10 @@
      * @param events the collection of {@link EventState}s.
      */
     void prepareEvents(EventStateCollection events) {
-        Iterator it = events.iterator();
-        Set denied = null;
+        Iterator<EventState> it = events.iterator();
+        Set<ItemId> denied = null;
         while (it.hasNext()) {
-            EventState state = (EventState) it.next();
+            EventState state = it.next();
             if (state.getType() == Event.NODE_REMOVED
                     || state.getType() == Event.PROPERTY_REMOVED) {
 
@@ -160,7 +160,7 @@
                 }
                 if (!granted) {
                     if (denied == null) {
-                        denied = new HashSet();
+                        denied = new HashSet<ItemId>();
                     }
                     denied.add(targetId);
                 }
@@ -178,15 +178,15 @@
      * @param events       the collection of {@link EventState}s.
      * @param deletedItems Iterator of deleted <code>ItemState</code>s.
      */
-    void prepareDeleted(EventStateCollection events, Iterator deletedItems) {
-        Set denied = null;
-        Set deletedIds = new HashSet();
+    void prepareDeleted(EventStateCollection events, Iterator<ItemState> deletedItems) {
+        Set<ItemId> denied = null;
+        Set<ItemId> deletedIds = new HashSet<ItemId>();
         while (deletedItems.hasNext()) {
-            deletedIds.add(((ItemState) deletedItems.next()).getId());
+            deletedIds.add((deletedItems.next()).getId());
         }
 
-        for (Iterator it = events.iterator(); it.hasNext();) {
-            EventState evState = (EventState) it.next();
+        for (Iterator<EventState> it = events.iterator(); it.hasNext();) {
+            EventState evState = it.next();
             ItemId targetId = evState.getTargetId();
             if (deletedIds.contains(targetId)) {
                 // check read permission
@@ -198,7 +198,7 @@
                 }
                 if (!granted) {
                     if (denied == null) {
-                        denied = new HashSet();
+                        denied = new HashSet<ItemId>();
                     }
                     denied.add(targetId);
                 }
@@ -217,17 +217,17 @@
      */
     void consumeEvents(EventStateCollection events) throws RepositoryException {
         // Set of ItemIds of denied ItemStates
-        Set denied = (Set) accessDenied.remove(events);
+        Set<ItemId> denied = accessDenied.remove(events);
         // check permissions
-        for (Iterator it = events.iterator(); it.hasNext() && session.isLive();) {
-            EventState state = (EventState) it.next();
+        for (Iterator<EventState> it = events.iterator(); it.hasNext() && session.isLive();) {
+            EventState state = it.next();
             if (state.getType() == Event.NODE_ADDED
                     || state.getType() == Event.PROPERTY_ADDED
                     || state.getType() == Event.PROPERTY_CHANGED) {
                 ItemId targetId = state.getTargetId();
                 if (!canRead(state)) {
                     if (denied == null) {
-                        denied = new HashSet();
+                        denied = new HashSet<ItemId>();
                     }
                     denied.add(targetId);
                 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java?rev=785540&r1=785539&r2=785540&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java Wed Jun 17 10:24:59 2009
@@ -71,7 +71,7 @@
     /**
      * List of events
      */
-    private final List events = new ArrayList();
+    private final List<EventState> events = new ArrayList<EventState>();
 
     /**
      * Event dispatcher.
@@ -161,8 +161,8 @@
 
         // 1. modified items
 
-        for (Iterator it = changes.modifiedStates(); it.hasNext();) {
-            ItemState state = (ItemState) it.next();
+        for (Iterator<ItemState> it = changes.modifiedStates(); it.hasNext();) {
+            ItemState state = it.next();
             if (state.isNode()) {
                 // node changed
                 // covers the following cases:
@@ -195,7 +195,7 @@
                     NodeId newParentId = n.getParentId();
                     if (newParentId != null && !oldParentId.equals(newParentId) &&
                             !n.isShareable()) {
-                        
+
                         // node moved
                         // generate node removed & node added event
                         NodeState oldParent;
@@ -208,7 +208,7 @@
                         }
 
                         NodeTypeImpl oldParentNodeType = getNodeType(oldParent, session);
-                        Set mixins = oldParent.getMixinTypeNames();
+                        Set<Name> mixins = oldParent.getMixinTypeNames();
                         Path newPath = getPath(n.getNodeId(), hmgr);
                         Path oldPath = getZombiePath(n.getNodeId(), hmgr);
                         events.add(EventState.childNodeRemoved(oldParentId,
@@ -248,8 +248,7 @@
                         if (parent != null) {
                             // check if node has been renamed
                             ChildNodeEntry moved = null;
-                            for (Iterator removedNodes = parent.getRemovedChildNodeEntries().iterator(); removedNodes.hasNext();) {
-                                ChildNodeEntry child = (ChildNodeEntry) removedNodes.next();
+                            for (ChildNodeEntry child : parent.getRemovedChildNodeEntries()) {
                                 if (child.getId().equals(n.getNodeId())) {
                                     // found node re-added with different name
                                     moved = child;
@@ -257,7 +256,7 @@
                             }
                             if (moved != null) {
                                 NodeTypeImpl nodeType = getNodeType(parent, session);
-                                Set mixins = parent.getMixinTypeNames();
+                                Set<Name> mixins = parent.getMixinTypeNames();
                                 Path newPath = getPath(state.getId(), hmgr);
                                 Path parentPath = getParent(newPath);
                                 Path oldPath;
@@ -294,14 +293,13 @@
                 }
 
                 // check if child nodes of modified node state have been reordered
-                List reordered = n.getReorderedChildNodeEntries();
+                List<ChildNodeEntry> reordered = n.getReorderedChildNodeEntries();
                 NodeTypeImpl nodeType = getNodeType(n, session);
-                Set mixins = n.getMixinTypeNames();
+                Set<Name> mixins = n.getMixinTypeNames();
                 if (reordered.size() > 0) {
                     // create a node removed and a node added event for every
                     // reorder
-                    for (Iterator ro = reordered.iterator(); ro.hasNext();) {
-                        ChildNodeEntry child = (ChildNodeEntry) ro.next();
+                    for (ChildNodeEntry child : reordered) {
                         Path.Element addedElem = getPathElement(child);
                         Path parentPath = getPath(n.getNodeId(), hmgr);
                         // get removed index
@@ -320,13 +318,13 @@
                                 parentPath, child.getId(), addedElem,
                                 nodeType.getQName(), mixins, session));
 
-                        List cne = n.getChildNodeEntries();
+                        List<ChildNodeEntry> cne = n.getChildNodeEntries();
                         // index of the child node entry before which this
                         // child node entry was reordered
                         int idx = cne.indexOf(child) + 1;
                         Path.Element beforeElem = null;
                         if (idx < cne.size()) {
-                            beforeElem = getPathElement((ChildNodeEntry) cne.get(idx));
+                            beforeElem = getPathElement(cne.get(idx));
                         }
 
                         events.add(EventState.nodeReordered(n.getNodeId(),
@@ -343,7 +341,7 @@
                 Path path = getPath(state.getId(), hmgr);
                 NodeState parent = (NodeState) stateMgr.getItemState(state.getParentId());
                 NodeTypeImpl nodeType = getNodeType(parent, session);
-                Set mixins = parent.getMixinTypeNames();
+                Set<Name> mixins = parent.getMixinTypeNames();
                 events.add(EventState.propertyChanged(state.getParentId(),
                         getParent(path), path.getNameElement(),
                         nodeType.getQName(), mixins, session));
@@ -352,14 +350,14 @@
 
         // 2. removed items
 
-        for (Iterator it = changes.deletedStates(); it.hasNext();) {
-            ItemState state = (ItemState) it.next();
+        for (Iterator<ItemState> it = changes.deletedStates(); it.hasNext();) {
+            ItemState state = it.next();
             if (state.isNode()) {
                 // node deleted
                 NodeState n = (NodeState) state;
                 NodeState parent = (NodeState) stateMgr.getItemState(n.getParentId());
                 NodeTypeImpl nodeType = getNodeType(parent, session);
-                Set mixins = parent.getMixinTypeNames();
+                Set<Name> mixins = parent.getMixinTypeNames();
                 Path path = getZombiePath(state.getId(), hmgr);
                 events.add(EventState.childNodeRemoved(n.getParentId(),
                         getParent(path),
@@ -378,7 +376,7 @@
                     NodeState n = (NodeState) changes.get(state.getParentId());
                     // node state exists -> only property removed
                     NodeTypeImpl nodeType = getNodeType(n, session);
-                    Set mixins = n.getMixinTypeNames();
+                    Set<Name> mixins = n.getMixinTypeNames();
                     Path path = getZombiePath(state.getId(), hmgr);
                     events.add(EventState.propertyRemoved(state.getParentId(),
                             getParent(path),
@@ -394,8 +392,8 @@
 
         // 3. added items
 
-        for (Iterator it = changes.addedStates(); it.hasNext();) {
-            ItemState state = (ItemState) it.next();
+        for (Iterator<ItemState> it = changes.addedStates(); it.hasNext();) {
+            ItemState state = it.next();
             if (state.isNode()) {
                 // node created
                 NodeState n = (NodeState) state;
@@ -403,7 +401,7 @@
                 // the parent of an added item is always modified or new
                 NodeState parent = (NodeState) changes.get(parentId);
                 NodeTypeImpl nodeType = getNodeType(parent, session);
-                Set mixins = parent.getMixinTypeNames();
+                Set<Name> mixins = parent.getMixinTypeNames();
                 Path path = getPath(n.getNodeId(), hmgr);
                 events.add(EventState.childNodeAdded(parentId,
                         getParent(path),
@@ -419,7 +417,7 @@
                 // property created / set
                 NodeState n = (NodeState) changes.get(state.getParentId());
                 NodeTypeImpl nodeType = getNodeType(n, session);
-                Set mixins = n.getMixinTypeNames();
+                Set<Name> mixins = n.getMixinTypeNames();
                 Path path = getPath(state.getId(), hmgr);
                 events.add(EventState.propertyAdded(state.getParentId(),
                         getParent(path),
@@ -436,7 +434,7 @@
      *
      * @param c
      */
-    public void addAll(Collection c) {
+    public void addAll(Collection<EventState> c) {
         events.addAll(c);
     }
 
@@ -495,7 +493,7 @@
      *
      * @return an iterator over {@link EventState} instance.
      */
-    Iterator iterator() {
+    Iterator<EventState> iterator() {
         return events.iterator();
     }
 
@@ -503,7 +501,7 @@
      * Return the list of events.
      * @return list of events
      */
-    public List getEvents() {
+    public List<EventState> getEvents() {
         return Collections.unmodifiableList(events);
     }
 
@@ -540,8 +538,7 @@
             throws ItemStateException {
         if (n.isShareable()) {
             // check if a share was added or removed
-            for (Iterator added = n.getAddedShares().iterator(); added.hasNext(); ) {
-                NodeId parentId = (NodeId) added.next();
+            for (NodeId parentId : n.getAddedShares()) {
                 // ignore primary parent id
                 if (n.getParentId().equals(parentId)) {
                     continue;
@@ -565,8 +562,7 @@
                 es.setShareableNode(true);
                 events.add(es);
             }
-            for (Iterator removed = n.getRemovedShares().iterator(); removed.hasNext(); ) {
-                NodeId parentId = (NodeId) removed.next();
+            for (NodeId parentId : n.getRemovedShares()) {
                 // if this shareable node is removed, only create events for
                 // parent ids that are not primary
                 if (n.getParentId().equals(parentId)) {
@@ -765,15 +761,15 @@
     }
 
     /**
-     * Get the longest common path of all event state paths. 
-     * 
+     * Get the longest common path of all event state paths.
+     *
      * @return the longest common path
      */
     public String getCommonPath() {
         String common = null;
         try {
             for (int i = 0; i < events.size(); i++) {
-                EventState state = (EventState) events.get(i);
+                EventState state = events.get(i);
                 String s = session.getJCRPath(state.getParentPath());
                 if (common == null) {
                     common = s;

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/FilteredEventIterator.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/FilteredEventIterator.java?rev=785540&r1=785539&r2=785540&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/FilteredEventIterator.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/FilteredEventIterator.java Wed Jun 17 10:24:59 2009
@@ -59,7 +59,7 @@
     /**
      * Current position
      */
-    private long pos = 0;
+    private long pos;
 
     /**
      * The timestamp when the events occured.

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ObservationDispatcher.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ObservationDispatcher.java?rev=785540&r1=785539&r2=785540&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ObservationDispatcher.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ObservationDispatcher.java Wed Jun 17 10:24:59 2009
@@ -48,22 +48,22 @@
     /**
      * Currently active <code>EventConsumer</code>s for notification.
      */
-    private Set activeConsumers = new HashSet();
+    private Set<EventConsumer> activeConsumers = new HashSet<EventConsumer>();
 
     /**
      * Currently active synchronous <code>EventConsumer</code>s for notification.
      */
-    private Set synchronousConsumers = new HashSet();
+    private Set<EventConsumer> synchronousConsumers = new HashSet<EventConsumer>();
 
     /**
      * Set of <code>EventConsumer</code>s for read only Set access
      */
-    private Set readOnlyConsumers;
+    private Set<EventConsumer> readOnlyConsumers;
 
     /**
      * Set of synchronous <code>EventConsumer</code>s for read only Set access.
      */
-    private Set synchronousReadOnlyConsumers;
+    private Set<EventConsumer> synchronousReadOnlyConsumers;
 
     /**
      * synchronization monitor for listener changes
@@ -111,19 +111,19 @@
      *
      * @return <code>Set</code> of <code>EventConsumer</code>s.
      */
-    Set getAsynchronousConsumers() {
+    Set<EventConsumer> getAsynchronousConsumers() {
         synchronized (consumerChange) {
             if (readOnlyConsumers == null) {
-                readOnlyConsumers = Collections.unmodifiableSet(new HashSet(activeConsumers));
+                readOnlyConsumers = Collections.unmodifiableSet(new HashSet<EventConsumer>(activeConsumers));
             }
             return readOnlyConsumers;
         }
     }
 
-    Set getSynchronousConsumers() {
+    Set<EventConsumer> getSynchronousConsumers() {
         synchronized (consumerChange) {
             if (synchronousReadOnlyConsumers == null) {
-                synchronousReadOnlyConsumers = Collections.unmodifiableSet(new HashSet(synchronousConsumers));
+                synchronousReadOnlyConsumers = Collections.unmodifiableSet(new HashSet<EventConsumer>(synchronousConsumers));
             }
             return synchronousReadOnlyConsumers;
         }
@@ -139,8 +139,8 @@
 
             log.debug("got EventStateCollection");
             log.debug("event delivery to " + action.getEventConsumers().size() + " consumers started...");
-            for (Iterator it = action.getEventConsumers().iterator(); it.hasNext();) {
-                EventConsumer c = (EventConsumer) it.next();
+            for (Iterator<EventConsumer> it = action.getEventConsumers().iterator(); it.hasNext();) {
+                EventConsumer c = it.next();
                 try {
                     c.consumeEvents(action.getEventStates());
                 } catch (Throwable t) {
@@ -161,11 +161,10 @@
      * prepare the events for dispatching.
      */
     void prepareEvents(EventStateCollection events) {
-        Set consumers = new HashSet();
+        Set<EventConsumer> consumers = new HashSet<EventConsumer>();
         consumers.addAll(getSynchronousConsumers());
         consumers.addAll(getAsynchronousConsumers());
-        for (Iterator it = consumers.iterator(); it.hasNext();) {
-            EventConsumer c = (EventConsumer) it.next();
+        for (EventConsumer c : consumers) {
             c.prepareEvents(events);
         }
     }
@@ -174,11 +173,10 @@
      * {@inheritDoc}
      */
     void prepareDeleted(EventStateCollection events, ChangeLog changes) {
-        Set consumers = new HashSet();
+        Set<EventConsumer> consumers = new HashSet<EventConsumer>();
         consumers.addAll(getSynchronousConsumers());
         consumers.addAll(getAsynchronousConsumers());
-        for (Iterator it = consumers.iterator(); it.hasNext();) {
-            EventConsumer c = (EventConsumer) it.next();
+        for (EventConsumer c : consumers) {
             c.prepareDeleted(events, changes.deletedStates());
         }
     }
@@ -191,12 +189,11 @@
      */
     void dispatchEvents(EventStateCollection events) {
         // notify synchronous listeners
-        Set synchronous = getSynchronousConsumers();
+        Set<EventConsumer> synchronous = getSynchronousConsumers();
         if (log.isDebugEnabled()) {
             log.debug("notifying " + synchronous.size() + " synchronous listeners.");
         }
-        for (Iterator it = synchronous.iterator(); it.hasNext();) {
-            EventConsumer c = (EventConsumer) it.next();
+        for (EventConsumer c : synchronous) {
             try {
                 c.consumeEvents(events);
             } catch (Throwable t) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/mem/InMemPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/mem/InMemPersistenceManager.java?rev=785540&r1=785539&r2=785540&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/mem/InMemPersistenceManager.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/mem/InMemPersistenceManager.java Wed Jun 17 10:24:59 2009
@@ -39,7 +39,6 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.jcr.PropertyType;
 import java.io.BufferedInputStream;
 import java.io.BufferedOutputStream;
 import java.io.ByteArrayInputStream;

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/obj/ObjectPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/obj/ObjectPersistenceManager.java?rev=785540&r1=785539&r2=785540&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/obj/ObjectPersistenceManager.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/obj/ObjectPersistenceManager.java Wed Jun 17 10:24:59 2009
@@ -38,7 +38,6 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.jcr.PropertyType;
 import java.io.BufferedInputStream;
 import java.io.BufferedOutputStream;
 import java.io.File;

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/retention/RetentionRegistryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/retention/RetentionRegistryImpl.java?rev=785540&r1=785539&r2=785540&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/retention/RetentionRegistryImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/retention/RetentionRegistryImpl.java Wed Jun 17 10:24:59 2009
@@ -69,10 +69,10 @@
     private final SessionImpl session;
     private final FileSystemResource retentionFile;
 
-    private long holdCnt = 0;
-    private long retentionCnt = 0;
-    
-    private boolean initialized = false;
+    private long holdCnt;
+    private long retentionCnt;
+
+    private boolean initialized;
 
     public RetentionRegistryImpl(SessionImpl session, FileSystem fs) throws RepositoryException {
         this.session = session;
@@ -107,7 +107,7 @@
      * node, that entry will be ignored. Upon {@link #close()} of this
      * manager, the file will be updated to reflect the actual set of holds/
      * retentions present and effective in the content.
-     * 
+     *
      * @throws IOException
      * @throws FileSystemException
      */
@@ -194,12 +194,12 @@
         writeRetentionFile();
         initialized = false;
     }
-    
+
     private void addHolds(Path nodePath, PropertyImpl p) throws RepositoryException {
         synchronized (holdMap) {
             Hold[] holds = HoldImpl.createFromProperty(p, ((PropertyId) p.getId()).getParentId());
             holdMap.put(nodePath, Arrays.asList(holds));
-            holdCnt++;            
+            holdCnt++;
         }
     }
 
@@ -284,7 +284,7 @@
         if (element != null) {
             rp = (RetentionPolicy) element.get();
         }
-        if (rp == null && checkParent ) {
+        if (rp == null && checkParent) {
             element = retentionMap.map(nodePath.getAncestor(1), true);
             if (element != null) {
                 rp = (RetentionPolicy) element.get();
@@ -341,7 +341,7 @@
                 // else: not interested in any other property -> ignore.
 
             } catch (RepositoryException e) {
-                log.warn("Internal error while processing event.",e.getMessage());
+                log.warn("Internal error while processing event.", e.getMessage());
                 // ignore.
             }
         }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeStateMerger.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeStateMerger.java?rev=785540&r1=785539&r2=785540&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeStateMerger.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeStateMerger.java Wed Jun 17 10:24:59 2009
@@ -23,7 +23,6 @@
 
 import java.util.ArrayList;
 import java.util.HashSet;
-import java.util.Iterator;
 
 /**
  * Internal utility class used for merging concurrent changes that occurred
@@ -98,13 +97,10 @@
                 // child node entries
                 if (!state.getChildNodeEntries().equals(
                         overlayedState.getChildNodeEntries())) {
-                    ArrayList added = new ArrayList();
-                    ArrayList removed = new ArrayList();
+                    ArrayList<ChildNodeEntry> added = new ArrayList<ChildNodeEntry>();
+                    ArrayList<ChildNodeEntry> removed = new ArrayList<ChildNodeEntry>();
 
-                    for (Iterator iter = state.getAddedChildNodeEntries().iterator();
-                         iter.hasNext();) {
-                        ChildNodeEntry cne =
-                                (ChildNodeEntry) iter.next();
+                    for (ChildNodeEntry cne : state.getAddedChildNodeEntries()) {
 
                         if (context.isAdded(cne.getId())) {
                             // a new child node entry has been added to this state;
@@ -124,10 +120,7 @@
                         }
                     }
 
-                    for (Iterator iter = state.getRemovedChildNodeEntries().iterator();
-                         iter.hasNext();) {
-                        ChildNodeEntry cne =
-                                (ChildNodeEntry) iter.next();
+                    for (ChildNodeEntry cne : state.getRemovedChildNodeEntries()) {
                         if (context.isDeleted(cne.getId())) {
                             // a child node entry has been removed from this node state
                             removed.add(cne);
@@ -137,14 +130,10 @@
                     // copy child node antries from other state and
                     // re-apply changes made on this state
                     state.setChildNodeEntries(overlayedState.getChildNodeEntries());
-                    for (Iterator iter = added.iterator(); iter.hasNext();) {
-                        ChildNodeEntry cne =
-                                (ChildNodeEntry) iter.next();
+                    for (ChildNodeEntry cne : added) {
                         state.addChildNodeEntry(cne.getName(), cne.getId());
                     }
-                    for (Iterator iter = removed.iterator(); iter.hasNext();) {
-                        ChildNodeEntry cne =
-                                (ChildNodeEntry) iter.next();
+                    for (ChildNodeEntry cne : removed) {
                         state.removeChildNodeEntry(cne.getId());
                     }
                 }
@@ -152,12 +141,10 @@
                 // property names
                 if (!state.getPropertyNames().equals(
                         overlayedState.getPropertyNames())) {
-                    HashSet added = new HashSet();
-                    HashSet removed = new HashSet();
+                    HashSet<Name> added = new HashSet<Name>();
+                    HashSet<Name> removed = new HashSet<Name>();
 
-                    for (Iterator iter = state.getAddedPropertyNames().iterator();
-                         iter.hasNext();) {
-                        Name name = (Name) iter.next();
+                    for (Name name : state.getAddedPropertyNames()) {
                         PropertyId propId =
                                 new PropertyId(state.getNodeId(), name);
                         if (context.isAdded(propId)) {
@@ -172,9 +159,7 @@
                             added.add(name);
                         }
                     }
-                    for (Iterator iter = state.getRemovedPropertyNames().iterator();
-                         iter.hasNext();) {
-                        Name name = (Name) iter.next();
+                    for (Name name : state.getRemovedPropertyNames()) {
                         PropertyId propId =
                                 new PropertyId(state.getNodeId(), name);
                         if (context.isDeleted(propId)) {
@@ -186,12 +171,10 @@
                     // copy property names from other and
                     // re-apply changes made on this state
                     state.setPropertyNames(overlayedState.getPropertyNames());
-                    for (Iterator iter = added.iterator(); iter.hasNext();) {
-                        Name name = (Name) iter.next();
+                    for (Name name : added) {
                         state.addPropertyName(name);
                     }
-                    for (Iterator iter = removed.iterator(); iter.hasNext();) {
-                        Name name = (Name) iter.next();
+                    for (Name name : removed) {
                         state.removePropertyName(name);
                     }
                 }
@@ -206,6 +189,9 @@
 
     //-----------------------------------------------------< inner interfaces >
 
+    /**
+     * The context of a modification.
+     */
     static interface MergeContext {
         boolean isAdded(ItemId id);
         boolean isDeleted(ItemId id);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java?rev=785540&r1=785539&r2=785540&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java Wed Jun 17 10:24:59 2009
@@ -39,6 +39,7 @@
 import org.apache.jackrabbit.core.nodetype.NodeTypeConflictException;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.nodetype.PropDef;
+import org.apache.jackrabbit.core.observation.EventState;
 import org.apache.jackrabbit.core.observation.EventStateCollection;
 import org.apache.jackrabbit.core.observation.EventStateCollectionFactory;
 import org.apache.jackrabbit.core.persistence.PersistenceManager;
@@ -520,7 +521,7 @@
         /**
          * Map of attributes stored for this update operation.
          */
-        private HashMap attributes;
+        private HashMap<String, Object> attributes;
 
         /**
          * Timestamp when this update was created.
@@ -595,8 +596,8 @@
                  * respective shared item and add the shared items to a
                  * new change log.
                  */
-                for (Iterator iter = local.modifiedStates(); iter.hasNext();) {
-                    ItemState state = (ItemState) iter.next();
+                for (Iterator<ItemState> iter = local.modifiedStates(); iter.hasNext();) {
+                    ItemState state = iter.next();
                     state.connect(getItemState(state.getId()));
                     if (state.isStale()) {
                         boolean merged = false;
@@ -648,8 +649,8 @@
 
                     shared.modified(state.getOverlayedState());
                 }
-                for (Iterator iter = local.deletedStates(); iter.hasNext();) {
-                    ItemState state = (ItemState) iter.next();
+                for (Iterator<ItemState> iter = local.deletedStates(); iter.hasNext();) {
+                    ItemState state = iter.next();
                     state.connect(getItemState(state.getId()));
                     if (state.isStale()) {
                         String msg = state.getId() + " has been modified externally";
@@ -658,16 +659,16 @@
                     }
                     shared.deleted(state.getOverlayedState());
                 }
-                for (Iterator iter = local.addedStates(); iter.hasNext();) {
-                    ItemState state = (ItemState) iter.next();
+                for (Iterator<ItemState> iter = local.addedStates(); iter.hasNext();) {
+                    ItemState state = iter.next();
                     state.connect(createInstance(state));
                     shared.added(state.getOverlayedState());
                 }
 
                 // filter out virtual node references for later processing
                 // (see comment above)
-                for (Iterator iter = local.modifiedRefs(); iter.hasNext();) {
-                    NodeReferences refs = (NodeReferences) iter.next();
+                for (Iterator<NodeReferences> iter = local.modifiedRefs(); iter.hasNext();) {
+                    NodeReferences refs = iter.next();
                     boolean virtual = false;
                     NodeId id = refs.getId().getTargetId();
                     for (int i = 0; i < virtualProviders.length; i++) {
@@ -786,24 +787,24 @@
 
                 local.disconnect();
 
-                for (Iterator iter = shared.modifiedStates(); iter.hasNext();) {
-                    ItemState state = (ItemState) iter.next();
+                for (Iterator<ItemState> iter = shared.modifiedStates(); iter.hasNext();) {
+                    ItemState state = iter.next();
                     try {
                         state.copy(loadItemState(state.getId()), false);
                     } catch (ItemStateException e) {
                         state.discard();
                     }
                 }
-                for (Iterator iter = shared.deletedStates(); iter.hasNext();) {
-                    ItemState state = (ItemState) iter.next();
+                for (Iterator<ItemState> iter = shared.deletedStates(); iter.hasNext();) {
+                    ItemState state = iter.next();
                     try {
                         state.copy(loadItemState(state.getId()), false);
                     } catch (ItemStateException e) {
                         state.discard();
                     }
                 }
-                for (Iterator iter = shared.addedStates(); iter.hasNext();) {
-                    ItemState state = (ItemState) iter.next();
+                for (Iterator<ItemState> iter = shared.addedStates(); iter.hasNext();) {
+                    ItemState state = iter.next();
                     state.discard();
                 }
             } finally {
@@ -819,7 +820,7 @@
          */
         public void setAttribute(String name, Object value) {
             if (attributes == null) {
-                attributes = new HashMap();
+                attributes = new HashMap<String, Object>();
             }
             attributes.put(name, value);
         }
@@ -844,7 +845,7 @@
         /**
          * {@inheritDoc}
          */
-        public List getEvents() {
+        public List<EventState> getEvents() {
             return events.getEvents();
         }
 
@@ -872,13 +873,13 @@
          */
         private void updateReferences() throws ItemStateException {
             // process added REFERENCE properties
-            for (Iterator i = local.addedStates(); i.hasNext();) {
-                addReferences((ItemState) i.next());
+            for (Iterator<ItemState> i = local.addedStates(); i.hasNext();) {
+                addReferences(i.next());
             }
 
             // process modified REFERENCE properties
-            for (Iterator i = local.modifiedStates(); i.hasNext();) {
-                ItemState state = (ItemState) i.next();
+            for (Iterator<ItemState> i = local.modifiedStates(); i.hasNext();) {
+                ItemState state = i.next();
                 if (!state.isNode()) {
                     // remove old references from the target
                     removeReferences(getItemState(state.getId()));
@@ -888,8 +889,8 @@
             }
 
             // process removed REFERENCE properties
-            for (Iterator i = local.deletedStates(); i.hasNext();) {
-                removeReferences((ItemState) i.next());
+            for (Iterator<ItemState> i = local.deletedStates(); i.hasNext();) {
+                removeReferences(i.next());
             }
         }
 
@@ -979,8 +980,8 @@
                 throws ReferentialIntegrityException, ItemStateException {
 
             // check whether removed referenceable nodes are still being referenced
-            for (Iterator iter = local.deletedStates(); iter.hasNext();) {
-                ItemState state = (ItemState) iter.next();
+            for (Iterator<ItemState> iter = local.deletedStates(); iter.hasNext();) {
+                ItemState state = iter.next();
                 if (state.isNode()) {
                     NodeState node = (NodeState) state;
                     if (isReferenceable(node)) {
@@ -1008,8 +1009,8 @@
             }
 
             // check whether targets of modified node references exist
-            for (Iterator iter = local.modifiedRefs(); iter.hasNext();) {
-                NodeReferences refs = (NodeReferences) iter.next();
+            for (Iterator<NodeReferences> iter = local.modifiedRefs(); iter.hasNext();) {
+                NodeReferences refs = iter.next();
                 NodeId id = refs.getTargetId();
                 // no need to check existence of target if there are no references
                 if (refs.hasReferences()) {
@@ -1037,7 +1038,7 @@
         private boolean isReferenceable(NodeState state) throws ItemStateException {
             // shortcut: check some well known built-in types first
             Name primary = state.getNodeTypeName();
-            Set mixins = state.getMixinTypeNames();
+            Set<Name> mixins = state.getMixinTypeNames();
             if (mixins.contains(NameConstants.MIX_REFERENCEABLE)
                     || mixins.contains(NameConstants.MIX_VERSIONABLE)
                     || primary.equals(NameConstants.NT_RESOURCE)) {
@@ -1167,9 +1168,9 @@
         // Build a copy of the external change log, consisting of shared
         // states we have in our cache. Inform listeners about this
         // change.
-        Iterator modifiedStates = external.modifiedStates();
+        Iterator<ItemState> modifiedStates = external.modifiedStates();
         while (modifiedStates.hasNext()) {
-            ItemState state = (ItemState) modifiedStates.next();
+            ItemState state = modifiedStates.next();
             state = cache.retrieve(state.getId());
             if (state != null) {
                 try {
@@ -1189,9 +1190,9 @@
                 }
             }
         }
-        Iterator deletedStates = external.deletedStates();
+        Iterator<ItemState> deletedStates = external.deletedStates();
         while (deletedStates.hasNext()) {
-            ItemState state = (ItemState) deletedStates.next();
+            ItemState state = deletedStates.next();
             state = cache.retrieve(state.getId());
             if (state != null) {
                 shared.deleted(state);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/StateChangeDispatcher.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/StateChangeDispatcher.java?rev=785540&r1=785539&r2=785540&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/StateChangeDispatcher.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/StateChangeDispatcher.java Wed Jun 17 10:24:59 2009
@@ -23,7 +23,6 @@
 import java.lang.ref.Reference;
 import java.lang.ref.WeakReference;
 import java.util.Collection;
-import java.util.Iterator;
 
 /**
  * Component that holds references to listeners interested in changes to item
@@ -35,13 +34,13 @@
      * Simple item state listeners.
      * A copy on write array list is used so that no synchronization is required.
      */
-    private final Collection listeners = new CopyOnWriteArrayList();
+    private final Collection<WeakReference<ItemStateListener>> listeners = new CopyOnWriteArrayList();
 
     /**
      * Node state listeners
      * A copy on write array list is used so that no synchronization is required.
      */
-    private final transient Collection nsListeners = new CopyOnWriteArrayList();
+    private final transient Collection<WeakReference<NodeStateListener>> nsListeners = new CopyOnWriteArrayList();
 
     /**
      * Add an <code>ItemStateListener</code>.
@@ -49,18 +48,17 @@
      */
     public void addListener(ItemStateListener listener) {
         assert getReference(listeners, listener) == null;
-        listeners.add(new WeakReference(listener));
+        listeners.add(new WeakReference<ItemStateListener>(listener));
 
         if (listener instanceof NodeStateListener) {
-            assert getReference(nsListeners, listener) == null;
-            nsListeners.add(new WeakReference(listener));
+            NodeStateListener nsListener = (NodeStateListener) listener;
+            assert getReference(nsListeners, nsListener) == null;
+            nsListeners.add(new WeakReference<NodeStateListener>(nsListener));
         }
     }
-    
-    private Reference getReference(Collection coll, ItemStateListener listener) {
-        Iterator iter = coll.iterator();
-        while (iter.hasNext()) {
-            Reference ref = (Reference) iter.next();
+
+    private <T> Reference<T> getReference(Collection< ? extends Reference<T>> coll, ItemStateListener listener) {
+        for (Reference<T> ref : coll) {
             Object o = ref.get();
             if (o == listener) {
                 return ref;
@@ -88,10 +86,8 @@
      * @param created created state.
      */
     public void notifyStateCreated(ItemState created) {
-        Iterator iter = listeners.iterator();
-        while (iter.hasNext()) {
-            Reference ref = (Reference) iter.next();
-            ItemStateListener l = (ItemStateListener) ref.get();
+        for (Reference<ItemStateListener> ref : listeners) {
+            ItemStateListener l = ref.get();
             if (l != null) {
                 l.stateCreated(created);
             }
@@ -103,10 +99,8 @@
      * @param modified modified state.
      */
     public void notifyStateModified(ItemState modified) {
-        Iterator iter = listeners.iterator();
-        while (iter.hasNext()) {
-            Reference ref = (Reference) iter.next();
-            ItemStateListener l = (ItemStateListener) ref.get();
+        for (Reference<ItemStateListener> ref : listeners) {
+            ItemStateListener l = ref.get();
             if (l != null) {
                 l.stateModified(modified);
             }
@@ -118,13 +112,11 @@
      * @param destroyed destroyed state.
      */
     public void notifyStateDestroyed(ItemState destroyed) {
-        Iterator iter = listeners.iterator();
-        while (iter.hasNext()) {
-            Reference ref = (Reference) iter.next();
-            ItemStateListener l = (ItemStateListener) ref.get();
+        for (Reference<ItemStateListener> ref : listeners) {
+            ItemStateListener l = ref.get();
             if (l != null) {
                 l.stateDestroyed(destroyed);
-            }            
+            }
         }
     }
 
@@ -133,13 +125,11 @@
      * @param discarded discarded state.
      */
     public void notifyStateDiscarded(ItemState discarded) {
-        Iterator iter = listeners.iterator();
-        while (iter.hasNext()) {
-            Reference ref = (Reference) iter.next();
-            ItemStateListener l = (ItemStateListener) ref.get();
+        for (Reference<ItemStateListener> ref : listeners) {
+            ItemStateListener l = ref.get();
             if (l != null) {
                 l.stateDiscarded(discarded);
-            }               
+            }
         }
     }
 
@@ -151,13 +141,11 @@
      * @param id    id of new node
      */
     public void notifyNodeAdded(NodeState state, Name name, int index, NodeId id) {
-        Iterator iter = nsListeners.iterator();
-        while (iter.hasNext()) {
-            Reference ref = (Reference) iter.next();
-            NodeStateListener n = (NodeStateListener) ref.get();
+        for (Reference<NodeStateListener> ref : nsListeners) {
+            NodeStateListener n = ref.get();
             if (n != null) {
                 n.nodeAdded(state, name, index, id);
-            }                 
+            }
         }
     }
 
@@ -166,13 +154,11 @@
      * @param state node state that changed
      */
     public void notifyNodesReplaced(NodeState state) {
-        Iterator iter = nsListeners.iterator();
-        while (iter.hasNext()) {
-            Reference ref = (Reference) iter.next();
-            NodeStateListener n = (NodeStateListener) ref.get();
+        for (Reference<NodeStateListener> ref : nsListeners) {
+            NodeStateListener n = ref.get();
             if (n != null) {
                 n.nodesReplaced(state);
-            }              
+            }
         }
     }
 
@@ -181,13 +167,11 @@
      * @param state node state that changed
      */
     public void notifyNodeModified(NodeState state) {
-        Iterator iter = nsListeners.iterator();
-        while (iter.hasNext()) {
-            Reference ref = (Reference) iter.next();
-            NodeStateListener n = (NodeStateListener) ref.get();
+        for (Reference<NodeStateListener> ref : nsListeners) {
+            NodeStateListener n = ref.get();
             if (n != null) {
                 n.nodeModified(state);
-            }               
+            }
         }
     }
 
@@ -199,13 +183,11 @@
      * @param id    id of new node
      */
     public void notifyNodeRemoved(NodeState state, Name name, int index, NodeId id) {
-        Iterator iter = nsListeners.iterator();
-        while (iter.hasNext()) {
-            Reference ref = (Reference) iter.next();
-            NodeStateListener n = (NodeStateListener) ref.get();
+        for (Reference<NodeStateListener> ref : nsListeners) {
+            NodeStateListener n = ref.get();
             if (n != null) {
                 n.nodeRemoved(state, name, index, id);
-            }               
+            }
         }
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/ClonedInputSource.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/ClonedInputSource.java?rev=785540&r1=785539&r2=785540&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/ClonedInputSource.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/xml/ClonedInputSource.java Wed Jun 17 10:24:59 2009
@@ -34,12 +34,12 @@
  * {@link #cloneInputSource()} method.
  */
 public class ClonedInputSource extends InputSource {
-    private final char characterArray[];
-    private final byte byteArray[];
+    private final char[] characterArray;
+    private final byte[] byteArray;
 
     /**
      * Clone existing input source.
-     * 
+     *
      * @param input
      * @throws RepositoryException
      */
@@ -64,7 +64,7 @@
         }
     }
 
-    private ClonedInputSource(char characterArray[], byte byteArray[]) {
+    private ClonedInputSource(char[] characterArray, byte[] byteArray) {
         super();
         this.characterArray = characterArray;
         this.byteArray = byteArray;
@@ -81,7 +81,7 @@
     /**
      * Make a clone if this input source. The input source being cloned is still
      * valid after cloning.
-     * 
+     *
      * @return input source clone.
      */
     public ClonedInputSource cloneInputSource() {
@@ -108,7 +108,7 @@
                 final int bufferSize = Math.min(stream.available(), 4096);
                 ByteArrayOutputStream s = new ByteArrayOutputStream(bufferSize);
 
-                byte buffer[] = new byte[bufferSize];
+                byte[] buffer = new byte[bufferSize];
                 while (true) {
                     int numRead = stream.read(buffer);
                     if (numRead > 0) {
@@ -140,7 +140,7 @@
                 final int bufferSize = 4096;
                 CharArrayWriter w = new CharArrayWriter(bufferSize);
 
-                char buffer[] = new char[bufferSize];
+                char[] buffer = new char[bufferSize];
                 while (true) {
                     int numRead = reader.read(buffer);
                     if (numRead > 0) {



Mime
View raw message