jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r772909 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: ./ config/ persistence/bundle/util/ state/ value/
Date Fri, 08 May 2009 10:07:00 GMT
Author: thomasm
Date: Fri May  8 10:07:00 2009
New Revision: 772909

URL: http://svn.apache.org/viewvc?rev=772909&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/SessionImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfig.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ConnectionFactory.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ConnectionRecoveryManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/CacheManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInDataStore.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInMemory.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java?rev=772909&r1=772908&r2=772909&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
Fri May  8 10:07:00 2009
@@ -676,7 +676,7 @@
      * @throws RepositoryException
      */
     public GarbageCollector createDataStoreGarbageCollector() throws RepositoryException
{
-        ArrayList pmList = new ArrayList();
+        ArrayList<PersistenceManager> pmList = new ArrayList<PersistenceManager>();
         VersionManagerImpl vm = (VersionManagerImpl) rep.getVersionManager();
         PersistenceManager pm = vm.getPersistenceManager();
         pmList.add(pm);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfig.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfig.java?rev=772909&r1=772908&r2=772909&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfig.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfig.java
Fri May  8 10:07:00 2009
@@ -155,7 +155,7 @@
     /**
      * map of workspace names and workspace configurations
      */
-    private Map workspaces;
+    private Map<String, WorkspaceConfig> workspaces;
 
     /**
      * Repository home directory.
@@ -260,7 +260,7 @@
             ClusterConfig cc, DataStoreFactory dsf,
             RepositoryLockMechanismFactory rlf,
             RepositoryConfigurationParser parser) {
-        workspaces = new HashMap();
+        workspaces = new HashMap<String, WorkspaceConfig>();
         this.home = home;
         this.sec = sec;
         this.fsf = fsf;
@@ -309,9 +309,9 @@
                         fs.createFolder(workspaceConfigDirectory);
                     } else {
                         String[] dirNames = fs.listFolders(workspaceConfigDirectory);
-                        for (int i = 0; i < dirNames.length; i++) {
+                        for (String dir : dirNames) {
                             String configDir = workspaceConfigDirectory
-                            + FileSystem.SEPARATOR + dirNames[i];
+                            + FileSystem.SEPARATOR + dir;
                             WorkspaceConfig wc = loadWorkspaceConfig(fs, configDir);
                             if (wc != null) {
                                 addWorkspaceConfig(wc);
@@ -336,8 +336,8 @@
                         "Invalid workspace root directory: " + workspaceDirectory);
             }
 
-            for (int i = 0; i < files.length; i++) {
-                WorkspaceConfig wc = loadWorkspaceConfig(files[i]);
+            for (File file: files) {
+                WorkspaceConfig wc = loadWorkspaceConfig(file);
                 if (wc != null) {
                     addWorkspaceConfig(wc);
                 }
@@ -744,7 +744,7 @@
      *
      * @return workspace configurations
      */
-    public Collection getWorkspaceConfigs() {
+    public Collection<WorkspaceConfig> getWorkspaceConfigs() {
         return workspaces.values();
     }
 
@@ -756,7 +756,7 @@
      *         workspace does not exist
      */
     public WorkspaceConfig getWorkspaceConfig(String name) {
-        return (WorkspaceConfig) workspaces.get(name);
+        return workspaces.get(name);
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ConnectionFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ConnectionFactory.java?rev=772909&r1=772908&r2=772909&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ConnectionFactory.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ConnectionFactory.java
Fri May  8 10:07:00 2009
@@ -58,7 +58,7 @@
             SQLException {
         if (driver != null && driver.length() > 0) {
             try {
-                Class d = Class.forName(driver);
+                Class< ? > d = Class.forName(driver);
                 if (javax.naming.Context.class.isAssignableFrom(d)) {
                     // JNDI context
                     Context context = (Context) d.newInstance();

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ConnectionRecoveryManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ConnectionRecoveryManager.java?rev=772909&r1=772908&r2=772909&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ConnectionRecoveryManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ConnectionRecoveryManager.java
Fri May  8 10:07:00 2009
@@ -103,9 +103,9 @@
     public static final int TRIALS = 20;
 
     /**
-     * The map of prepared statements (key: SQL stmt, value: prepared stmt).
+     * The map of prepared statements
      */
-    private HashMap preparedStatements = new HashMap();
+    private HashMap<String, PreparedStatement> preparedStatements = new HashMap<String,
PreparedStatement>();
 
     /**
      * Indicates whether the managed connection is open or closed.
@@ -211,7 +211,7 @@
     private ResultSet executeQueryInternal(String sql) throws SQLException, RepositoryException
{
         PreparedStatement stmt = null;
         try {
-            stmt = (PreparedStatement) preparedStatements.get(sql);
+            stmt = preparedStatements.get(sql);
             if (stmt == null) {
                 stmt = getConnection().prepareStatement(sql);
                 preparedStatements.put(sql, stmt);
@@ -285,7 +285,7 @@
             if (returnGeneratedKeys) {
                 key += " RETURN_GENERATED_KEYS";
             }
-            PreparedStatement stmt = (PreparedStatement) preparedStatements.get(key);
+            PreparedStatement stmt = preparedStatements.get(key);
             if (stmt == null) {
                 if (returnGeneratedKeys) {
                     stmt = getConnection().prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/CacheManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/CacheManager.java?rev=772909&r1=772908&r2=772909&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/CacheManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/CacheManager.java
Fri May  8 10:07:00 2009
@@ -17,7 +17,6 @@
 package org.apache.jackrabbit.core.state;
 
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.WeakHashMap;
 
 import org.slf4j.Logger;
@@ -51,7 +50,7 @@
     private static final long DEFAULT_MAX_MEMORY_PER_CACHE = 4 * 1024 * 1024;
 
     /** The set of caches (weakly referenced). */
-    private WeakHashMap caches = new WeakHashMap();
+    private WeakHashMap<Cache, Object> caches = new WeakHashMap<Cache, Object>();
 
     /** The default minimum resize interval (in ms). */
     private static final int DEFAULT_MIN_RESIZE_INTERVAL = 1000;
@@ -139,10 +138,10 @@
         // entries in a weak hash map may disappear any time
         // so can't use size() / keySet() directly
         // only using the iterator guarantees that we don't get null references
-        ArrayList list = new ArrayList();
+        ArrayList<Cache> list = new ArrayList<Cache>();
         synchronized (caches) {
-            for (Iterator it = caches.keySet().iterator(); it.hasNext();) {
-                list.add(it.next());
+            for (Cache c: caches.keySet()) {
+                list.add(c);
             }
         }
         if (list.size() == 0) {
@@ -156,9 +155,9 @@
         // calculate the total access count and memory used
         long totalAccessCount = 0;
         long totalMemoryUsed = 0;
-        for (int i = 0; i < infos.length; i++) {
-            totalAccessCount += infos[i].getAccessCount();
-            totalMemoryUsed += infos[i].getMemoryUsed();
+        for (CacheInfo info : infos) {
+            totalAccessCount += info.getAccessCount();
+            totalMemoryUsed += info.getMemoryUsed();
         }
         // try to distribute the memory based on the access count
         // and memory used (higher numbers - more memory)
@@ -170,8 +169,7 @@
         double memoryPerUsed = (double) maxMemory / 2.
                 / Math.max(1., (double) totalMemoryUsed);
         int fullCacheCount = 0;
-        for (int i = 0; i < infos.length; i++) {
-            CacheInfo info = infos[i];
+        for (CacheInfo info : infos) {
             long mem = (long) (memoryPerAccess * info.getAccessCount());
             mem += (long) (memoryPerUsed * info.getMemoryUsed());
             mem = Math.min(mem, maxMemoryPerCache);
@@ -186,13 +184,12 @@
         }
         // calculate the unused memory
         long unusedMemory = maxMemory;
-        for (int i = 0; i < infos.length; i++) {
-            unusedMemory -= infos[i].getMemory();
+        for (CacheInfo info : infos) {
+            unusedMemory -= info.getMemory();
         }
         // distribute the remaining memory evenly across the full caches
         if (unusedMemory > 0 && fullCacheCount > 0) {
-            for (int i = 0; i < infos.length; i++) {
-                CacheInfo info = infos[i];
+            for (CacheInfo info : infos) {
                 if (info.wasFull()) {
                     info.setMemory(info.getMemory() + unusedMemory
                             / fullCacheCount);
@@ -200,8 +197,7 @@
             }
         }
         // set the new limit
-        for (int i = 0; i < infos.length; i++) {
-            CacheInfo info = infos[i];
+        for (CacheInfo info : infos) {
             Cache cache = info.getCache();
             if (log.isDebugEnabled()) {
                 log.debug(cache + " now:" + cache.getMaxMemorySize() + " used:"

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInDataStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInDataStore.java?rev=772909&r1=772908&r2=772909&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInDataStore.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInDataStore.java
Fri May  8 10:07:00 2009
@@ -104,14 +104,8 @@
         return getDataRecord().getStream();
     }
 
-    /**
-     * {@inheritDoc}
-     */
     public String toString() {
-        StringBuffer buff = new StringBuffer(20);
-        buff.append(PREFIX);
-        buff.append(identifier.toString());
-        return buff.toString();
+        return PREFIX + identifier;
     }
 
     static BLOBInDataStore getInstance(DataStore store, String s) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInMemory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInMemory.java?rev=772909&r1=772908&r2=772909&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInMemory.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInMemory.java
Fri May  8 10:07:00 2009
@@ -171,7 +171,7 @@
      * {@inheritDoc}
      */
     public String toString() {
-        StringBuffer buff = new StringBuffer(PREFIX.length() + 2 * data.length);
+        StringBuilder buff = new StringBuilder(PREFIX.length() + 2 * data.length);
         buff.append(PREFIX);
         char[] hex = Constants.hexDigits;
         for (int i = 0; i < data.length; i++) {



Mime
View raw message