aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/data
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/vaadin/data')
-rw-r--r--src/com/vaadin/data/util/MethodProperty.java9
-rw-r--r--src/com/vaadin/data/util/MethodPropertyDescriptor.java12
-rw-r--r--src/com/vaadin/data/util/sqlcontainer/SQLContainer.java129
-rw-r--r--src/com/vaadin/data/util/sqlcontainer/connection/J2EEConnectionPool.java5
-rw-r--r--src/com/vaadin/data/util/sqlcontainer/query/TableQuery.java29
5 files changed, 112 insertions, 72 deletions
diff --git a/src/com/vaadin/data/util/MethodProperty.java b/src/com/vaadin/data/util/MethodProperty.java
index 4fc5531320..7df45e04ab 100644
--- a/src/com/vaadin/data/util/MethodProperty.java
+++ b/src/com/vaadin/data/util/MethodProperty.java
@@ -48,8 +48,6 @@ import com.vaadin.util.SerializerHelper;
@SuppressWarnings("serial")
public class MethodProperty<T> extends AbstractProperty<T> {
- private static final Logger logger = Logger.getLogger(MethodProperty.class
- .getName());
/**
* The object that includes the property the MethodProperty is bound to.
*/
@@ -130,9 +128,9 @@ public class MethodProperty<T> extends AbstractProperty<T> {
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);
}
};
@@ -777,4 +775,7 @@ public class MethodProperty<T> extends AbstractProperty<T> {
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 10faa7a0f3..5fdb982b9e 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,7 @@ 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 3bf33defd5..e9b5b4fea3 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 */
@@ -132,6 +129,7 @@ public class SQLContainer implements Container, Container.Filterable,
*
* {@inheritDoc}
*/
+
public Object addItem() throws UnsupportedOperationException {
Object emptyKey[] = new Object[delegate.getPrimaryKeyColumns().size()];
RowId itemId = new TemporaryRowId(emptyKey);
@@ -162,15 +160,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;
@@ -187,6 +185,7 @@ public class SQLContainer implements Container, Container.Filterable,
*
* @see com.vaadin.data.Container#containsId(java.lang.Object)
*/
+
public boolean containsId(Object itemId) {
if (itemId == null) {
return false;
@@ -215,7 +214,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;
@@ -227,6 +226,7 @@ public class SQLContainer implements Container, Container.Filterable,
* @see com.vaadin.data.Container#getContainerProperty(java.lang.Object,
* java.lang.Object)
*/
+
public Property<?> getContainerProperty(Object itemId, Object propertyId) {
Item item = getItem(itemId);
if (item == null) {
@@ -240,6 +240,7 @@ public class SQLContainer implements Container, Container.Filterable,
*
* @see com.vaadin.data.Container#getContainerPropertyIds()
*/
+
public Collection<?> getContainerPropertyIds() {
return Collections.unmodifiableCollection(propertyIds);
}
@@ -249,6 +250,7 @@ public class SQLContainer implements Container, Container.Filterable,
*
* @see com.vaadin.data.Container#getItem(java.lang.Object)
*/
+
public Item getItem(Object itemId) {
if (!cachedItems.containsKey(itemId)) {
int index = indexOfId(itemId);
@@ -295,6 +297,7 @@ public class SQLContainer implements Container, Container.Filterable,
*
* {@inheritDoc}
*/
+
public Collection<?> getItemIds() {
updateCount();
ArrayList<RowId> ids = new ArrayList<RowId>();
@@ -325,17 +328,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);
}
@@ -350,6 +354,7 @@ public class SQLContainer implements Container, Container.Filterable,
*
* @see com.vaadin.data.Container#getType(java.lang.Object)
*/
+
public Class<?> getType(Object propertyId) {
if (!propertyIds.contains(propertyId)) {
return null;
@@ -362,6 +367,7 @@ public class SQLContainer implements Container, Container.Filterable,
*
* @see com.vaadin.data.Container#size()
*/
+
public int size() {
updateCount();
return size + sizeOfAddedItems() - removedItems.size();
@@ -372,6 +378,7 @@ public class SQLContainer implements Container, Container.Filterable,
*
* @see com.vaadin.data.Container#removeItem(java.lang.Object)
*/
+
public boolean removeItem(Object itemId)
throws UnsupportedOperationException {
if (!containsId(itemId)) {
@@ -400,29 +407,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;
}
@@ -439,6 +446,7 @@ public class SQLContainer implements Container, Container.Filterable,
*
* @see com.vaadin.data.Container#removeAllItems()
*/
+
public boolean removeAllItems() throws UnsupportedOperationException {
if (autoCommit) {
/* Remove and commit instantly. */
@@ -452,7 +460,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 +470,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;
}
@@ -499,6 +507,7 @@ public class SQLContainer implements Container, Container.Filterable,
/**
* {@inheritDoc}
*/
+
public void addContainerFilter(Filter filter)
throws UnsupportedFilterException {
// filter.setCaseSensitive(!ignoreCase);
@@ -510,6 +519,7 @@ public class SQLContainer implements Container, Container.Filterable,
/**
* {@inheritDoc}
*/
+
public void removeContainerFilter(Filter filter) {
filters.remove(filter);
}
@@ -549,6 +559,7 @@ public class SQLContainer implements Container, Container.Filterable,
/**
* {@inheritDoc}
*/
+
public void removeAllContainerFilters() {
filters.clear();
refresh();
@@ -563,6 +574,7 @@ public class SQLContainer implements Container, Container.Filterable,
*
* @see com.vaadin.data.Container.Indexed#indexOfId(java.lang.Object)
*/
+
public int indexOfId(Object itemId) {
// First check if the id is in the added items
for (int ix = 0; ix < addedItems.size(); ix++) {
@@ -609,6 +621,7 @@ public class SQLContainer implements Container, Container.Filterable,
*
* @see com.vaadin.data.Container.Indexed#getIdByIndex(int)
*/
+
public Object getIdByIndex(int index) {
if (index < 0 || index > size() - 1) {
return null;
@@ -635,6 +648,7 @@ public class SQLContainer implements Container, Container.Filterable,
*
* @see com.vaadin.data.Container.Ordered#nextItemId(java.lang.Object)
*/
+
public Object nextItemId(Object itemId) {
return getIdByIndex(indexOfId(itemId) + 1);
}
@@ -644,6 +658,7 @@ public class SQLContainer implements Container, Container.Filterable,
*
* @see com.vaadin.data.Container.Ordered#prevItemId(java.lang.Object)
*/
+
public Object prevItemId(Object itemId) {
return getIdByIndex(indexOfId(itemId) - 1);
}
@@ -653,6 +668,7 @@ public class SQLContainer implements Container, Container.Filterable,
*
* @see com.vaadin.data.Container.Ordered#firstItemId()
*/
+
public Object firstItemId() {
updateCount();
if (size == 0) {
@@ -680,6 +696,7 @@ public class SQLContainer implements Container, Container.Filterable,
*
* @see com.vaadin.data.Container.Ordered#lastItemId()
*/
+
public Object lastItemId() {
if (addedItems.isEmpty()) {
int lastIx = size() - 1;
@@ -705,6 +722,7 @@ public class SQLContainer implements Container, Container.Filterable,
*
* @see com.vaadin.data.Container.Ordered#isFirstId(java.lang.Object)
*/
+
public boolean isFirstId(Object itemId) {
return firstItemId().equals(itemId);
}
@@ -714,6 +732,7 @@ public class SQLContainer implements Container, Container.Filterable,
*
* @see com.vaadin.data.Container.Ordered#isLastId(java.lang.Object)
*/
+
public boolean isLastId(Object itemId) {
return lastItemId().equals(itemId);
}
@@ -728,6 +747,7 @@ public class SQLContainer implements Container, Container.Filterable,
* @see com.vaadin.data.Container.Sortable#sort(java.lang.Object[],
* boolean[])
*/
+
public void sort(Object[] propertyId, boolean[] ascending) {
sorters.clear();
if (propertyId == null || propertyId.length == 0) {
@@ -743,7 +763,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));
}
@@ -756,6 +776,7 @@ public class SQLContainer implements Container, Container.Filterable,
*
* @see com.vaadin.data.Container.Sortable#getSortableContainerPropertyIds()
*/
+
public Collection<?> getSortableContainerPropertyIds() {
return getContainerPropertyIds();
}
@@ -872,7 +893,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 +948,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 +978,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 +1031,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 +1047,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 +1092,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 +1118,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 +1135,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 +1158,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 +1240,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 +1260,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);
}
@@ -1324,6 +1350,7 @@ public class SQLContainer implements Container, Container.Filterable,
* @see com.vaadin.data.Container#addContainerProperty(java.lang.Object,
* java.lang.Class, java.lang.Object)
*/
+
public boolean addContainerProperty(Object propertyId, Class<?> type,
Object defaultValue) throws UnsupportedOperationException {
throw new UnsupportedOperationException();
@@ -1334,6 +1361,7 @@ public class SQLContainer implements Container, Container.Filterable,
*
* @see com.vaadin.data.Container#removeContainerProperty(java.lang.Object)
*/
+
public boolean removeContainerProperty(Object propertyId)
throws UnsupportedOperationException {
throw new UnsupportedOperationException();
@@ -1344,6 +1372,7 @@ public class SQLContainer implements Container, Container.Filterable,
*
* @see com.vaadin.data.Container#addItem(java.lang.Object)
*/
+
public Item addItem(Object itemId) throws UnsupportedOperationException {
throw new UnsupportedOperationException();
}
@@ -1354,6 +1383,7 @@ public class SQLContainer implements Container, Container.Filterable,
* @see com.vaadin.data.Container.Ordered#addItemAfter(java.lang.Object,
* java.lang.Object)
*/
+
public Item addItemAfter(Object previousItemId, Object newItemId)
throws UnsupportedOperationException {
throw new UnsupportedOperationException();
@@ -1364,6 +1394,7 @@ public class SQLContainer implements Container, Container.Filterable,
*
* @see com.vaadin.data.Container.Indexed#addItemAt(int, java.lang.Object)
*/
+
public Item addItemAt(int index, Object newItemId)
throws UnsupportedOperationException {
throw new UnsupportedOperationException();
@@ -1374,6 +1405,7 @@ public class SQLContainer implements Container, Container.Filterable,
*
* @see com.vaadin.data.Container.Indexed#addItemAt(int)
*/
+
public Object addItemAt(int index) throws UnsupportedOperationException {
throw new UnsupportedOperationException();
}
@@ -1383,6 +1415,7 @@ public class SQLContainer implements Container, Container.Filterable,
*
* @see com.vaadin.data.Container.Ordered#addItemAfter(java.lang.Object)
*/
+
public Object addItemAfter(Object previousItemId)
throws UnsupportedOperationException {
throw new UnsupportedOperationException();
@@ -1399,6 +1432,7 @@ public class SQLContainer implements Container, Container.Filterable,
* com.vaadin.data.Container.ItemSetChangeNotifier#addListener(com.vaadin
* .data.Container.ItemSetChangeListener)
*/
+
public void addListener(Container.ItemSetChangeListener listener) {
if (itemSetChangeListeners == null) {
itemSetChangeListeners = new LinkedList<Container.ItemSetChangeListener>();
@@ -1413,6 +1447,7 @@ public class SQLContainer implements Container, Container.Filterable,
* com.vaadin.data.Container.ItemSetChangeNotifier#removeListener(com.vaadin
* .data.Container.ItemSetChangeListener)
*/
+
public void removeListener(Container.ItemSetChangeListener listener) {
if (itemSetChangeListeners != null) {
itemSetChangeListeners.remove(listener);
@@ -1577,7 +1612,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 +1676,7 @@ public class SQLContainer implements Container, Container.Filterable,
}
}
+ private static final Logger getLogger() {
+ return Logger.getLogger(SQLContainer.class.getName());
+ }
}
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());
+ }
}