db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1838913 - in /db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque: TorqueInstance.java dsfactory/JndiDataSourceFactory.java map/DatabaseMap.java map/TableMap.java oid/IDBroker.java util/BasePeerImpl.java
Date Fri, 24 Aug 2018 17:35:46 GMT
Author: tv
Date: Fri Aug 24 17:35:45 2018
New Revision: 1838913

URL: http://svn.apache.org/viewvc?rev=1838913&view=rev
Log:
Practice Java 8

Modified:
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/TorqueInstance.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/dsfactory/JndiDataSourceFactory.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/map/DatabaseMap.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/map/TableMap.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/oid/IDBroker.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeerImpl.java

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/TorqueInstance.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/TorqueInstance.java?rev=1838913&r1=1838912&r2=1838913&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/TorqueInstance.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/TorqueInstance.java
Fri Aug 24 17:35:45 2018
@@ -852,24 +852,13 @@ public class TorqueInstance
     public synchronized void shutdown()
         throws TorqueException
     {
-        for (IDBroker idBroker : idBrokers)
-        {
-            idBroker.stop();
-            // do not remove idbrokers because they will not be
-            // re-registered on a new startup.
-        }
+        // do not remove idbrokers because they will not be
+        // re-registered on a new startup.
+        idBrokers.forEach(IDBroker::stop);
 
         // shut down the cache managers
-        for (Iterator<Map.Entry<String, AbstractBaseManager<?>>> it
-                = managers.entrySet().iterator(); it.hasNext();)
-        {
-            Map.Entry<String, AbstractBaseManager<?>> mentry
-                    = it.next();
-
-            AbstractBaseManager<?> manager = mentry.getValue();
-            manager.dispose();
-            it.remove();
-        }
+        managers.values().forEach(AbstractBaseManager<?>::dispose);
+        managers.clear();
 
         // shut down the data source factories
         TorqueException exception = null;

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/dsfactory/JndiDataSourceFactory.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/dsfactory/JndiDataSourceFactory.java?rev=1838913&r1=1838912&r2=1838913&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/dsfactory/JndiDataSourceFactory.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/dsfactory/JndiDataSourceFactory.java
Fri Aug 24 17:35:45 2018
@@ -275,13 +275,8 @@ public class JndiDataSourceFactory
     {
         log.debug("InitialContext -------------------------------");
         Map<?, ?> env = ctx.getEnvironment();
-        Iterator<?> qw = env.entrySet().iterator();
         log.debug("Environment properties:" + env.size());
-        while (qw.hasNext())
-        {
-            Map.Entry<?, ?> entry = (Map.Entry<?, ?>) qw.next();
-            log.debug("    " + entry.getKey() + ": " + entry.getValue());
-        }
+        env.forEach((key, value) -> log.debug("    " + key + ": " + value));
         log.debug("----------------------------------------------");
     }
 

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/map/DatabaseMap.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/map/DatabaseMap.java?rev=1838913&r1=1838912&r2=1838913&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/map/DatabaseMap.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/map/DatabaseMap.java
Fri Aug 24 17:35:45 2018
@@ -374,11 +374,10 @@ public class DatabaseMap extends OptionS
     public void copyFrom(final DatabaseMap databaseMap)
     {
         this.isInitialized = databaseMap.isInitialized;
+
         this.clearOptions();
-        for (Map.Entry<String, String> option : databaseMap.getOptions().entrySet())
-        {
-            this.setOption(option.getKey(), option.getValue());
-        }
+        databaseMap.getOptions().forEach((key, value) -> this.setOption(key, value));
+
         this.tables.clear();
         this.tables.putAll(databaseMap.tables);
     }

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/map/TableMap.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/map/TableMap.java?rev=1838913&r1=1838912&r2=1838913&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/map/TableMap.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/map/TableMap.java
Fri Aug 24 17:35:45 2018
@@ -637,13 +637,13 @@ public class TableMap extends OptionSupp
     {
         Set<ColumnMap> result = new HashSet<ColumnMap>();
 
-        for (ColumnMap column : columns.values())
+        columns.values().forEach(column ->
         {
             if (column.isPrimaryKey())
             {
                 result.add(column);
             }
-        }
+        });
         if (result.isEmpty())
         {
             throw new TorqueException("getPrimaryKey(): Table " + tableName

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/oid/IDBroker.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/oid/IDBroker.java?rev=1838913&r1=1838912&r2=1838913&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/oid/IDBroker.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/oid/IDBroker.java
Fri Aug 24 17:35:45 2018
@@ -28,7 +28,6 @@ import java.sql.Statement;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.ListIterator;
-import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
@@ -544,15 +543,13 @@ public class IDBroker implements Runnabl
             }
 
             // logger.info("IDBroker thread checking for more keys.");
-            for (Map.Entry<String, List<BigDecimal>> id_entry : ids.entrySet())
+            ids.forEach((tableName, availableIds) ->
             {
-                String tableName = id_entry.getKey();
                 if (log.isDebugEnabled())
                 {
                     log.debug("IDBroker thread checking for more keys "
                             + "on table: " + tableName);
                 }
-                List<BigDecimal> availableIds = id_entry.getValue();
                 int quantity = getQuantity(tableName, null).intValue();
                 if (quantity > availableIds.size())
                 {
@@ -574,7 +571,7 @@ public class IDBroker implements Runnabl
                                      + "for table: " + tableName, exc);
                     }
                 }
-            }
+            });
         }
         log.debug("IDBroker thread finished.");
         threadRunning = false;

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeerImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeerImpl.java?rev=1838913&r1=1838912&r2=1838913&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeerImpl.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeerImpl.java
Fri Aug 24 17:35:45 2018
@@ -419,12 +419,7 @@ public class BasePeerImpl<T> implements
         }
 
         List<String> columnNames = new ArrayList<String>();
-        for (Map.Entry<Column, JdbcTypedValue> columnValue
-                : insertValues.entrySet())
-        {
-            Column column = columnValue.getKey();
-            columnNames.add(column.getColumnName());
-        }
+        insertValues.keySet().forEach((column) -> columnNames.add(column.getColumnName()));
 
         String fullTableName = SqlBuilder.getFullTableName(
                 getTableMap().getFullyQualifiedTableName(),



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message