diff options
author | Johannes Dahlström <johannesd@vaadin.com> | 2012-06-12 17:05:23 +0300 |
---|---|---|
committer | Johannes Dahlström <johannesd@vaadin.com> | 2012-06-12 17:05:23 +0300 |
commit | 56a9aaba779038ebe0f32fc63259d3a5cea3e26f (patch) | |
tree | 194dea4f1c2d46dad6ad6f0383cb249325ee1586 | |
parent | 4ceccdc68f1eb3ffcb7b20e20b81877764a9c729 (diff) | |
parent | 17c14316649b191bedc5cf2c0cc58cd49ad74a03 (diff) | |
download | vaadin-framework-56a9aaba779038ebe0f32fc63259d3a5cea3e26f.tar.gz vaadin-framework-56a9aaba779038ebe0f32fc63259d3a5cea3e26f.zip |
Merge commit '17c14'
Conflicts:
src/com/vaadin/Application.java
src/com/vaadin/data/util/MethodPropertyDescriptor.java
src/com/vaadin/data/util/sqlcontainer/SQLContainer.java
src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java
src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java
src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
src/com/vaadin/terminal/gwt/server/DragAndDropService.java
src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java
src/com/vaadin/terminal/gwt/widgetsetutils/ClassPathExplorer.java
src/com/vaadin/ui/Table.java
tests/testbench/com/vaadin/launcher/ApplicationRunnerServlet.java
22 files changed, 452 insertions, 268 deletions
diff --git a/src/com/vaadin/Application.java b/src/com/vaadin/Application.java index 4da1d52c00..58ad4da684 100644 --- a/src/com/vaadin/Application.java +++ b/src/com/vaadin/Application.java @@ -1066,12 +1066,14 @@ public class Application implements Terminal.ErrorListener, Serializable { * the change event. * @see com.vaadin.terminal.Terminal.ErrorListener#terminalError(com.vaadin.terminal.Terminal.ErrorEvent) */ + @Override public void terminalError(Terminal.ErrorEvent event) { final Throwable t = event.getThrowable(); if (t instanceof SocketException) { // Most likely client browser closed socket - logger.info("SocketException in CommunicationManager." - + " Most likely client (browser) closed socket."); + getLogger().info( + "SocketException in CommunicationManager." + + " Most likely client (browser) closed socket."); return; } @@ -1090,7 +1092,7 @@ public class Application implements Terminal.ErrorListener, Serializable { } // also print the error on console - logger.log(Level.SEVERE, "Terminal error:", t); + getLogger().log(Level.SEVERE, "Terminal error:", t); } /** @@ -1809,6 +1811,7 @@ public class Application implements Terminal.ErrorListener, Serializable { this.throwable = throwable; } + @Override public Throwable getThrowable() { return throwable; } @@ -2416,4 +2419,8 @@ public class Application implements Terminal.ErrorListener, Serializable { } } + + private static final Logger getLogger() { + return Logger.getLogger(Application.class.getName()); + } } 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..a2a76ec6cf 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,23 +106,29 @@ 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); } }; + @Override public String getName() { return name; } + @Override public Class<?> getPropertyType() { return propertyType; } + @Override public Property<?> createProperty(Object bean) { return new MethodProperty<Object>(propertyType, bean, readMethod, 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..66f5737683 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} */ + @Override 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) */ + @Override 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) */ + @Override 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() */ + @Override 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) */ + @Override 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} */ + @Override 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) */ + @Override 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() */ + @Override 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) */ + @Override 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() */ + @Override 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} */ + @Override public void addContainerFilter(Filter filter) throws UnsupportedFilterException { // filter.setCaseSensitive(!ignoreCase); @@ -510,6 +519,7 @@ public class SQLContainer implements Container, Container.Filterable, /** * {@inheritDoc} */ + @Override public void removeContainerFilter(Filter filter) { filters.remove(filter); } @@ -549,6 +559,7 @@ public class SQLContainer implements Container, Container.Filterable, /** * {@inheritDoc} */ + @Override 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) */ + @Override 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) */ + @Override 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) */ + @Override 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) */ + @Override 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() */ + @Override 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() */ + @Override 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) */ + @Override 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) */ + @Override 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[]) */ + @Override 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() */ + @Override 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) */ + @Override 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) */ + @Override 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) */ + @Override 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) */ + @Override 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) */ + @Override 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) */ + @Override 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) */ + @Override 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) */ + @Override 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) */ + @Override public void removeListener(Container.ItemSetChangeListener listener) { if (itemSetChangeListeners != null) { itemSetChangeListeners.remove(listener); @@ -1442,6 +1477,7 @@ public class SQLContainer implements Container, Container.Filterable, super(source); } + @Override public Container getContainer() { return (Container) getSource(); } @@ -1577,7 +1613,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 +1677,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()); + } } diff --git a/src/com/vaadin/event/ListenerMethod.java b/src/com/vaadin/event/ListenerMethod.java index 1f1305fa69..f7dc8a7f13 100644 --- a/src/com/vaadin/event/ListenerMethod.java +++ b/src/com/vaadin/event/ListenerMethod.java @@ -43,9 +43,6 @@ import java.util.logging.Logger; @SuppressWarnings("serial") public class ListenerMethod implements EventListener, Serializable { - private static final Logger logger = Logger.getLogger(ListenerMethod.class - .getName()); - /** * Type of the event that should trigger this listener. Also the subclasses * of this class are accepted to trigger the listener. @@ -84,9 +81,10 @@ public class ListenerMethod implements EventListener, Serializable { out.writeObject(name); out.writeObject(paramTypes); } catch (NotSerializableException e) { - logger.warning("Error in serialization of the application: Class " - + target.getClass().getName() - + " must implement serialization."); + getLogger().warning( + "Error in serialization of the application: Class " + + target.getClass().getName() + + " must implement serialization."); throw e; } @@ -103,7 +101,7 @@ public class ListenerMethod implements EventListener, Serializable { // inner classes method = findHighestMethod(target.getClass(), name, paramTypes); } catch (SecurityException e) { - logger.log(Level.SEVERE, "Internal deserialization error", e); + getLogger().log(Level.SEVERE, "Internal deserialization error", e); } }; @@ -658,4 +656,8 @@ public class ListenerMethod implements EventListener, Serializable { return target; } + private static final Logger getLogger() { + return Logger.getLogger(ListenerMethod.class.getName()); + } + } diff --git a/src/com/vaadin/event/dd/acceptcriteria/SourceIs.java b/src/com/vaadin/event/dd/acceptcriteria/SourceIs.java index 0d29e9a327..62bf64f76c 100644 --- a/src/com/vaadin/event/dd/acceptcriteria/SourceIs.java +++ b/src/com/vaadin/event/dd/acceptcriteria/SourceIs.java @@ -25,8 +25,6 @@ import com.vaadin.ui.Component; @SuppressWarnings("serial") @ClientCriterion(VDragSourceIs.class) public class SourceIs extends ClientSideCriterion { - private static final Logger logger = Logger.getLogger(SourceIs.class - .getName()); private Component[] components; @@ -43,11 +41,11 @@ public class SourceIs extends ClientSideCriterion { if (c.getApplication() != null) { target.addAttribute("component" + paintedComponents++, c); } else { - logger.log( - Level.WARNING, - "SourceIs component {0} at index {1} is not attached to the component hierachy and will thus be ignored", - new Object[] { c.getClass().getName(), - Integer.valueOf(i) }); + Logger.getLogger(SourceIs.class.getName()) + .log(Level.WARNING, + "SourceIs component {0} at index {1} is not attached to the component hierachy and will thus be ignored", + new Object[] { c.getClass().getName(), + Integer.valueOf(i) }); } } target.addAttribute("c", paintedComponents); diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java index 182321e54e..b123af95bb 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java @@ -64,9 +64,6 @@ import com.vaadin.ui.Root; public abstract class AbstractApplicationPortlet extends GenericPortlet implements Constants { - private static final Logger logger = Logger - .getLogger(AbstractApplicationPortlet.class.getName()); - public static class WrappedHttpAndPortletRequest extends WrappedPortletRequest { @@ -336,7 +333,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet * Print an information/warning message about running with xsrf * protection disabled */ - logger.warning(WARNING_XSRF_PROTECTION_DISABLED); + getLogger().warning(WARNING_XSRF_PROTECTION_DISABLED); } } @@ -352,7 +349,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet if (!productionMode) { /* Print an information/warning message about running in debug mode */ // TODO Maybe we need a different message for portlets? - logger.warning(NOT_PRODUCTION_MODE_INFO); + getLogger().warning(NOT_PRODUCTION_MODE_INFO); } } @@ -672,11 +669,12 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet } catch (final SessionExpiredException e) { // TODO Figure out a better way to deal with // SessionExpiredExceptions - logger.finest("A user session has expired"); + getLogger().finest("A user session has expired"); } catch (final GeneralSecurityException e) { // TODO Figure out a better way to deal with // GeneralSecurityExceptions - logger.fine("General security exception, the security key was probably incorrect."); + getLogger() + .fine("General security exception, the security key was probably incorrect."); } catch (final Throwable e) { handleServiceException(request, response, application, e); } finally { @@ -738,7 +736,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet private void handleUnknownRequest(PortletRequest request, PortletResponse response) { - logger.warning("Unknown request type"); + getLogger().warning("Unknown request type"); } /** @@ -804,8 +802,9 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet os.write(buffer, 0, bytes); } } else { - logger.info("Requested resource [" + resourceID - + "] could not be found"); + getLogger().info( + "Requested resource [" + resourceID + + "] could not be found"); response.setProperty(ResourceResponse.HTTP_STATUS_CODE, Integer.toString(HttpServletResponse.SC_NOT_FOUND)); } @@ -1151,4 +1150,8 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet return PortletApplicationContext2.getApplicationContext(portletSession); } + private static final Logger getLogger() { + return Logger.getLogger(AbstractApplicationPortlet.class.getName()); + } + } diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java index 7f16f48cbe..86274869e9 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java @@ -88,9 +88,6 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements // TODO Move some (all?) of the constants to a separate interface (shared // with portlet) - private static final Logger logger = Logger - .getLogger(AbstractApplicationServlet.class.getName()); - private Properties applicationProperties; private boolean productionMode = false; @@ -193,7 +190,7 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements * Print an information/warning message about running with xsrf * protection disabled */ - logger.warning(WARNING_XSRF_PROTECTION_DISABLED); + getLogger().warning(WARNING_XSRF_PROTECTION_DISABLED); } } @@ -207,7 +204,7 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements if (!productionMode) { /* Print an information/warning message about running in debug mode */ - logger.warning(NOT_PRODUCTION_MODE_INFO); + getLogger().warning(NOT_PRODUCTION_MODE_INFO); } } @@ -221,7 +218,7 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements } catch (NumberFormatException nfe) { // Default is 1h resourceCacheTime = 3600; - logger.warning(WARNING_RESOURCE_CACHING_TIME_NOT_NUMERIC); + getLogger().warning(WARNING_RESOURCE_CACHING_TIME_NOT_NUMERIC); } } @@ -804,8 +801,8 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements resultPath = url.getFile(); } catch (final Exception e) { // FIXME: Handle exception - logger.log(Level.INFO, "Could not find resource path " + path, - e); + getLogger().log(Level.INFO, + "Could not find resource path " + path, e); } } return resultPath; @@ -1062,10 +1059,11 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements if (resourceUrl == null) { // cannot serve requested file - logger.info("Requested resource [" - + filename - + "] not found from filesystem or through class loader." - + " Add widgetset and/or theme JAR to your classpath or add files to WebContent/VAADIN folder."); + getLogger() + .info("Requested resource [" + + filename + + "] not found from filesystem or through class loader." + + " Add widgetset and/or theme JAR to your classpath or add files to WebContent/VAADIN folder."); response.setStatus(HttpServletResponse.SC_NOT_FOUND); return; } @@ -1073,9 +1071,10 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements // security check: do not permit navigation out of the VAADIN // directory if (!isAllowedVAADINResourceUrl(request, resourceUrl)) { - logger.info("Requested resource [" - + filename - + "] not accessible in the VAADIN directory or access to it is forbidden."); + getLogger() + .info("Requested resource [" + + filename + + "] not accessible in the VAADIN directory or access to it is forbidden."); response.setStatus(HttpServletResponse.SC_FORBIDDEN); return; } @@ -1098,10 +1097,10 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements } } catch (Exception e) { // Failed to find out last modified timestamp. Continue without it. - logger.log( - Level.FINEST, - "Failed to find out last modified timestamp. Continuing without it.", - e); + getLogger() + .log(Level.FINEST, + "Failed to find out last modified timestamp. Continuing without it.", + e); } finally { if (connection instanceof URLConnection) { try { @@ -1113,7 +1112,7 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements is.close(); } } catch (IOException e) { - logger.log(Level.INFO, + getLogger().log(Level.INFO, "Error closing URLConnection input stream", e); } } @@ -1181,12 +1180,14 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements // loader sees it. if (!resourceUrl.getPath().contains("!/VAADIN/")) { - logger.info("Blocked attempt to access a JAR entry not starting with /VAADIN/: " - + resourceUrl); + getLogger().info( + "Blocked attempt to access a JAR entry not starting with /VAADIN/: " + + resourceUrl); return false; } - logger.fine("Accepted access to a JAR entry using a class loader: " - + resourceUrl); + getLogger().fine( + "Accepted access to a JAR entry using a class loader: " + + resourceUrl); return true; } else { // Some servers such as GlassFish extract files from JARs (file:) @@ -1196,11 +1197,13 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements // "/../" if (!resourceUrl.getPath().contains("/VAADIN/") || resourceUrl.getPath().contains("/../")) { - logger.info("Blocked attempt to access file: " + resourceUrl); + getLogger().info( + "Blocked attempt to access file: " + resourceUrl); return false; } - logger.fine("Accepted access to a file using a class loader: " - + resourceUrl); + getLogger().fine( + "Accepted access to a file using a class loader: " + + resourceUrl); return true; } } @@ -1742,4 +1745,8 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements c > 96 && c < 123 // a-z ; } + + private static final Logger getLogger() { + return Logger.getLogger(AbstractApplicationServlet.class.getName()); + } } diff --git a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java index 9e3545cac5..d31e607b96 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java @@ -92,9 +92,6 @@ public abstract class AbstractCommunicationManager implements Serializable { private static final String DASHDASH = "--"; - private static final Logger logger = Logger - .getLogger(AbstractCommunicationManager.class.getName()); - private static final RequestHandler APP_RESOURCE_HANDLER = new ApplicationResourceHandler(); private static final RequestHandler UNSUPPORTED_BROWSER_HANDLER = new UnsupportedBrowserHandler(); @@ -539,7 +536,7 @@ public abstract class AbstractCommunicationManager implements Serializable { if (root == null) { // This should not happen, no windows exists but // application is still open. - logger.warning("Could not get root for application"); + getLogger().warning("Could not get root for application"); return; } } else { @@ -562,7 +559,7 @@ public abstract class AbstractCommunicationManager implements Serializable { // FIXME: Handle exception // Not critical, but something is still wrong; print // stacktrace - logger.log(Level.WARNING, + getLogger().log(Level.WARNING, "getSystemMessages() failed - continuing", e2); } if (ci != null) { @@ -604,8 +601,9 @@ public abstract class AbstractCommunicationManager implements Serializable { } if (!Version.getFullVersion().equals(widgetsetVersion)) { - logger.warning(String.format(Constants.WIDGETSET_MISMATCH_INFO, - Version.getFullVersion(), widgetsetVersion)); + getLogger().warning( + String.format(Constants.WIDGETSET_MISMATCH_INFO, + Version.getFullVersion(), widgetsetVersion)); } } @@ -638,7 +636,7 @@ public abstract class AbstractCommunicationManager implements Serializable { printHighlightedComponentHierarchy(sb, component); } - logger.info(sb.toString()); + getLogger().info(sb.toString()); } protected void printHighlightedComponentHierarchy(StringBuilder sb, @@ -767,7 +765,7 @@ public abstract class AbstractCommunicationManager implements Serializable { // Paints components DirtyConnectorTracker rootConnectorTracker = root .getDirtyConnectorTracker(); - logger.log(Level.FINE, "* Creating response to client"); + getLogger().log(Level.FINE, "* Creating response to client"); if (repaintAll) { getClientCache(root).clear(); rootConnectorTracker.markAllConnectorsDirty(); @@ -780,8 +778,10 @@ public abstract class AbstractCommunicationManager implements Serializable { dirtyVisibleConnectors .addAll(getDirtyVisibleConnectors(rootConnectorTracker)); - logger.log(Level.FINE, "Found " + dirtyVisibleConnectors.size() - + " dirty connectors to paint"); + getLogger().log( + Level.FINE, + "Found " + dirtyVisibleConnectors.size() + + " dirty connectors to paint"); for (ClientConnector connector : dirtyVisibleConnectors) { if (connector instanceof Component) { ((Component) connector).updateState(); @@ -841,7 +841,8 @@ public abstract class AbstractCommunicationManager implements Serializable { try { referenceState = stateType.newInstance(); } catch (Exception e) { - logger.log(Level.WARNING, + getLogger().log( + Level.WARNING, "Error creating reference object for state of type " + stateType.getName()); } @@ -1006,16 +1007,16 @@ public abstract class AbstractCommunicationManager implements Serializable { (Class[]) null); ci = (Application.SystemMessages) m.invoke(null, (Object[]) null); } catch (NoSuchMethodException e) { - logger.log(Level.WARNING, + getLogger().log(Level.WARNING, "getSystemMessages() failed - continuing", e); } catch (IllegalArgumentException e) { - logger.log(Level.WARNING, + getLogger().log(Level.WARNING, "getSystemMessages() failed - continuing", e); } catch (IllegalAccessException e) { - logger.log(Level.WARNING, + getLogger().log(Level.WARNING, "getSystemMessages() failed - continuing", e); } catch (InvocationTargetException e) { - logger.log(Level.WARNING, + getLogger().log(Level.WARNING, "getSystemMessages() failed - continuing", e); } @@ -1054,8 +1055,8 @@ public abstract class AbstractCommunicationManager implements Serializable { is = getThemeResourceAsStream(root, getTheme(root), resource); } catch (final Exception e) { // FIXME: Handle exception - logger.log(Level.FINER, "Failed to get theme resource stream.", - e); + getLogger().log(Level.FINER, + "Failed to get theme resource stream.", e); } if (is != null) { @@ -1074,13 +1075,13 @@ public abstract class AbstractCommunicationManager implements Serializable { r.close(); } catch (final java.io.IOException e) { // FIXME: Handle exception - logger.log(Level.INFO, "Resource transfer failed", e); + getLogger().log(Level.INFO, "Resource transfer failed", e); } outWriter.print("\"" + JsonPaintTarget.escapeJSON(layout.toString()) + "\""); } else { // FIXME: Handle exception - logger.severe("CustomLayout not found: " + resource); + getLogger().severe("CustomLayout not found: " + resource); } } outWriter.print("}"); @@ -1171,8 +1172,9 @@ public abstract class AbstractCommunicationManager implements Serializable { } sortByHierarchy((List) legacyComponents); for (Vaadin6Component c : legacyComponents) { - logger.fine("Painting Vaadin6Component " + c.getClass().getName() - + "@" + Integer.toHexString(c.hashCode())); + getLogger().fine( + "Painting Vaadin6Component " + c.getClass().getName() + "@" + + Integer.toHexString(c.hashCode())); paintTarget.startTag("change"); final String pid = c.getConnectorId(); paintTarget.addAttribute("pid", pid); @@ -1187,6 +1189,7 @@ public abstract class AbstractCommunicationManager implements Serializable { // containers rely on that their updateFromUIDL method has been called // before children start calling e.g. updateCaption Collections.sort(paintables, new Comparator<Component>() { + @Override public int compare(Component c1, Component c2) { int depth1 = 0; while (c1.getParent() != null) { @@ -1273,14 +1276,17 @@ public abstract class AbstractCommunicationManager implements Serializable { private static class NullIterator<E> implements Iterator<E> { + @Override public boolean hasNext() { return false; } + @Override public E next() { return null; } + @Override public void remove() { } @@ -1479,7 +1485,7 @@ public abstract class AbstractCommunicationManager implements Serializable { invocation.getConnectorId()); if (connector == null) { - logger.log( + getLogger().log( Level.WARNING, "RPC call to " + invocation.getInterfaceName() + "." + invocation.getMethodName() @@ -1517,7 +1523,7 @@ public abstract class AbstractCommunicationManager implements Serializable { msg += ", caption=" + caption; } } - logger.warning(msg); + getLogger().warning(msg); continue; } @@ -1545,14 +1551,13 @@ public abstract class AbstractCommunicationManager implements Serializable { } handleChangeVariablesError(app, errorComponent, e, changes); - } } } - } catch (JSONException e) { - logger.warning("Unable to parse RPC call from the client: " - + e.getMessage()); + getLogger().warning( + "Unable to parse RPC call from the client: " + + e.getMessage()); // TODO or return success = false? throw new RuntimeException(e); } @@ -1726,6 +1731,7 @@ public abstract class AbstractCommunicationManager implements Serializable { this.throwable = throwable; } + @Override public Throwable getThrowable() { return throwable; } @@ -1895,8 +1901,9 @@ public abstract class AbstractCommunicationManager implements Serializable { DateFormat dateFormat = DateFormat.getDateTimeInstance( DateFormat.SHORT, DateFormat.SHORT, l); if (!(dateFormat instanceof SimpleDateFormat)) { - logger.warning("Unable to get default date pattern for locale " - + l.toString()); + getLogger().warning( + "Unable to get default date pattern for locale " + + l.toString()); dateFormat = new SimpleDateFormat(); } final String df = ((SimpleDateFormat) dateFormat).toPattern(); @@ -2095,7 +2102,8 @@ public abstract class AbstractCommunicationManager implements Serializable { if (id == null) { id = nextTypeKey++; typeToKey.put(class1, id); - logger.log(Level.FINE, "Mapping " + class1.getName() + " to " + id); + getLogger().log(Level.FINE, + "Mapping " + class1.getName() + " to " + id); } return id.toString(); } @@ -2232,7 +2240,7 @@ public abstract class AbstractCommunicationManager implements Serializable { writeUidlResponse(request, true, pWriter, root, false); pWriter.print("}"); String initialUIDL = sWriter.toString(); - logger.log(Level.FINE, "Initial UIDL:" + initialUIDL); + getLogger().log(Level.FINE, "Initial UIDL:" + initialUIDL); return initialUIDL; } @@ -2386,4 +2394,7 @@ public abstract class AbstractCommunicationManager implements Serializable { } } + private static final Logger getLogger() { + return Logger.getLogger(AbstractCommunicationManager.class.getName()); + } } diff --git a/src/com/vaadin/terminal/gwt/server/AbstractWebApplicationContext.java b/src/com/vaadin/terminal/gwt/server/AbstractWebApplicationContext.java index c0ae0afc26..bf4ea860a8 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractWebApplicationContext.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractWebApplicationContext.java @@ -32,9 +32,6 @@ import com.vaadin.terminal.ApplicationResource; public abstract class AbstractWebApplicationContext implements ApplicationContext, HttpSessionBindingListener, Serializable { - private static final Logger logger = Logger - .getLogger(AbstractWebApplicationContext.class.getName()); - protected Collection<TransactionListener> listeners = Collections .synchronizedList(new LinkedList<TransactionListener>()); @@ -145,7 +142,7 @@ public abstract class AbstractWebApplicationContext implements // remove same application here. Possible if you got e.g. session // lifetime 1 min but socket write may take longer than 1 min. // FIXME: Handle exception - logger.log(Level.SEVERE, + getLogger().log(Level.SEVERE, "Could not remove application, leaking memory.", e); } } @@ -252,4 +249,8 @@ public abstract class AbstractWebApplicationContext implements return lastRequestTime; } + private Logger getLogger() { + return Logger.getLogger(AbstractWebApplicationContext.class.getName()); + } + }
\ No newline at end of file diff --git a/src/com/vaadin/terminal/gwt/server/ComponentSizeValidator.java b/src/com/vaadin/terminal/gwt/server/ComponentSizeValidator.java index 335067ca7a..171d440796 100644 --- a/src/com/vaadin/terminal/gwt/server/ComponentSizeValidator.java +++ b/src/com/vaadin/terminal/gwt/server/ComponentSizeValidator.java @@ -34,9 +34,6 @@ import com.vaadin.ui.Window; @SuppressWarnings({ "serial", "deprecation" }) public class ComponentSizeValidator implements Serializable { - private final static Logger logger = Logger - .getLogger(ComponentSizeValidator.class.getName()); - private final static int LAYERS_SHOWN = 4; /** @@ -134,7 +131,7 @@ public class ComponentSizeValidator implements Serializable { return parentCanDefineHeight(component); } catch (Exception e) { - logger.log(Level.FINER, + getLogger().log(Level.FINER, "An exception occurred while validating sizes.", e); return true; } @@ -154,7 +151,7 @@ public class ComponentSizeValidator implements Serializable { return parentCanDefineWidth(component); } catch (Exception e) { - logger.log(Level.FINER, + getLogger().log(Level.FINER, "An exception occurred while validating sizes.", e); return true; } @@ -653,11 +650,15 @@ public class ComponentSizeValidator implements Serializable { return; } catch (Exception e) { // TODO Auto-generated catch block - logger.log(Level.FINER, + getLogger().log(Level.FINER, "An exception occurred while validating sizes.", e); } } } + private static Logger getLogger() { + return Logger.getLogger(ComponentSizeValidator.class.getName()); + } + } diff --git a/src/com/vaadin/terminal/gwt/server/DragAndDropService.java b/src/com/vaadin/terminal/gwt/server/DragAndDropService.java index e2358bcbb9..f5bef0b568 100644 --- a/src/com/vaadin/terminal/gwt/server/DragAndDropService.java +++ b/src/com/vaadin/terminal/gwt/server/DragAndDropService.java @@ -28,9 +28,6 @@ import com.vaadin.ui.Component; public class DragAndDropService implements VariableOwner, ClientConnector { - private static final Logger logger = Logger - .getLogger(DragAndDropService.class.getName()); - private int lastVisitId; private boolean lastVisitAccepted = false; @@ -45,13 +42,15 @@ public class DragAndDropService implements VariableOwner, ClientConnector { this.manager = manager; } + @Override public void changeVariables(Object source, Map<String, Object> variables) { Object owner = variables.get("dhowner"); // Validate drop handler owner if (!(owner instanceof DropTarget)) { - logger.severe("DropHandler owner " + owner - + " must implement DropTarget"); + getLogger() + .severe("DropHandler owner " + owner + + " must implement DropTarget"); return; } // owner cannot be null here @@ -81,8 +80,9 @@ public class DragAndDropService implements VariableOwner, ClientConnector { DropHandler dropHandler = (dropTarget).getDropHandler(); if (dropHandler == null) { // No dropHandler returned so no drop can be performed. - logger.fine("DropTarget.getDropHandler() returned null for owner: " - + dropTarget); + getLogger().fine( + "DropTarget.getDropHandler() returned null for owner: " + + dropTarget); return; } @@ -181,10 +181,12 @@ public class DragAndDropService implements VariableOwner, ClientConnector { return transferable; } + @Override public boolean isEnabled() { return isConnectorEnabled(); } + @Override public boolean isImmediate() { return true; } @@ -218,70 +220,87 @@ public class DragAndDropService implements VariableOwner, ClientConnector { return false; } + @Override public SharedState getState() { // TODO Auto-generated method stub return null; } + @Override public String getConnectorId() { return VDragAndDropManager.DD_SERVICE; } + @Override public boolean isConnectorEnabled() { // Drag'n'drop can't be disabled return true; } + @Override public List<ClientMethodInvocation> retrievePendingRpcCalls() { return null; } + @Override public RpcManager getRpcManager(Class<?> rpcInterface) { // TODO Use rpc for drag'n'drop return null; } + @Override public Class<? extends SharedState> getStateType() { return SharedState.class; } + @Override public void requestRepaint() { // TODO Auto-generated method stub } + @Override public ClientConnector getParent() { // TODO Auto-generated method stub return null; } + @Override public void requestRepaintAll() { // TODO Auto-generated method stub } + @Override public void setParent(ClientConnector parent) { // TODO Auto-generated method stub } + @Override public void attach() { // TODO Auto-generated method stub } + @Override public void detach() { // TODO Auto-generated method stub } + @Override public Iterator<Extension> getExtensionIterator() { // TODO Auto-generated method stub return null; } + @Override public void removeExtension(Extension feature) { // TODO Auto-generated method stub + } + private Logger getLogger() { + return Logger.getLogger(DragAndDropService.class.getName()); } } diff --git a/src/com/vaadin/terminal/gwt/server/GAEApplicationServlet.java b/src/com/vaadin/terminal/gwt/server/GAEApplicationServlet.java index 485c98f036..a6032fa98d 100644 --- a/src/com/vaadin/terminal/gwt/server/GAEApplicationServlet.java +++ b/src/com/vaadin/terminal/gwt/server/GAEApplicationServlet.java @@ -94,9 +94,6 @@ import com.vaadin.service.ApplicationContext; */ public class GAEApplicationServlet extends ApplicationServlet { - private static final Logger logger = Logger - .getLogger(GAEApplicationServlet.class.getName()); - // memcache mutex is MUTEX_BASE + sessio id private static final String MUTEX_BASE = "_vmutex"; @@ -209,8 +206,9 @@ public class GAEApplicationServlet extends ApplicationServlet { try { Thread.sleep(RETRY_AFTER_MILLISECONDS); } catch (InterruptedException e) { - logger.finer("Thread.sleep() interrupted while waiting for lock. Trying again. " - + e); + getLogger().finer( + "Thread.sleep() interrupted while waiting for lock. Trying again. " + + e); } } @@ -252,16 +250,16 @@ public class GAEApplicationServlet extends ApplicationServlet { ds.put(entity); } catch (DeadlineExceededException e) { - logger.warning("DeadlineExceeded for " + session.getId()); + getLogger().warning("DeadlineExceeded for " + session.getId()); sendDeadlineExceededNotification(request, response); } catch (NotSerializableException e) { - logger.log(Level.SEVERE, "Not serializable!", e); + getLogger().log(Level.SEVERE, "Not serializable!", e); // TODO this notification is usually not shown - should we redirect // in some other way - can we? sendNotSerializableNotification(request, response); } catch (Exception e) { - logger.log(Level.WARNING, + getLogger().log(Level.WARNING, "An exception occurred while servicing request.", e); sendCriticalErrorNotification(request, response); @@ -308,12 +306,14 @@ public class GAEApplicationServlet extends ApplicationServlet { session.setAttribute(WebApplicationContext.class.getName(), applicationContext); } catch (IOException e) { - logger.log(Level.WARNING, + getLogger().log( + Level.WARNING, "Could not de-serialize ApplicationContext for " + session.getId() + " A new one will be created. ", e); } catch (ClassNotFoundException e) { - logger.log(Level.WARNING, + getLogger().log( + Level.WARNING, "Could not de-serialize ApplicationContext for " + session.getId() + " A new one will be created. ", e); @@ -368,8 +368,9 @@ public class GAEApplicationServlet extends ApplicationServlet { List<Entity> entities = pq.asList(Builder .withLimit(CLEANUP_LIMIT)); if (entities != null) { - logger.info("Vaadin cleanup deleting " + entities.size() - + " expired Vaadin sessions."); + getLogger().info( + "Vaadin cleanup deleting " + entities.size() + + " expired Vaadin sessions."); List<Key> keys = new ArrayList<Key>(); for (Entity e : entities) { keys.add(e.getKey()); @@ -387,8 +388,9 @@ public class GAEApplicationServlet extends ApplicationServlet { List<Entity> entities = pq.asList(Builder .withLimit(CLEANUP_LIMIT)); if (entities != null) { - logger.info("Vaadin cleanup deleting " + entities.size() - + " expired appengine sessions."); + getLogger().info( + "Vaadin cleanup deleting " + entities.size() + + " expired appengine sessions."); List<Key> keys = new ArrayList<Key>(); for (Entity e : entities) { keys.add(e.getKey()); @@ -397,7 +399,11 @@ public class GAEApplicationServlet extends ApplicationServlet { } } } catch (Exception e) { - logger.log(Level.WARNING, "Exception while cleaning.", e); + getLogger().log(Level.WARNING, "Exception while cleaning.", e); } } + + private static final Logger getLogger() { + return Logger.getLogger(GAEApplicationServlet.class.getName()); + } } diff --git a/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java b/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java index 1cde164618..a9f84e62b6 100644 --- a/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java +++ b/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java @@ -43,9 +43,6 @@ import com.vaadin.ui.CustomLayout; @SuppressWarnings("serial") public class JsonPaintTarget implements PaintTarget { - private static final Logger logger = Logger.getLogger(JsonPaintTarget.class - .getName()); - /* Document type declarations */ private final static String UIDL_ARG_NAME = "name"; @@ -107,6 +104,7 @@ public class JsonPaintTarget implements PaintTarget { cacheEnabled = cachingRequired; } + @Override public void startTag(String tagName) throws PaintException { startTag(tagName, false); } @@ -162,6 +160,7 @@ public class JsonPaintTarget implements PaintTarget { * @throws Paintexception * if the paint operation failed. */ + @Override public void endTag(String tagName) throws PaintException { // In case of null data output nothing: if (tagName == null) { @@ -328,14 +327,17 @@ public class JsonPaintTarget implements PaintTarget { * if the paint operation failed. * */ + @Override public void addText(String str) throws PaintException { tag.addData("\"" + escapeJSON(str) + "\""); } + @Override public void addAttribute(String name, boolean value) throws PaintException { tag.addAttribute("\"" + name + "\":" + (value ? "true" : "false")); } + @Override @SuppressWarnings("deprecation") public void addAttribute(String name, Resource value) throws PaintException { @@ -365,22 +367,27 @@ public class JsonPaintTarget implements PaintTarget { } + @Override public void addAttribute(String name, int value) throws PaintException { tag.addAttribute("\"" + name + "\":" + String.valueOf(value)); } + @Override public void addAttribute(String name, long value) throws PaintException { tag.addAttribute("\"" + name + "\":" + String.valueOf(value)); } + @Override public void addAttribute(String name, float value) throws PaintException { tag.addAttribute("\"" + name + "\":" + String.valueOf(value)); } + @Override public void addAttribute(String name, double value) throws PaintException { tag.addAttribute("\"" + name + "\":" + String.valueOf(value)); } + @Override public void addAttribute(String name, String value) throws PaintException { // In case of null data output nothing: if ((value == null) || (name == null)) { @@ -400,12 +407,14 @@ public class JsonPaintTarget implements PaintTarget { } + @Override public void addAttribute(String name, Component value) throws PaintException { final String id = value.getConnectorId(); addAttribute(name, id); } + @Override public void addAttribute(String name, Map<?, ?> value) throws PaintException { @@ -443,6 +452,7 @@ public class JsonPaintTarget implements PaintTarget { tag.addAttribute(sb.toString()); } + @Override public void addAttribute(String name, Object[] values) { // In case of null data output nothing: if ((values == null) || (name == null)) { @@ -463,41 +473,49 @@ public class JsonPaintTarget implements PaintTarget { tag.addAttribute(buf.toString()); } + @Override public void addVariable(VariableOwner owner, String name, String value) throws PaintException { tag.addVariable(new StringVariable(owner, name, escapeJSON(value))); } - public void addVariable(VariableOwner owner, String name, - Component value) throws PaintException { + @Override + public void addVariable(VariableOwner owner, String name, Component value) + throws PaintException { tag.addVariable(new StringVariable(owner, name, value.getConnectorId())); } + @Override public void addVariable(VariableOwner owner, String name, int value) throws PaintException { tag.addVariable(new IntVariable(owner, name, value)); } + @Override public void addVariable(VariableOwner owner, String name, long value) throws PaintException { tag.addVariable(new LongVariable(owner, name, value)); } + @Override public void addVariable(VariableOwner owner, String name, float value) throws PaintException { tag.addVariable(new FloatVariable(owner, name, value)); } + @Override public void addVariable(VariableOwner owner, String name, double value) throws PaintException { tag.addVariable(new DoubleVariable(owner, name, value)); } + @Override public void addVariable(VariableOwner owner, String name, boolean value) throws PaintException { tag.addVariable(new BooleanVariable(owner, name, value)); } + @Override public void addVariable(VariableOwner owner, String name, String[] value) throws PaintException { tag.addVariable(new ArrayVariable(owner, name, value)); @@ -516,6 +534,7 @@ public class JsonPaintTarget implements PaintTarget { * @throws PaintException * if the paint operation failed. */ + @Override public void addUploadStreamVariable(VariableOwner owner, String name) throws PaintException { startTag("uploadstream"); @@ -535,6 +554,7 @@ public class JsonPaintTarget implements PaintTarget { * @throws PaintException * if the paint operation failed. */ + @Override public void addSection(String sectionTagName, String sectionData) throws PaintException { tag.addData("{\"" + sectionTagName + "\":\"" + escapeJSON(sectionData) @@ -549,6 +569,7 @@ public class JsonPaintTarget implements PaintTarget { * @throws PaintException * if the paint operation failed. */ + @Override public void addUIDL(String xml) throws PaintException { // Ensure that the target is open @@ -582,6 +603,7 @@ public class JsonPaintTarget implements PaintTarget { * @see com.vaadin.terminal.PaintTarget#addXMLSection(String, String, * String) */ + @Override public void addXMLSection(String sectionTagName, String sectionData, String namespace) throws PaintException { @@ -646,12 +668,14 @@ public class JsonPaintTarget implements PaintTarget { * @see com.vaadin.terminal.PaintTarget#startPaintable(com.vaadin.terminal * .Paintable, java.lang.String) */ + @Override public PaintStatus startPaintable(Component connector, String tagName) throws PaintException { boolean topLevelPaintable = openPaintables.isEmpty(); - logger.fine("startPaintable for " + connector.getClass().getName() - + "@" + Integer.toHexString(connector.hashCode())); + getLogger().fine( + "startPaintable for " + connector.getClass().getName() + "@" + + Integer.toHexString(connector.hashCode())); startTag(tagName, true); openPaintables.push(connector); @@ -671,9 +695,11 @@ public class JsonPaintTarget implements PaintTarget { return PaintStatus.PAINTING; } + @Override public void endPaintable(Component paintable) throws PaintException { - logger.fine("endPaintable for " + paintable.getClass().getName() + "@" - + Integer.toHexString(paintable.hashCode())); + getLogger().fine( + "endPaintable for " + paintable.getClass().getName() + "@" + + Integer.toHexString(paintable.hashCode())); ClientConnector openPaintable = openPaintables.peek(); if (paintable != openPaintable) { @@ -692,6 +718,7 @@ public class JsonPaintTarget implements PaintTarget { * * @see com.vaadin.terminal.PaintTarget#addCharacterData(java.lang.String ) */ + @Override public void addCharacterData(String text) throws PaintException { if (text != null) { tag.addData(text); @@ -961,6 +988,7 @@ public class JsonPaintTarget implements PaintTarget { return usedResources; } + @Override @SuppressWarnings("unchecked") public String getTag(ClientConnector clientConnector) { Class<? extends ClientConnector> clientConnectorClass = clientConnector @@ -983,6 +1011,7 @@ public class JsonPaintTarget implements PaintTarget { return usedClientConnectors; } + @Override public void addVariable(VariableOwner owner, String name, StreamVariable value) throws PaintException { String url = manager.getStreamVariableTargetUrl((Connector) owner, @@ -998,8 +1027,13 @@ public class JsonPaintTarget implements PaintTarget { * * @see com.vaadin.terminal.PaintTarget#isFullRepaint() */ + @Override public boolean isFullRepaint() { return !cacheEnabled; } + private static final Logger getLogger() { + return Logger.getLogger(JsonPaintTarget.class.getName()); + } + } diff --git a/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java b/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java index 661da57af6..de4f918b75 100644 --- a/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java +++ b/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java @@ -48,9 +48,6 @@ import com.vaadin.ui.Root; @SuppressWarnings("serial") public class PortletApplicationContext2 extends AbstractWebApplicationContext { - private static final Logger logger = Logger - .getLogger(PortletApplicationContext2.class.getName()); - protected Map<Application, Set<PortletListener>> portletListeners = new HashMap<Application, Set<PortletListener>>(); protected transient PortletSession session; @@ -76,11 +73,11 @@ public class PortletApplicationContext2 extends AbstractWebApplicationContext { return new File(url.getFile()); } catch (final Exception e) { // FIXME: Handle exception - logger.log( - Level.INFO, - "Cannot access base directory, possible security issue " - + "with Application Server or Servlet Container", - e); + getLogger() + .log(Level.INFO, + "Cannot access base directory, possible security issue " + + "with Application Server or Servlet Container", + e); } } return null; @@ -419,4 +416,8 @@ public class PortletApplicationContext2 extends AbstractWebApplicationContext { "Portlet mode can only be changed from a portlet request"); } } + + private Logger getLogger() { + return Logger.getLogger(PortletApplicationContext2.class.getName()); + } } diff --git a/src/com/vaadin/terminal/gwt/widgetsetutils/ClassPathExplorer.java b/src/com/vaadin/terminal/gwt/widgetsetutils/ClassPathExplorer.java index 6a0aa0f4c2..ced92d519b 100644 --- a/src/com/vaadin/terminal/gwt/widgetsetutils/ClassPathExplorer.java +++ b/src/com/vaadin/terminal/gwt/widgetsetutils/ClassPathExplorer.java @@ -31,7 +31,6 @@ import java.util.logging.Logger; import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; import com.vaadin.event.dd.acceptcriteria.ClientCriterion; -import com.vaadin.terminal.gwt.server.ClientConnector; /** * Utility class to collect widgetset related information from classpath. @@ -53,15 +52,13 @@ import com.vaadin.terminal.gwt.server.ClientConnector; */ public class ClassPathExplorer { - private static Logger logger = Logger.getLogger(ClassPathExplorer.class - .getName()); - private static final String VAADIN_ADDON_VERSION_ATTRIBUTE = "Vaadin-Package-Version"; /** * File filter that only accepts directories. */ private final static FileFilter DIRECTORIES_ONLY = new FileFilter() { + @Override public boolean accept(File f) { if (f.exists() && f.isDirectory()) { return true; @@ -98,10 +95,9 @@ public class ClassPathExplorer { * * As a side effect, also accept criteria are searched under the same class * path entries and added into the acceptCriterion collection. - * - * @return a collection of {@link ClientConnector} classes */ public static void findAcceptCriteria() { + final Logger logger = getLogger(); logger.info("Searching for accept criteria.."); long start = System.currentTimeMillis(); Set<String> keySet = classpathLocations.keySet(); @@ -154,6 +150,7 @@ public class ClassPathExplorer { sb.append(widgetsets.get(ws)); sb.append("\n"); } + final Logger logger = getLogger(); logger.info(sb.toString()); logger.info("Search took " + (end - start) + "ms"); return widgetsets; @@ -214,7 +211,7 @@ public class ClassPathExplorer { } catch (MalformedURLException e) { // should never happen as based on an existing URL, // only changing end of file name/path part - logger.log(Level.SEVERE, + getLogger().log(Level.SEVERE, "Error locating the widgetset " + classname, e); } } @@ -250,7 +247,7 @@ public class ClassPathExplorer { } } } catch (IOException e) { - logger.log(Level.WARNING, "Error parsing jar file", e); + getLogger().log(Level.WARNING, "Error parsing jar file", e); } } @@ -278,7 +275,7 @@ public class ClassPathExplorer { classpath = classpath.substring(0, classpath.length() - 1); } - logger.fine("Classpath: " + classpath); + getLogger().fine("Classpath: " + classpath); String[] split = classpath.split(pathSep); for (int i = 0; i < split.length; i++) { @@ -312,6 +309,7 @@ public class ClassPathExplorer { include(null, file, locations); } long end = System.currentTimeMillis(); + Logger logger = getLogger(); if (logger.isLoggable(Level.FINE)) { logger.fine("getClassPathLocations took " + (end - start) + "ms"); } @@ -352,7 +350,7 @@ public class ClassPathExplorer { url = new URL("jar:" + url.toExternalForm() + "!/"); JarURLConnection conn = (JarURLConnection) url .openConnection(); - logger.fine(url.toString()); + getLogger().fine(url.toString()); JarFile jarFile = conn.getJarFile(); Manifest manifest = jarFile.getManifest(); if (manifest != null) { @@ -363,9 +361,11 @@ public class ClassPathExplorer { } } } catch (MalformedURLException e) { - logger.log(Level.FINEST, "Failed to inspect JAR file", e); + getLogger().log(Level.FINEST, "Failed to inspect JAR file", + e); } catch (IOException e) { - logger.log(Level.FINEST, "Failed to inspect JAR file", e); + getLogger().log(Level.FINEST, "Failed to inspect JAR file", + e); } return false; @@ -510,7 +510,7 @@ public class ClassPathExplorer { } } } catch (IOException e) { - logger.warning(e.toString()); + getLogger().warning(e.toString()); } } @@ -582,7 +582,8 @@ public class ClassPathExplorer { // Must be done here after stderr and stdout have been reset. if (errorToShow != null && logLevel != null) { - logger.log(logLevel, + getLogger().log( + logLevel, "Failed to load class " + fullclassName + ". " + errorToShow.getClass().getName() + ": " + errorToShow.getMessage()); @@ -601,6 +602,9 @@ public class ClassPathExplorer { * @return URL */ public static URL getDefaultSourceDirectory() { + + final Logger logger = getLogger(); + if (logger.isLoggable(Level.FINE)) { logger.fine("classpathLocations values:"); ArrayList<String> locations = new ArrayList<String>( @@ -656,20 +660,24 @@ public class ClassPathExplorer { */ public static void main(String[] args) { ClassPathExplorer.findAcceptCriteria(); - logger.info("Found client criteria:"); + getLogger().info("Found client criteria:"); for (Class<? extends AcceptCriterion> cls : acceptCriterion) { - logger.info(cls.getCanonicalName()); + getLogger().info(cls.getCanonicalName()); } - logger.info(""); - logger.info("Searching available widgetsets..."); + getLogger().info(""); + getLogger().info("Searching available widgetsets..."); Map<String, URL> availableWidgetSets = ClassPathExplorer .getAvailableWidgetSets(); for (String string : availableWidgetSets.keySet()) { - logger.info(string + " in " + availableWidgetSets.get(string)); + getLogger().info(string + " in " + availableWidgetSets.get(string)); } } + private static final Logger getLogger() { + return Logger.getLogger(ClassPathExplorer.class.getName()); + } + } diff --git a/src/com/vaadin/tools/WidgetsetCompiler.java b/src/com/vaadin/tools/WidgetsetCompiler.java index 618313a8d8..407f0e2387 100644 --- a/src/com/vaadin/tools/WidgetsetCompiler.java +++ b/src/com/vaadin/tools/WidgetsetCompiler.java @@ -36,9 +36,6 @@ import com.vaadin.terminal.gwt.widgetsetutils.WidgetSetBuilder; @Deprecated public class WidgetsetCompiler { - private static final Logger logger = Logger - .getLogger(WidgetsetCompiler.class.getName()); - /** * @param args * same arguments as for com.google.gwt.dev.Compiler @@ -75,7 +72,7 @@ public class WidgetsetCompiler { String[].class); method.invoke(null, new Object[] { args }); } catch (Throwable thr) { - logger.log(Level.SEVERE, + getLogger().log(Level.SEVERE, "Widgetset compilation failed", thr); } } @@ -85,7 +82,11 @@ public class WidgetsetCompiler { runThread.join(); System.out.println("Widgetset compilation finished"); } catch (Throwable thr) { - logger.log(Level.SEVERE, "Widgetset compilation failed", thr); + getLogger().log(Level.SEVERE, "Widgetset compilation failed", thr); } } + + private static final Logger getLogger() { + return Logger.getLogger(WidgetsetCompiler.class.getName()); + } } diff --git a/src/com/vaadin/ui/Table.java b/src/com/vaadin/ui/Table.java index 5f4016de18..3b12c097de 100644 --- a/src/com/vaadin/ui/Table.java +++ b/src/com/vaadin/ui/Table.java @@ -78,8 +78,7 @@ public class Table extends AbstractSelect implements Action.Container, Container.Ordered, Container.Sortable, ItemClickNotifier, DragSource, DropTarget, HasComponents { - private static final Logger logger = Logger - .getLogger(Table.class.getName()); + private transient Logger logger = null; /** * Modes that Table support as drag sourse. @@ -1757,8 +1756,9 @@ public class Table extends AbstractSelect implements Action.Container, * @return */ private Object[][] getVisibleCellsInsertIntoCache(int firstIndex, int rows) { - logger.finest("Insert " + rows + " rows at index " + firstIndex - + " to existing page buffer requested"); + getLogger().finest( + "Insert " + rows + " rows at index " + firstIndex + + " to existing page buffer requested"); // Page buffer must not become larger than pageLength*cacheRate before // or after the current page @@ -1861,11 +1861,14 @@ public class Table extends AbstractSelect implements Action.Container, } } pageBuffer = newPageBuffer; - logger.finest("Page Buffer now contains " - + pageBuffer[CELL_ITEMID].length + " rows (" - + pageBufferFirstIndex + "-" - + (pageBufferFirstIndex + pageBuffer[CELL_ITEMID].length - 1) - + ")"); + getLogger().finest( + "Page Buffer now contains " + + pageBuffer[CELL_ITEMID].length + + " rows (" + + pageBufferFirstIndex + + "-" + + (pageBufferFirstIndex + + pageBuffer[CELL_ITEMID].length - 1) + ")"); return cells; } @@ -1882,8 +1885,9 @@ public class Table extends AbstractSelect implements Action.Container, */ private Object[][] getVisibleCellsNoCache(int firstIndex, int rows, boolean replaceListeners) { - logger.finest("Render visible cells for rows " + firstIndex + "-" - + (firstIndex + rows - 1)); + getLogger().finest( + "Render visible cells for rows " + firstIndex + "-" + + (firstIndex + rows - 1)); final Object[] colids = getVisibleColumns(); final int cols = colids.length; @@ -2065,8 +2069,9 @@ public class Table extends AbstractSelect implements Action.Container, } protected void registerComponent(Component component) { - logger.finest("Registered " + component.getClass().getSimpleName() - + ": " + component.getCaption()); + getLogger().finest( + "Registered " + component.getClass().getSimpleName() + ": " + + component.getCaption()); if (component.getParent() != this) { component.setParent(this); } @@ -2097,8 +2102,9 @@ public class Table extends AbstractSelect implements Action.Container, * @param count */ private void unregisterComponentsAndPropertiesInRows(int firstIx, int count) { - logger.finest("Unregistering components in rows " + firstIx + "-" - + (firstIx + count - 1)); + getLogger().finest( + "Unregistering components in rows " + firstIx + "-" + + (firstIx + count - 1)); Object[] colids = getVisibleColumns(); if (pageBuffer != null && pageBuffer[CELL_ITEMID].length > 0) { int bufSize = pageBuffer[CELL_ITEMID].length; @@ -2178,8 +2184,9 @@ public class Table extends AbstractSelect implements Action.Container, * a set of components that should be unregistered. */ protected void unregisterComponent(Component component) { - logger.finest("Unregistered " + component.getClass().getSimpleName() - + ": " + component.getCaption()); + getLogger().finest( + "Unregistered " + component.getClass().getSimpleName() + ": " + + component.getCaption()); component.setParent(null); /* * Also remove property data sources to unregister listeners keeping the @@ -2548,7 +2555,7 @@ public class Table extends AbstractSelect implements Action.Container, .get("lastToBeRendered")).intValue(); } catch (Exception e) { // FIXME: Handle exception - logger.log(Level.FINER, + getLogger().log(Level.FINER, "Could not parse the first and/or last rows.", e); } @@ -2568,8 +2575,9 @@ public class Table extends AbstractSelect implements Action.Container, } } } - logger.finest("Client wants rows " + reqFirstRowToPaint + "-" - + (reqFirstRowToPaint + reqRowsToPaint - 1)); + getLogger().finest( + "Client wants rows " + reqFirstRowToPaint + "-" + + (reqFirstRowToPaint + reqRowsToPaint - 1)); clientNeedsContentRefresh = true; } @@ -2615,7 +2623,7 @@ public class Table extends AbstractSelect implements Action.Container, } } catch (final Exception e) { // FIXME: Handle exception - logger.log(Level.FINER, + getLogger().log(Level.FINER, "Could not determine column collapsing state", e); } clientNeedsContentRefresh = true; @@ -2637,7 +2645,7 @@ public class Table extends AbstractSelect implements Action.Container, } } catch (final Exception e) { // FIXME: Handle exception - logger.log(Level.FINER, + getLogger().log(Level.FINER, "Could not determine column reordering state", e); } clientNeedsContentRefresh = true; @@ -2927,8 +2935,9 @@ public class Table extends AbstractSelect implements Action.Container, target.startTag("prows"); if (!shouldHideAddedRows()) { - logger.finest("Paint rows for add. Index: " + firstIx + ", count: " - + count + "."); + getLogger().finest( + "Paint rows for add. Index: " + firstIx + ", count: " + + count + "."); // Partial row additions bypass the normal caching mechanism. Object[][] cells = getVisibleCellsInsertIntoCache(firstIx, count); @@ -2951,8 +2960,9 @@ public class Table extends AbstractSelect implements Action.Container, indexInRowbuffer, itemId); } } else { - logger.finest("Paint rows for remove. Index: " + firstIx - + ", count: " + count + "."); + getLogger().finest( + "Paint rows for remove. Index: " + firstIx + ", count: " + + count + "."); removeRowsFromCacheAndFillBottom(firstIx, count); target.addAttribute("hide", true); } @@ -3666,6 +3676,7 @@ public class Table extends AbstractSelect implements Action.Container, * * @see com.vaadin.event.Action.Container#addActionHandler(Action.Handler) */ + @Override public void addActionHandler(Action.Handler actionHandler) { if (actionHandler != null) { @@ -3692,6 +3703,7 @@ public class Table extends AbstractSelect implements Action.Container, * * @see com.vaadin.event.Action.Container#removeActionHandler(Action.Handler) */ + @Override public void removeActionHandler(Action.Handler actionHandler) { if (actionHandlers != null && actionHandlers.contains(actionHandler)) { @@ -4089,6 +4101,7 @@ public class Table extends AbstractSelect implements Action.Container, * * @see com.vaadin.data.Container.Ordered#nextItemId(java.lang.Object) */ + @Override public Object nextItemId(Object itemId) { return ((Container.Ordered) items).nextItemId(itemId); } @@ -4099,6 +4112,7 @@ public class Table extends AbstractSelect implements Action.Container, * * @see com.vaadin.data.Container.Ordered#prevItemId(java.lang.Object) */ + @Override public Object prevItemId(Object itemId) { return ((Container.Ordered) items).prevItemId(itemId); } @@ -4108,6 +4122,7 @@ public class Table extends AbstractSelect implements Action.Container, * * @see com.vaadin.data.Container.Ordered#firstItemId() */ + @Override public Object firstItemId() { return ((Container.Ordered) items).firstItemId(); } @@ -4117,6 +4132,7 @@ public class Table extends AbstractSelect implements Action.Container, * * @see com.vaadin.data.Container.Ordered#lastItemId() */ + @Override public Object lastItemId() { return ((Container.Ordered) items).lastItemId(); } @@ -4127,6 +4143,7 @@ public class Table extends AbstractSelect implements Action.Container, * * @see com.vaadin.data.Container.Ordered#isFirstId(java.lang.Object) */ + @Override public boolean isFirstId(Object itemId) { return ((Container.Ordered) items).isFirstId(itemId); } @@ -4137,6 +4154,7 @@ public class Table extends AbstractSelect implements Action.Container, * * @see com.vaadin.data.Container.Ordered#isLastId(java.lang.Object) */ + @Override public boolean isLastId(Object itemId) { return ((Container.Ordered) items).isLastId(itemId); } @@ -4146,6 +4164,7 @@ public class Table extends AbstractSelect implements Action.Container, * * @see com.vaadin.data.Container.Ordered#addItemAfter(java.lang.Object) */ + @Override public Object addItemAfter(Object previousItemId) throws UnsupportedOperationException { Object itemId = ((Container.Ordered) items) @@ -4162,6 +4181,7 @@ public class Table extends AbstractSelect implements Action.Container, * @see com.vaadin.data.Container.Ordered#addItemAfter(java.lang.Object, * java.lang.Object) */ + @Override public Item addItemAfter(Object previousItemId, Object newItemId) throws UnsupportedOperationException { Item item = ((Container.Ordered) items).addItemAfter(previousItemId, @@ -4254,6 +4274,7 @@ public class Table extends AbstractSelect implements Action.Container, * boolean[]) * */ + @Override public void sort(Object[] propertyId, boolean[] ascending) throws UnsupportedOperationException { final Container c = getContainerDataSource(); @@ -4289,6 +4310,7 @@ public class Table extends AbstractSelect implements Action.Container, * * @see com.vaadin.data.Container.Sortable#getSortableContainerPropertyIds() */ + @Override public Collection<?> getSortableContainerPropertyIds() { final Container c = getContainerDataSource(); if (c instanceof Container.Sortable && !isSortDisabled()) { @@ -4478,11 +4500,13 @@ public class Table extends AbstractSelect implements Action.Container, public abstract String getStyle(Object itemId, Object propertyId); } + @Override public void addListener(ItemClickListener listener) { addListener(VScrollTable.ITEM_CLICK_EVENT_ID, ItemClickEvent.class, listener, ItemClickEvent.ITEM_CLICK_METHOD); } + @Override public void removeListener(ItemClickListener listener) { removeListener(VScrollTable.ITEM_CLICK_EVENT_ID, ItemClickEvent.class, listener); @@ -4558,11 +4582,13 @@ public class Table extends AbstractSelect implements Action.Container, } + @Override public TableTransferable getTransferable(Map<String, Object> rawVariables) { TableTransferable transferable = new TableTransferable(rawVariables); return transferable; } + @Override public DropHandler getDropHandler() { return dropHandler; } @@ -4571,6 +4597,7 @@ public class Table extends AbstractSelect implements Action.Container, this.dropHandler = dropHandler; } + @Override public AbstractSelectTargetDetails translateDropTargetDetails( Map<String, Object> clientVariables) { return new AbstractSelectTargetDetails(clientVariables); @@ -4639,6 +4666,7 @@ public class Table extends AbstractSelect implements Action.Container, * com.vaadin.event.dd.acceptcriteria.AcceptCriterion#accepts(com.vaadin * .event.dd.DragAndDropEvent) */ + @Override @SuppressWarnings("unchecked") public boolean accept(DragAndDropEvent dragEvent) { AbstractSelectTargetDetails dropTargetData = (AbstractSelectTargetDetails) dragEvent @@ -5313,10 +5341,12 @@ public class Table extends AbstractSelect implements Action.Container, super.setVisible(visible); } + @Override public Iterator<Component> iterator() { return getComponentIterator(); } + @Override public Iterator<Component> getComponentIterator() { if (visibleComponents == null) { Collection<Component> empty = Collections.emptyList(); @@ -5326,7 +5356,15 @@ public class Table extends AbstractSelect implements Action.Container, return visibleComponents.iterator(); } + @Override public boolean isComponentVisible(Component childComponent) { return true; } + + private final Logger getLogger() { + if (logger == null) { + logger = Logger.getLogger(Table.class.getName()); + } + return logger; + } } diff --git a/src/com/vaadin/ui/TreeTable.java b/src/com/vaadin/ui/TreeTable.java index 74faac4781..6c832d37fe 100644 --- a/src/com/vaadin/ui/TreeTable.java +++ b/src/com/vaadin/ui/TreeTable.java @@ -49,9 +49,6 @@ import com.vaadin.ui.Tree.ExpandListener; @SuppressWarnings({ "serial" }) public class TreeTable extends Table implements Hierarchical { - private static final Logger logger = Logger.getLogger(TreeTable.class - .getName()); - private interface ContainerStrategy extends Serializable { public int size(); @@ -242,9 +239,9 @@ public class TreeTable extends Table implements Hierarchical { boolean removed = openItems.remove(itemId); if (!removed) { openItems.add(itemId); - logger.finest("Item " + itemId + " is now expanded"); + getLogger().finest("Item " + itemId + " is now expanded"); } else { - logger.finest("Item " + itemId + " is now collapsed"); + getLogger().finest("Item " + itemId + " is now collapsed"); } clearPreorderCache(); } @@ -819,4 +816,8 @@ public class TreeTable extends Table implements Hierarchical { requestRepaint(); } + private static final Logger getLogger() { + return Logger.getLogger(TreeTable.class.getName()); + } + } diff --git a/tests/testbench/com/vaadin/launcher/ApplicationRunnerServlet.java b/tests/testbench/com/vaadin/launcher/ApplicationRunnerServlet.java index 33d63b0413..dd93b1a8b6 100644 --- a/tests/testbench/com/vaadin/launcher/ApplicationRunnerServlet.java +++ b/tests/testbench/com/vaadin/launcher/ApplicationRunnerServlet.java @@ -9,7 +9,6 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.Collections; import java.util.LinkedHashSet; -import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; @@ -45,9 +44,6 @@ public class ApplicationRunnerServlet extends AbstractApplicationServlet { } } - private static final Logger logger = Logger - .getLogger(ApplicationRunnerServlet.class.getName()); - /** * The name of the application class currently used. Only valid within one * request. @@ -241,8 +237,10 @@ public class ApplicationRunnerServlet extends AbstractApplicationServlet { // Ignore as this is expected for many packages } catch (Exception e2) { // TODO: handle exception - logger.log(Level.FINE, "Failed to find application class " - + pkg + "." + baseName, e2); + getLogger().log( + Level.FINE, + "Failed to find application class " + pkg + "." + + baseName, e2); } if (appClass != null) { return appClass; @@ -289,4 +287,8 @@ public class ApplicationRunnerServlet extends AbstractApplicationServlet { }; } + private Logger getLogger() { + return Logger.getLogger(ApplicationRunnerServlet.class.getName()); + } + } |