diff options
author | Henri Sara <henri.sara@itmill.com> | 2012-06-05 07:44:15 +0000 |
---|---|---|
committer | Henri Sara <henri.sara@itmill.com> | 2012-06-05 07:44:15 +0000 |
commit | 17c14316649b191bedc5cf2c0cc58cd49ad74a03 (patch) | |
tree | a61eba97f86f378e22c53709e6d51cecec1b2950 /src/com/vaadin/data/util | |
parent | abdc1ee5c270658b9f361cace015ff27cc448a68 (diff) | |
download | vaadin-framework-17c14316649b191bedc5cf2c0cc58cd49ad74a03.tar.gz vaadin-framework-17c14316649b191bedc5cf2c0cc58cd49ad74a03.zip |
#8297 Do not use static logger instances
svn changeset:23882/svn branch:6.8
Diffstat (limited to 'src/com/vaadin/data/util')
5 files changed, 81 insertions, 71 deletions
diff --git a/src/com/vaadin/data/util/MethodProperty.java b/src/com/vaadin/data/util/MethodProperty.java index ff258d3e0f..777ce68790 100644 --- a/src/com/vaadin/data/util/MethodProperty.java +++ b/src/com/vaadin/data/util/MethodProperty.java @@ -49,8 +49,6 @@ import com.vaadin.util.SerializerHelper; @SuppressWarnings("serial") public class MethodProperty<T> extends AbstractProperty { - private static final Logger logger = Logger.getLogger(MethodProperty.class - .getName()); /** * The object that includes the property the MethodProperty is bound to. */ @@ -131,9 +129,9 @@ public class MethodProperty<T> extends AbstractProperty { getMethod = null; } } catch (SecurityException e) { - logger.log(Level.SEVERE, "Internal deserialization error", e); + getLogger().log(Level.SEVERE, "Internal deserialization error", e); } catch (NoSuchMethodException e) { - logger.log(Level.SEVERE, "Internal deserialization error", e); + getLogger().log(Level.SEVERE, "Internal deserialization error", e); } }; @@ -805,4 +803,7 @@ public class MethodProperty<T> extends AbstractProperty { super.fireValueChange(); } + private static final Logger getLogger() { + return Logger.getLogger(MethodProperty.class.getName()); + } } diff --git a/src/com/vaadin/data/util/MethodPropertyDescriptor.java b/src/com/vaadin/data/util/MethodPropertyDescriptor.java index f0c879766b..c4ec515917 100644 --- a/src/com/vaadin/data/util/MethodPropertyDescriptor.java +++ b/src/com/vaadin/data/util/MethodPropertyDescriptor.java @@ -23,9 +23,6 @@ import com.vaadin.util.SerializerHelper; public class MethodPropertyDescriptor<BT> implements VaadinPropertyDescriptor<BT> { - private static final Logger logger = Logger - .getLogger(MethodPropertyDescriptor.class.getName()); - private final String name; private Class<?> propertyType; private transient Method readMethod; @@ -109,9 +106,9 @@ public class MethodPropertyDescriptor<BT> implements readMethod = null; } } catch (SecurityException e) { - logger.log(Level.SEVERE, "Internal deserialization error", e); + getLogger().log(Level.SEVERE, "Internal deserialization error", e); } catch (NoSuchMethodException e) { - logger.log(Level.SEVERE, "Internal deserialization error", e); + getLogger().log(Level.SEVERE, "Internal deserialization error", e); } }; @@ -128,4 +125,8 @@ public class MethodPropertyDescriptor<BT> implements writeMethod); } + private static final Logger getLogger() { + return Logger.getLogger(MethodPropertyDescriptor.class.getName()); + } + }
\ No newline at end of file diff --git a/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java b/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java index 7eb67437e0..242a977614 100644 --- a/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java +++ b/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java @@ -36,9 +36,6 @@ import com.vaadin.data.util.sqlcontainer.query.generator.OracleGenerator; public class SQLContainer implements Container, Container.Filterable, Container.Indexed, Container.Sortable, Container.ItemSetChangeNotifier { - private static final Logger logger = Logger.getLogger(SQLContainer.class - .getName()); - /** Query delegate */ private QueryDelegate delegate; /** Auto commit mode, default = false */ @@ -162,15 +159,15 @@ public class SQLContainer implements Container, Container.Filterable, if (notificationsEnabled) { CacheFlushNotifier.notifyOfCacheFlush(this); } - logger.log(Level.FINER, "Row added to DB..."); + getLogger().log(Level.FINER, "Row added to DB..."); return itemId; } catch (SQLException e) { - logger.log(Level.WARNING, + getLogger().log(Level.WARNING, "Failed to add row to DB. Rolling back.", e); try { delegate.rollback(); } catch (SQLException ee) { - logger.log(Level.SEVERE, + getLogger().log(Level.SEVERE, "Failed to roll back row addition", e); } return null; @@ -215,7 +212,7 @@ public class SQLContainer implements Container, Container.Filterable, return delegate.containsRowWithKey(((RowId) itemId).getId()); } catch (Exception e) { /* Query failed, just return false. */ - logger.log(Level.WARNING, "containsId query failed", e); + getLogger().log(Level.WARNING, "containsId query failed", e); } } return false; @@ -325,17 +322,18 @@ public class SQLContainer implements Container, Container.Filterable, rs.close(); delegate.commit(); } catch (SQLException e) { - logger.log(Level.WARNING, "getItemIds() failed, rolling back.", e); + getLogger().log(Level.WARNING, + "getItemIds() failed, rolling back.", e); try { delegate.rollback(); } catch (SQLException e1) { - logger.log(Level.SEVERE, "Failed to roll back state", e1); + getLogger().log(Level.SEVERE, "Failed to roll back state", e1); } try { rs.getStatement().close(); rs.close(); } catch (SQLException e1) { - logger.log(Level.WARNING, "Closing session failed", e1); + getLogger().log(Level.WARNING, "Closing session failed", e1); } throw new RuntimeException("Failed to fetch item indexes.", e); } @@ -400,29 +398,29 @@ public class SQLContainer implements Container, Container.Filterable, CacheFlushNotifier.notifyOfCacheFlush(this); } if (success) { - logger.log(Level.FINER, "Row removed from DB..."); + getLogger().log(Level.FINER, "Row removed from DB..."); } return success; } catch (SQLException e) { - logger.log(Level.WARNING, "Failed to remove row, rolling back", - e); + getLogger().log(Level.WARNING, + "Failed to remove row, rolling back", e); try { delegate.rollback(); } catch (SQLException ee) { /* Nothing can be done here */ - logger.log(Level.SEVERE, "Failed to rollback row removal", - ee); + getLogger().log(Level.SEVERE, + "Failed to rollback row removal", ee); } return false; } catch (OptimisticLockException e) { - logger.log(Level.WARNING, "Failed to remove row, rolling back", - e); + getLogger().log(Level.WARNING, + "Failed to remove row, rolling back", e); try { delegate.rollback(); } catch (SQLException ee) { /* Nothing can be done here */ - logger.log(Level.SEVERE, "Failed to rollback row removal", - ee); + getLogger().log(Level.SEVERE, + "Failed to rollback row removal", ee); } throw e; } @@ -452,7 +450,7 @@ public class SQLContainer implements Container, Container.Filterable, } if (success) { delegate.commit(); - logger.log(Level.FINER, "All rows removed from DB..."); + getLogger().log(Level.FINER, "All rows removed from DB..."); refresh(); if (notificationsEnabled) { CacheFlushNotifier.notifyOfCacheFlush(this); @@ -462,23 +460,23 @@ public class SQLContainer implements Container, Container.Filterable, } return success; } catch (SQLException e) { - logger.log(Level.WARNING, + getLogger().log(Level.WARNING, "removeAllItems() failed, rolling back", e); try { delegate.rollback(); } catch (SQLException ee) { /* Nothing can be done here */ - logger.log(Level.SEVERE, "Failed to roll back", ee); + getLogger().log(Level.SEVERE, "Failed to roll back", ee); } return false; } catch (OptimisticLockException e) { - logger.log(Level.WARNING, + getLogger().log(Level.WARNING, "removeAllItems() failed, rolling back", e); try { delegate.rollback(); } catch (SQLException ee) { /* Nothing can be done here */ - logger.log(Level.SEVERE, "Failed to roll back", ee); + getLogger().log(Level.SEVERE, "Failed to roll back", ee); } throw e; } @@ -743,7 +741,7 @@ public class SQLContainer implements Container, Container.Filterable, try { asc = ascending[i]; } catch (Exception e) { - logger.log(Level.WARNING, "", e); + getLogger().log(Level.WARNING, "", e); } sorters.add(new OrderBy((String) propertyId[i], asc)); } @@ -872,7 +870,8 @@ public class SQLContainer implements Container, Container.Filterable, */ public void commit() throws UnsupportedOperationException, SQLException { try { - logger.log(Level.FINER, "Commiting changes through delegate..."); + getLogger().log(Level.FINER, + "Commiting changes through delegate..."); delegate.beginTransaction(); /* Perform buffered deletions */ for (RowItem item : removedItems.values()) { @@ -926,7 +925,7 @@ public class SQLContainer implements Container, Container.Filterable, * @throws SQLException */ public void rollback() throws UnsupportedOperationException, SQLException { - logger.log(Level.FINE, "Rolling back changes..."); + getLogger().log(Level.FINE, "Rolling back changes..."); removedItems.clear(); addedItems.clear(); modifiedItems.clear(); @@ -956,15 +955,15 @@ public class SQLContainer implements Container, Container.Filterable, if (notificationsEnabled) { CacheFlushNotifier.notifyOfCacheFlush(this); } - logger.log(Level.FINER, "Row updated to DB..."); + getLogger().log(Level.FINER, "Row updated to DB..."); } catch (SQLException e) { - logger.log(Level.WARNING, + getLogger().log(Level.WARNING, "itemChangeNotification failed, rolling back...", e); try { delegate.rollback(); } catch (SQLException ee) { /* Nothing can be done here */ - logger.log(Level.SEVERE, "Rollback failed", e); + getLogger().log(Level.SEVERE, "Rollback failed", e); } throw new RuntimeException(e); } @@ -1009,13 +1008,13 @@ public class SQLContainer implements Container, Container.Filterable, try { delegate.setFilters(filters); } catch (UnsupportedOperationException e) { - logger.log(Level.FINE, + getLogger().log(Level.FINE, "The query delegate doesn't support filtering", e); } try { delegate.setOrderBy(sorters); } catch (UnsupportedOperationException e) { - logger.log(Level.FINE, + getLogger().log(Level.FINE, "The query delegate doesn't support filtering", e); } int newSize = delegate.getCount(); @@ -1025,7 +1024,8 @@ public class SQLContainer implements Container, Container.Filterable, } sizeUpdated = new Date(); sizeDirty = false; - logger.log(Level.FINER, "Updated row count. New count is: " + size); + getLogger().log(Level.FINER, + "Updated row count. New count is: " + size); } catch (SQLException e) { throw new RuntimeException("Failed to update item set size.", e); } @@ -1069,7 +1069,7 @@ public class SQLContainer implements Container, Container.Filterable, try { type = Class.forName(rsmd.getColumnClassName(i)); } catch (Exception e) { - logger.log(Level.WARNING, "Class not found", e); + getLogger().log(Level.WARNING, "Class not found", e); /* On failure revert to Object and hope for the best. */ type = Object.class; } @@ -1095,14 +1095,14 @@ public class SQLContainer implements Container, Container.Filterable, rs.getStatement().close(); rs.close(); delegate.commit(); - logger.log(Level.FINER, "Property IDs fetched."); + getLogger().log(Level.FINER, "Property IDs fetched."); } catch (SQLException e) { - logger.log(Level.WARNING, + getLogger().log(Level.WARNING, "Failed to fetch property ids, rolling back", e); try { delegate.rollback(); } catch (SQLException e1) { - logger.log(Level.SEVERE, "Failed to roll back", e1); + getLogger().log(Level.SEVERE, "Failed to roll back", e1); } try { if (rs != null) { @@ -1112,7 +1112,7 @@ public class SQLContainer implements Container, Container.Filterable, rs.close(); } } catch (SQLException e1) { - logger.log(Level.WARNING, "Failed to close session", e1); + getLogger().log(Level.WARNING, "Failed to close session", e1); } throw e; } @@ -1135,7 +1135,7 @@ public class SQLContainer implements Container, Container.Filterable, } catch (UnsupportedOperationException e) { /* The query delegate doesn't support sorting. */ /* No need to do anything. */ - logger.log(Level.FINE, + getLogger().log(Level.FINE, "The query delegate doesn't support sorting", e); } delegate.beginTransaction(); @@ -1217,14 +1217,17 @@ public class SQLContainer implements Container, Container.Filterable, rs.getStatement().close(); rs.close(); delegate.commit(); - logger.log(Level.FINER, "Fetched " + pageLength * CACHE_RATIO - + " rows starting from " + currentOffset); + getLogger().log( + Level.FINER, + "Fetched " + pageLength * CACHE_RATIO + + " rows starting from " + currentOffset); } catch (SQLException e) { - logger.log(Level.WARNING, "Failed to fetch rows, rolling back", e); + getLogger().log(Level.WARNING, + "Failed to fetch rows, rolling back", e); try { delegate.rollback(); } catch (SQLException e1) { - logger.log(Level.SEVERE, "Failed to roll back", e1); + getLogger().log(Level.SEVERE, "Failed to roll back", e1); } try { if (rs != null) { @@ -1234,7 +1237,7 @@ public class SQLContainer implements Container, Container.Filterable, } } } catch (SQLException e1) { - logger.log(Level.WARNING, "Failed to close session", e1); + getLogger().log(Level.WARNING, "Failed to close session", e1); } throw new RuntimeException("Failed to fetch page.", e); } @@ -1577,7 +1580,8 @@ public class SQLContainer implements Container, Container.Filterable, r.getReferencedColumn())); return true; } catch (Exception e) { - logger.log(Level.WARNING, "Setting referenced item failed.", e); + getLogger() + .log(Level.WARNING, "Setting referenced item failed.", e); return false; } } @@ -1640,4 +1644,8 @@ public class SQLContainer implements Container, Container.Filterable, } } + private static final Logger getLogger() { + return Logger.getLogger(SQLContainer.class.getName()); + } + }
\ No newline at end of file diff --git a/src/com/vaadin/data/util/sqlcontainer/connection/J2EEConnectionPool.java b/src/com/vaadin/data/util/sqlcontainer/connection/J2EEConnectionPool.java index 9e4bb772f5..40d0d0426f 100644 --- a/src/com/vaadin/data/util/sqlcontainer/connection/J2EEConnectionPool.java +++ b/src/com/vaadin/data/util/sqlcontainer/connection/J2EEConnectionPool.java @@ -13,8 +13,6 @@ import javax.naming.NamingException; import javax.sql.DataSource; public class J2EEConnectionPool implements JDBCConnectionPool { - private static final Logger logger = Logger - .getLogger(J2EEConnectionPool.class.getName()); private String dataSourceJndiName; @@ -58,7 +56,8 @@ public class J2EEConnectionPool implements JDBCConnectionPool { try { conn.close(); } catch (SQLException e) { - logger.log(Level.FINE, "Could not release SQL connection", e); + Logger.getLogger(J2EEConnectionPool.class.getName()).log( + Level.FINE, "Could not release SQL connection", e); } } } diff --git a/src/com/vaadin/data/util/sqlcontainer/query/TableQuery.java b/src/com/vaadin/data/util/sqlcontainer/query/TableQuery.java index 7e546309f6..22ca30cc32 100644 --- a/src/com/vaadin/data/util/sqlcontainer/query/TableQuery.java +++ b/src/com/vaadin/data/util/sqlcontainer/query/TableQuery.java @@ -38,9 +38,6 @@ import com.vaadin.data.util.sqlcontainer.query.generator.StatementHelper; public class TableQuery implements QueryDelegate, QueryDelegate.RowIdChangeNotifier { - private static final Logger logger = Logger.getLogger(TableQuery.class - .getName()); - /** Table name, primary key column name(s) and version column name */ private String tableName; private List<String> primaryKeyColumns; @@ -115,7 +112,7 @@ public class TableQuery implements QueryDelegate, * @see com.vaadin.addon.sqlcontainer.query.QueryDelegate#getCount() */ public int getCount() throws SQLException { - logger.log(Level.FINE, "Fetching count..."); + getLogger().log(Level.FINE, "Fetching count..."); StatementHelper sh = sqlGenerator.generateSelectQuery(tableName, filters, null, 0, 0, "COUNT(*)"); boolean shouldCloseTransaction = false; @@ -228,7 +225,7 @@ public class TableQuery implements QueryDelegate, PreparedStatement pstmt = activeConnection.prepareStatement( sh.getQueryString(), primaryKeyColumns.toArray(new String[0])); sh.setParameterValuesToStatement(pstmt); - logger.log(Level.FINE, "DB -> " + sh.getQueryString()); + getLogger().log(Level.FINE, "DB -> " + sh.getQueryString()); int result = pstmt.executeUpdate(); if (result > 0) { /* @@ -293,7 +290,7 @@ public class TableQuery implements QueryDelegate, throw new IllegalStateException(); } - logger.log(Level.FINE, "DB -> begin transaction"); + getLogger().log(Level.FINE, "DB -> begin transaction"); activeConnection = connectionPool.reserveConnection(); activeConnection.setAutoCommit(false); transactionOpen = true; @@ -306,7 +303,7 @@ public class TableQuery implements QueryDelegate, */ public void commit() throws UnsupportedOperationException, SQLException { if (transactionOpen && activeConnection != null) { - logger.log(Level.FINE, "DB -> commit"); + getLogger().log(Level.FINE, "DB -> commit"); activeConnection.commit(); connectionPool.releaseConnection(activeConnection); } else { @@ -334,7 +331,7 @@ public class TableQuery implements QueryDelegate, */ public void rollback() throws UnsupportedOperationException, SQLException { if (transactionOpen && activeConnection != null) { - logger.log(Level.FINE, "DB -> rollback"); + getLogger().log(Level.FINE, "DB -> rollback"); activeConnection.rollback(); connectionPool.releaseConnection(activeConnection); } else { @@ -389,7 +386,7 @@ public class TableQuery implements QueryDelegate, } PreparedStatement pstmt = c.prepareStatement(sh.getQueryString()); sh.setParameterValuesToStatement(pstmt); - logger.log(Level.FINE, "DB -> " + sh.getQueryString()); + getLogger().log(Level.FINE, "DB -> " + sh.getQueryString()); return pstmt.executeQuery(); } @@ -415,7 +412,7 @@ public class TableQuery implements QueryDelegate, } pstmt = c.prepareStatement(sh.getQueryString()); sh.setParameterValuesToStatement(pstmt); - logger.log(Level.FINE, "DB -> " + sh.getQueryString()); + getLogger().log(Level.FINE, "DB -> " + sh.getQueryString()); int retval = pstmt.executeUpdate(); return retval; } finally { @@ -458,7 +455,7 @@ public class TableQuery implements QueryDelegate, pstmt = c.prepareStatement(sh.getQueryString(), primaryKeyColumns.toArray(new String[0])); sh.setParameterValuesToStatement(pstmt); - logger.log(Level.FINE, "DB -> " + sh.getQueryString()); + getLogger().log(Level.FINE, "DB -> " + sh.getQueryString()); int result = pstmt.executeUpdate(); genKeys = pstmt.getGeneratedKeys(); RowId newId = getNewRowId(row, genKeys); @@ -571,7 +568,7 @@ public class TableQuery implements QueryDelegate, } return new RowId(newRowId.toArray()); } catch (Exception e) { - logger.log(Level.FINE, + getLogger().log(Level.FINE, "Failed to fetch key values on insert: " + e.getMessage()); return null; } @@ -586,8 +583,8 @@ public class TableQuery implements QueryDelegate, */ public boolean removeRow(RowItem row) throws UnsupportedOperationException, SQLException { - logger.log(Level.FINE, "Removing row with id: " - + row.getId().getId()[0].toString()); + getLogger().log(Level.FINE, + "Removing row with id: " + row.getId().getId()[0].toString()); if (executeUpdate(sqlGenerator.generateDeleteQuery(getTableName(), primaryKeyColumns, versionColumn, row)) == 1) { return true; @@ -695,4 +692,8 @@ public class TableQuery implements QueryDelegate, rowIdChangeListeners.remove(listener); } } + + private static final Logger getLogger() { + return Logger.getLogger(TableQuery.class.getName()); + } } |