Repository: cayenne Updated Branches: refs/heads/master bf689bfd0 -> a2e0452d6
Renamed CommonsJdbcEventLogger and FormattedCommonsJdbcEventLogger to Slf4jJdbcEventLogger and FormattedSlf4jJdbcEventLogger respectively. Added SLF4J license to LICENSE.txt Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/a2e0452d Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/a2e0452d Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/a2e0452d Branch: refs/heads/master Commit: a2e0452d66a056db75295124a06534f9ac56916b Parents: bf689bf Author: Nikita Timofeev <stari...@gmail.com> Authored: Wed May 3 13:07:04 2017 +0300 Committer: Nikita Timofeev <stari...@gmail.com> Committed: Wed May 3 13:07:04 2017 +0300 ---------------------------------------------------------------------- .../main/resources/META-INF/cayenne/LICENSE.txt | 26 + .../reverse/configuration/ToolsModule.java | 4 +- .../configuration/server/ServerModule.java | 4 +- .../cayenne/log/CommonsJdbcEventLogger.java | 487 ------------------- .../log/FormattedCommonsJdbcEventLogger.java | 135 ----- .../log/FormattedSlf4jJdbcEventLogger.java | 135 +++++ .../cayenne/log/Slf4jJdbcEventLogger.java | 482 ++++++++++++++++++ .../access/DefaultDataRowStoreFactoryIT.java | 6 +- .../server/DataContextFactoryTest.java | 6 +- .../server/DataDomainProviderTest.java | 4 +- .../DefaultDataSourceFactoryLoaderTest.java | 6 +- .../server/DefaultDbAdapterFactoryTest.java | 10 +- .../cayenne/dba/PerAdapterProviderTest.java | 4 +- .../cayenne/log/CommonsJdbcEventLoggerTest.java | 56 --- .../cayenne/log/Slf4jJdbcEventLoggerTest.java | 57 +++ .../unit/di/server/ServerCaseModule.java | 4 +- docs/doc/src/main/resources/UPGRADE.txt | 4 + .../src/docbkx/customizing-cayenne-runtime.xml | 4 +- .../event/JavaGroupsBridgeProviderTest.java | 4 +- .../cayenne/event/JMSBridgeProviderTest.java | 4 +- .../cayenne/event/XMPPBridgeProviderTest.java | 4 +- 21 files changed, 736 insertions(+), 710 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cayenne/blob/a2e0452d/build-tools/cayenne-legal/src/main/resources/META-INF/cayenne/LICENSE.txt ---------------------------------------------------------------------- diff --git a/build-tools/cayenne-legal/src/main/resources/META-INF/cayenne/LICENSE.txt b/build-tools/cayenne-legal/src/main/resources/META-INF/cayenne/LICENSE.txt index ebc376a..ad10aba 100644 --- a/build-tools/cayenne-legal/src/main/resources/META-INF/cayenne/LICENSE.txt +++ b/build-tools/cayenne-legal/src/main/resources/META-INF/cayenne/LICENSE.txt @@ -813,3 +813,29 @@ Copyright 2010 Google Inc. All Rights Reserved. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + + +===================================================================== +SLF4J License + + Copyright (c) 2004-2017 QOS.ch + All rights reserved. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cayenne/blob/a2e0452d/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/configuration/ToolsModule.java ---------------------------------------------------------------------- diff --git a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/configuration/ToolsModule.java b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/configuration/ToolsModule.java index d2c6b62..0c8cb2c 100644 --- a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/configuration/ToolsModule.java +++ b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/configuration/ToolsModule.java @@ -51,7 +51,7 @@ import org.apache.cayenne.di.Key; import org.apache.cayenne.di.Module; import org.apache.cayenne.di.spi.DefaultAdhocObjectFactory; import org.apache.cayenne.di.spi.DefaultClassLoaderManager; -import org.apache.cayenne.log.CommonsJdbcEventLogger; +import org.apache.cayenne.log.Slf4jJdbcEventLogger; import org.apache.cayenne.log.JdbcEventLogger; import org.apache.cayenne.resource.ClassLoaderResourceLocator; import org.apache.cayenne.resource.ResourceLocator; @@ -96,7 +96,7 @@ public class ToolsModule implements Module { binder.bind(RuntimeProperties.class).to(DefaultRuntimeProperties.class); binder.bind(BatchTranslatorFactory.class).to(DefaultBatchTranslatorFactory.class); - binder.bind(JdbcEventLogger.class).to(CommonsJdbcEventLogger.class); + binder.bind(JdbcEventLogger.class).to(Slf4jJdbcEventLogger.class); ServerModule.contributeAdapterDetectors(binder).add(FirebirdSniffer.class).add(OpenBaseSniffer.class) .add(FrontBaseSniffer.class).add(IngresSniffer.class).add(SQLiteSniffer.class).add(DB2Sniffer.class) http://git-wip-us.apache.org/repos/asf/cayenne/blob/a2e0452d/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerModule.java ---------------------------------------------------------------------- diff --git a/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerModule.java b/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerModule.java index 74b8109..962bba9 100644 --- a/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerModule.java +++ b/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerModule.java @@ -100,7 +100,7 @@ import org.apache.cayenne.event.DefaultEventManager; import org.apache.cayenne.event.NoopEventBridgeProvider; import org.apache.cayenne.event.EventBridge; import org.apache.cayenne.event.EventManager; -import org.apache.cayenne.log.CommonsJdbcEventLogger; +import org.apache.cayenne.log.Slf4jJdbcEventLogger; import org.apache.cayenne.log.JdbcEventLogger; import org.apache.cayenne.map.EntitySorter; import org.apache.cayenne.access.types.ValueObjectType; @@ -293,7 +293,7 @@ public class ServerModule implements Module { contributeProperties(binder) .put(Constants.SERVER_MAX_ID_QUALIFIER_SIZE_PROPERTY, String.valueOf(DEFAULT_MAX_ID_QUALIFIER_SIZE)); - binder.bind(JdbcEventLogger.class).to(CommonsJdbcEventLogger.class); + binder.bind(JdbcEventLogger.class).to(Slf4jJdbcEventLogger.class); binder.bind(ClassLoaderManager.class).to(DefaultClassLoaderManager.class); binder.bind(AdhocObjectFactory.class).to(DefaultAdhocObjectFactory.class); http://git-wip-us.apache.org/repos/asf/cayenne/blob/a2e0452d/cayenne-server/src/main/java/org/apache/cayenne/log/CommonsJdbcEventLogger.java ---------------------------------------------------------------------- diff --git a/cayenne-server/src/main/java/org/apache/cayenne/log/CommonsJdbcEventLogger.java b/cayenne-server/src/main/java/org/apache/cayenne/log/CommonsJdbcEventLogger.java deleted file mode 100644 index c0007bc..0000000 --- a/cayenne-server/src/main/java/org/apache/cayenne/log/CommonsJdbcEventLogger.java +++ /dev/null @@ -1,487 +0,0 @@ -/***************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - ****************************************************************/ -package org.apache.cayenne.log; - -import org.apache.cayenne.CayenneRuntimeException; -import org.apache.cayenne.ExtendedEnumeration; -import org.apache.cayenne.access.translator.DbAttributeBinding; -import org.apache.cayenne.access.translator.ParameterBinding; -import org.apache.cayenne.configuration.Constants; -import org.apache.cayenne.configuration.RuntimeProperties; -import org.apache.cayenne.conn.DataSourceInfo; -import org.apache.cayenne.di.Inject; -import org.apache.cayenne.map.DbAttribute; -import org.apache.cayenne.util.IDUtil; -import org.apache.cayenne.util.Util; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.lang.reflect.Array; -import java.sql.SQLException; -import java.util.Iterator; -import java.util.List; - -/** - * A {@link JdbcEventLogger} built on top of slf4j-api logger. - * - * @since 3.1 - */ -public class CommonsJdbcEventLogger implements JdbcEventLogger { - - private static final Logger logger = LoggerFactory.getLogger(CommonsJdbcEventLogger.class); - - /** - * @deprecated since 4.0 - */ - private static final int TRIM_VALUES_THRESHOLD = 30; - - protected long queryExecutionTimeLoggingThreshold; - - public CommonsJdbcEventLogger(@Inject RuntimeProperties runtimeProperties) { - this.queryExecutionTimeLoggingThreshold = runtimeProperties.getLong( - Constants.QUERY_EXECUTION_TIME_LOGGING_THRESHOLD_PROPERTY, 0); - } - - // this should go away once we can remove 4.0 deprecated API. The actual logic for printing a value is now - // spread around the ExtendedTypes - void sqlLiteralForObject(StringBuilder buffer, Object object) { - if (object == null) { - buffer.append("NULL"); - } else if (object instanceof String) { - buffer.append('\''); - // lets escape quotes - String literal = (String) object; - if (literal.length() > TRIM_VALUES_THRESHOLD) { - literal = literal.substring(0, TRIM_VALUES_THRESHOLD) + "..."; - } - - int curPos = 0; - int endPos = 0; - - while ((endPos = literal.indexOf('\'', curPos)) >= 0) { - buffer.append(literal.substring(curPos, endPos + 1)).append('\''); - curPos = endPos + 1; - } - - if (curPos < literal.length()) - buffer.append(literal.substring(curPos)); - - buffer.append('\''); - } - // handle byte pretty formatting - else if (object instanceof Byte) { - IDUtil.appendFormattedByte(buffer, (Byte) object); - } else if (object instanceof Number) { - // process numeric value (do something smart in the future) - buffer.append(object); - } else if (object instanceof java.sql.Date) { - buffer.append('\'').append(object).append('\''); - } else if (object instanceof java.sql.Time) { - buffer.append('\'').append(object).append('\''); - } else if (object instanceof java.util.Date) { - long time = ((java.util.Date) object).getTime(); - buffer.append('\'').append(new java.sql.Timestamp(time)).append('\''); - } else if (object instanceof java.util.Calendar) { - long time = ((java.util.Calendar) object).getTimeInMillis(); - buffer.append(object.getClass().getName()).append('(').append(new java.sql.Timestamp(time)).append(')'); - } else if (object instanceof Character) { - buffer.append(((Character) object).charValue()); - } else if (object instanceof Boolean) { - buffer.append('\'').append(object).append('\''); - } else if (object instanceof Enum<?>) { - // buffer.append(object.getClass().getName()).append("."); - buffer.append(((Enum<?>) object).name()).append("="); - if (object instanceof ExtendedEnumeration) { - Object value = ((ExtendedEnumeration) object).getDatabaseValue(); - if (value instanceof String) - buffer.append("'"); - buffer.append(value); - if (value instanceof String) - buffer.append("'"); - } else { - buffer.append(((Enum<?>) object).ordinal()); - // FIXME -- this isn't quite right - } - } else if (object instanceof ParameterBinding) { - sqlLiteralForObject(buffer, ((ParameterBinding) object).getValue()); - } else if (object.getClass().isArray()) { - buffer.append("< "); - - int len = Array.getLength(object); - boolean trimming = false; - if (len > TRIM_VALUES_THRESHOLD) { - len = TRIM_VALUES_THRESHOLD; - trimming = true; - } - - for (int i = 0; i < len; i++) { - if (i > 0) { - buffer.append(","); - } - sqlLiteralForObject(buffer, Array.get(object, i)); - } - - if (trimming) { - buffer.append("..."); - } - - buffer.append('>'); - } else { - buffer.append(object.getClass().getName()).append("@").append(System.identityHashCode(object)); - } - } - - @Override - public void log(String message) { - if (message != null) { - logger.info(message); - } - } - - @Deprecated - @Override - public void logConnect(String dataSource) { - if (isLoggable()) { - logger.info("Connecting. JNDI path: " + dataSource); - } - } - - @Deprecated - @Override - public void logConnect(String url, String userName, String password) { - if (isLoggable()) { - StringBuilder buf = new StringBuilder("Opening connection: "); - - // append URL on the same line to make log somewhat grep-friendly - buf.append(url); - buf.append("\n\tLogin: ").append(userName); - buf.append("\n\tPassword: *******"); - - logger.info(buf.toString()); - } - } - - @Deprecated - @Override - public void logPoolCreated(DataSourceInfo dsi) { - if (isLoggable()) { - StringBuilder buf = new StringBuilder("Created connection pool: "); - - if (dsi != null) { - // append URL on the same line to make log somewhat - // grep-friendly - buf.append(dsi.getDataSourceUrl()); - - if (dsi.getAdapterClassName() != null) { - buf.append("\n\tCayenne DbAdapter: ").append(dsi.getAdapterClassName()); - } - - buf.append("\n\tDriver class: ").append(dsi.getJdbcDriver()); - - if (dsi.getMinConnections() >= 0) { - buf.append("\n\tMin. connections in the pool: ").append(dsi.getMinConnections()); - } - if (dsi.getMaxConnections() >= 0) { - buf.append("\n\tMax. connections in the pool: ").append(dsi.getMaxConnections()); - } - } else { - buf.append(" pool information unavailable"); - } - - logger.info(buf.toString()); - } - } - - @Deprecated - @Override - public void logConnectSuccess() { - logger.info("+++ Connecting: SUCCESS."); - } - - @Deprecated - @Override - public void logConnectFailure(Throwable th) { - logger.info("*** Connecting: FAILURE.", th); - } - - @Override - public void logGeneratedKey(DbAttribute attribute, Object value) { - if (isLoggable()) { - String entity = attribute.getEntity().getName(); - String key = attribute.getName(); - - logger.info("Generated PK: " + entity + "." + key + " = " + value); - } - } - - /** - * @deprecated since 4.0 use - * {@link #logQuery(String, ParameterBinding[], long)}. - */ - @Deprecated - @Override - public void logQuery(String queryStr, List<?> params) { - logQuery(queryStr, null, params, -1); - } - - /** - * @deprecated since 4.0 uses old style of parameter logging. - */ - @Deprecated - private void buildLog(StringBuilder buffer, String prefix, String postfix, List<DbAttribute> attributes, - List<?> parameters, boolean isInserting) { - if (parameters != null && parameters.size() > 0) { - Iterator<DbAttribute> attributeIterator = null; - int position = 0; - - if (attributes != null) - attributeIterator = attributes.iterator(); - - for (Object parameter : parameters) { - // If at the beginning, output the prefix, otherwise a - // separator. - if (position++ == 0) - buffer.append(prefix); - else - buffer.append(", "); - - // Find the next attribute and SKIP generated attributes. Only - // skip when logging inserts, though. Should show previously - // generated keys on DELETE, UPDATE, or SELECT. - DbAttribute attribute = null; - while (attributeIterator != null && attributeIterator.hasNext()) { - attribute = attributeIterator.next(); - - if (!isInserting || !attribute.isGenerated()) - break; - } - - buffer.append(position); - - if (attribute != null) { - buffer.append("->"); - buffer.append(attribute.getName()); - } - - buffer.append(":"); - sqlLiteralForObject(buffer, parameter); - } - - buffer.append(postfix); - } - } - - private boolean isInserting(String query) { - if (query == null || query.length() == 0) - return false; - - char firstCharacter = query.charAt(0); - - return firstCharacter == 'I' || firstCharacter == 'i'; - } - - @Override - public void logQuery(String sql, ParameterBinding[] bindings, long translatedIn) { - if (isLoggable()) { - - StringBuilder buffer = new StringBuilder(sql).append(" "); - appendParameters(buffer, "bind", bindings); - - if (buffer.length() > 0) { - logger.info(buffer.toString()); - } - } - } - - @Deprecated - @Override - public void logQuery(String queryStr, List<DbAttribute> attrs, List<?> params, long time) { - if (isLoggable()) { - StringBuilder buffer = new StringBuilder(queryStr); - buildLog(buffer, " [bind: ", "]", attrs, params, isInserting(queryStr)); - - // log preparation time only if it is something significant - if (time > 5) { - buffer.append(" - prepared in ").append(time).append(" ms."); - } - - logger.info(buffer.toString()); - } - } - - /** - * @deprecated since 4.0 - */ - @Deprecated - @Override - public void logQueryParameters(String label, List<DbAttribute> attrs, List<Object> parameters, boolean isInserting) { - String prefix = "[" + label + ": "; - if (isLoggable() && parameters.size() > 0) { - StringBuilder buffer = new StringBuilder(); - buildLog(buffer, prefix, "]", attrs, parameters, isInserting); - logger.info(buffer.toString()); - } - } - - @Override - public void logQueryParameters(String label, ParameterBinding[] bindings) { - - if (isLoggable() && bindings.length > 0) { - - StringBuilder buffer = new StringBuilder(); - appendParameters(buffer, label, bindings); - - if (buffer.length() > 0) { - logger.info(buffer.toString()); - } - } - } - - private void appendParameters(StringBuilder buffer, String label, ParameterBinding[] bindings) { - - int len = bindings.length; - if (len > 0) { - - boolean hasIncluded = false; - - for (int i = 0, j = 1; i < len; i++) { - ParameterBinding b = bindings[i]; - - if (b.isExcluded()) { - continue; - } - - if (hasIncluded) { - buffer.append(", "); - } else { - hasIncluded = true; - buffer.append("[").append(label).append(": "); - } - - - buffer.append(j++); - - if(b instanceof DbAttributeBinding) { - DbAttribute attribute = ((DbAttributeBinding) b).getAttribute(); - if (attribute != null) { - buffer.append("->"); - buffer.append(attribute.getName()); - } - } - - buffer.append(":"); - - if (b.getExtendedType() != null) { - buffer.append(b.getExtendedType().toString(b.getValue())); - } else if(b.getValue() == null) { - buffer.append("NULL"); - } else { - buffer.append(b.getValue().getClass().getName()) - .append("@") - .append(System.identityHashCode(b.getValue())); - } - } - - if (hasIncluded) { - buffer.append("]"); - } - } - } - - @Override - public void logSelectCount(int count, long time) { - logSelectCount(count, time, null); - } - - @Override - public void logSelectCount(int count, long time, String sql) { - - if (isLoggable()) { - StringBuilder buf = new StringBuilder(); - - if (count == 1) { - buf.append("=== returned 1 row."); - } else { - buf.append("=== returned ").append(count).append(" rows."); - } - - if (time >= 0) { - buf.append(" - took ").append(time).append(" ms."); - } - - logger.info(buf.toString()); - } - - if (queryExecutionTimeLoggingThreshold > 0 && time > queryExecutionTimeLoggingThreshold) { - String message = "Query time exceeded threshold (" + time + " ms): "; - logger.warn(message + sql, new CayenneRuntimeException(message + "%s", sql)); - } - } - - @Override - public void logUpdateCount(int count) { - if (isLoggable()) { - if (count < 0) { - logger.info("=== updated ? rows"); - } else { - String countStr = (count == 1) ? "=== updated 1 row." : "=== updated " + count + " rows."; - logger.info(countStr); - } - } - } - - @Override - public void logBeginTransaction(String transactionLabel) { - logger.info("--- " + transactionLabel); - } - - @Override - public void logCommitTransaction(String transactionLabel) { - logger.info("+++ " + transactionLabel); - } - - @Override - public void logRollbackTransaction(String transactionLabel) { - logger.info("*** " + transactionLabel); - } - - @Override - public void logQueryError(Throwable th) { - if (isLoggable()) { - if (th != null) { - th = Util.unwindException(th); - } - - logger.info("*** error.", th); - - if (th instanceof SQLException) { - SQLException sqlException = ((SQLException) th).getNextException(); - while (sqlException != null) { - logger.info("*** nested SQL error.", sqlException); - sqlException = sqlException.getNextException(); - } - } - } - } - - @Override - public boolean isLoggable() { - return logger.isInfoEnabled(); - } -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/a2e0452d/cayenne-server/src/main/java/org/apache/cayenne/log/FormattedCommonsJdbcEventLogger.java ---------------------------------------------------------------------- diff --git a/cayenne-server/src/main/java/org/apache/cayenne/log/FormattedCommonsJdbcEventLogger.java b/cayenne-server/src/main/java/org/apache/cayenne/log/FormattedCommonsJdbcEventLogger.java deleted file mode 100644 index ad08f86..0000000 --- a/cayenne-server/src/main/java/org/apache/cayenne/log/FormattedCommonsJdbcEventLogger.java +++ /dev/null @@ -1,135 +0,0 @@ -/***************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - ****************************************************************/ -package org.apache.cayenne.log; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -import org.apache.cayenne.configuration.RuntimeProperties; -import org.apache.cayenne.di.Inject; -import org.apache.cayenne.map.DbAttribute; - -/** - * A {@link CommonsJdbcEventLogger} extension that provides pretty formatting of the - * logged SQL messages. - * - * @since 3.1 - */ -public class FormattedCommonsJdbcEventLogger extends CommonsJdbcEventLogger { - - private final static Map<String, String> KEYWORDS = new HashMap<>(); - - static { - KEYWORDS.put(" select ", "SELECT"); - KEYWORDS.put(" from ", "FROM"); - KEYWORDS.put(" where ", "WHERE"); - KEYWORDS.put(" order by ", "ORDER BY"); - KEYWORDS.put(" group by ", "GROUP BY"); - KEYWORDS.put(" update ", "UPDATE"); - KEYWORDS.put(" exec ", "EXEC"); - KEYWORDS.put(" set ", "SET"); - KEYWORDS.put(" insert ", "INSERT"); - KEYWORDS.put(" values ", "VALUES"); - KEYWORDS.put(" delete ", "DELETE"); - KEYWORDS.put(" declare ", "DECLARE"); - KEYWORDS.put(" case ", "CASE"); - } - - public FormattedCommonsJdbcEventLogger(@Inject RuntimeProperties runtimeProperties) { - super(runtimeProperties); - } - - private String formatQuery(String sql) { - Map<Integer, String> scanResult = scanQuery(sql); - Iterator<Integer> iter = scanResult.keySet().iterator(); - int nextKeyIdx = (iter.hasNext()) ? iter.next() : -1; - - StringBuffer buffer = new StringBuffer(); - int apixCount = 0; - int bufferPos = 0; - for (int pos = 0; pos < sql.length(); pos++) { - if (sql.charAt(pos) == '\'') { - apixCount++; - if (pos > 0 && sql.charAt(pos - 1) == '\'') - apixCount = apixCount - 2; - } - if (apixCount % 2 != 0) { - continue; - } - if (pos == nextKeyIdx) { - buffer.append(sql.substring(bufferPos, pos + 1)); - buffer.append("\n"); - String shiftedKeyWrd = scanResult.get(nextKeyIdx); - nextKeyIdx = (iter.hasNext()) ? iter.next() : -1; - buffer.append(shiftedKeyWrd); - pos = pos + shiftedKeyWrd.length(); - bufferPos = pos + 1; - } - else if (sql.charAt(pos) == ',' - || sql.charAt(pos) == ')' - || sql.charAt(pos) == '(') { - buffer.append(sql.substring(bufferPos, pos + 1)); - buffer.append("\n\t"); - bufferPos = pos + 1; - } - } - buffer.append(sql.substring(bufferPos)); - buffer.append("\n"); - String result = buffer.toString(); - while (result.contains(" ")) { - result = result.replaceAll(" ", " "); - } - return result; - } - - private Map<Integer, String> scanQuery(String sql) { - Map<Integer, String> result = new TreeMap<Integer, String>(); - String sql2Lower = sql.toLowerCase(); - for (String keyWrd : KEYWORDS.keySet()) { - int prevIdx = 0; - while (true) { - int idx = sql2Lower.indexOf(keyWrd, prevIdx); - if (idx >= 0) { - result.put(idx, KEYWORDS.get(keyWrd)); - prevIdx = idx + 1; - } - else { - break; - } - } - } - return result; - } - - @Override - @Deprecated - public void logQuery( - String queryStr, - List<DbAttribute> attrs, - List<?> params, - long time) { - if (isLoggable()) { - super.logQuery(formatQuery(queryStr), attrs, params, time); - } - } - -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/a2e0452d/cayenne-server/src/main/java/org/apache/cayenne/log/FormattedSlf4jJdbcEventLogger.java ---------------------------------------------------------------------- diff --git a/cayenne-server/src/main/java/org/apache/cayenne/log/FormattedSlf4jJdbcEventLogger.java b/cayenne-server/src/main/java/org/apache/cayenne/log/FormattedSlf4jJdbcEventLogger.java new file mode 100644 index 0000000..7994f58 --- /dev/null +++ b/cayenne-server/src/main/java/org/apache/cayenne/log/FormattedSlf4jJdbcEventLogger.java @@ -0,0 +1,135 @@ +/***************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + ****************************************************************/ +package org.apache.cayenne.log; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + +import org.apache.cayenne.configuration.RuntimeProperties; +import org.apache.cayenne.di.Inject; +import org.apache.cayenne.map.DbAttribute; + +/** + * A {@link Slf4jJdbcEventLogger} extension that provides pretty formatting of the + * logged SQL messages. + * + * @since 3.1 + * @since 4.0 renamed from FormattedCommonsJdbcEventLogger to FormattedSlf4jJdbcEventLogger as part of migration to SLF4J + */ +public class FormattedSlf4jJdbcEventLogger extends Slf4jJdbcEventLogger { + + private final static Map<String, String> KEYWORDS = new HashMap<>(); + + static { + KEYWORDS.put(" select ", "SELECT"); + KEYWORDS.put(" from ", "FROM"); + KEYWORDS.put(" where ", "WHERE"); + KEYWORDS.put(" order by ", "ORDER BY"); + KEYWORDS.put(" group by ", "GROUP BY"); + KEYWORDS.put(" update ", "UPDATE"); + KEYWORDS.put(" exec ", "EXEC"); + KEYWORDS.put(" set ", "SET"); + KEYWORDS.put(" insert ", "INSERT"); + KEYWORDS.put(" values ", "VALUES"); + KEYWORDS.put(" delete ", "DELETE"); + KEYWORDS.put(" declare ", "DECLARE"); + KEYWORDS.put(" case ", "CASE"); + } + + public FormattedSlf4jJdbcEventLogger(@Inject RuntimeProperties runtimeProperties) { + super(runtimeProperties); + } + + private String formatQuery(String sql) { + Map<Integer, String> scanResult = scanQuery(sql); + Iterator<Integer> iter = scanResult.keySet().iterator(); + int nextKeyIdx = (iter.hasNext()) ? iter.next() : -1; + + StringBuilder buffer = new StringBuilder(); + int apixCount = 0; + int bufferPos = 0; + for (int pos = 0; pos < sql.length(); pos++) { + if (sql.charAt(pos) == '\'') { + apixCount++; + if (pos > 0 && sql.charAt(pos - 1) == '\'') + apixCount = apixCount - 2; + } + if (apixCount % 2 != 0) { + continue; + } + if (pos == nextKeyIdx) { + buffer.append(sql.substring(bufferPos, pos + 1)); + buffer.append("\n"); + String shiftedKeyWrd = scanResult.get(nextKeyIdx); + nextKeyIdx = (iter.hasNext()) ? iter.next() : -1; + buffer.append(shiftedKeyWrd); + pos = pos + shiftedKeyWrd.length(); + bufferPos = pos + 1; + } + else if (sql.charAt(pos) == ',' + || sql.charAt(pos) == ')' + || sql.charAt(pos) == '(') { + buffer.append(sql.substring(bufferPos, pos + 1)); + buffer.append("\n\t"); + bufferPos = pos + 1; + } + } + buffer.append(sql.substring(bufferPos)); + buffer.append("\n"); + String result = buffer.toString(); + while (result.contains(" ")) { + result = result.replaceAll(" ", " "); + } + return result; + } + + private Map<Integer, String> scanQuery(String sql) { + Map<Integer, String> result = new TreeMap<>(); + String sql2Lower = sql.toLowerCase(); + for (String keyWrd : KEYWORDS.keySet()) { + int prevIdx = 0; + while (true) { + int idx = sql2Lower.indexOf(keyWrd, prevIdx); + if (idx >= 0) { + result.put(idx, KEYWORDS.get(keyWrd)); + prevIdx = idx + 1; + } else { + break; + } + } + } + return result; + } + + @Override + @Deprecated + public void logQuery( + String queryStr, + List<DbAttribute> attrs, + List<?> params, + long time) { + if (isLoggable()) { + super.logQuery(formatQuery(queryStr), attrs, params, time); + } + } + +} http://git-wip-us.apache.org/repos/asf/cayenne/blob/a2e0452d/cayenne-server/src/main/java/org/apache/cayenne/log/Slf4jJdbcEventLogger.java ---------------------------------------------------------------------- diff --git a/cayenne-server/src/main/java/org/apache/cayenne/log/Slf4jJdbcEventLogger.java b/cayenne-server/src/main/java/org/apache/cayenne/log/Slf4jJdbcEventLogger.java new file mode 100644 index 0000000..9a872ec --- /dev/null +++ b/cayenne-server/src/main/java/org/apache/cayenne/log/Slf4jJdbcEventLogger.java @@ -0,0 +1,482 @@ +/***************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + ****************************************************************/ +package org.apache.cayenne.log; + +import org.apache.cayenne.CayenneRuntimeException; +import org.apache.cayenne.ExtendedEnumeration; +import org.apache.cayenne.access.translator.DbAttributeBinding; +import org.apache.cayenne.access.translator.ParameterBinding; +import org.apache.cayenne.configuration.Constants; +import org.apache.cayenne.configuration.RuntimeProperties; +import org.apache.cayenne.conn.DataSourceInfo; +import org.apache.cayenne.di.Inject; +import org.apache.cayenne.map.DbAttribute; +import org.apache.cayenne.util.IDUtil; +import org.apache.cayenne.util.Util; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.lang.reflect.Array; +import java.sql.SQLException; +import java.util.Iterator; +import java.util.List; + +/** + * A {@link JdbcEventLogger} built on top of slf4j-api logger. + * + * @since 3.1 + * @since 4.0 renamed from CommonsJdbcEventLogger to Slf4jJdbcEventLogger as part of migration to SLF4J + */ +public class Slf4jJdbcEventLogger implements JdbcEventLogger { + + private static final Logger logger = LoggerFactory.getLogger(JdbcEventLogger.class); + + /** + * @deprecated since 4.0 + */ + private static final int TRIM_VALUES_THRESHOLD = 30; + + protected long queryExecutionTimeLoggingThreshold; + + public Slf4jJdbcEventLogger(@Inject RuntimeProperties runtimeProperties) { + this.queryExecutionTimeLoggingThreshold = runtimeProperties.getLong( + Constants.QUERY_EXECUTION_TIME_LOGGING_THRESHOLD_PROPERTY, 0); + } + + // this should go away once we can remove 4.0 deprecated API. The actual logic for printing a value is now + // spread around the ExtendedTypes + @Deprecated + void sqlLiteralForObject(StringBuilder buffer, Object object) { + if (object == null) { + buffer.append("NULL"); + } else if (object instanceof String) { + buffer.append('\''); + // lets escape quotes + String literal = (String) object; + if (literal.length() > TRIM_VALUES_THRESHOLD) { + literal = literal.substring(0, TRIM_VALUES_THRESHOLD) + "..."; + } + + int curPos = 0; + int endPos = 0; + + while ((endPos = literal.indexOf('\'', curPos)) >= 0) { + buffer.append(literal.substring(curPos, endPos + 1)).append('\''); + curPos = endPos + 1; + } + + if (curPos < literal.length()) + buffer.append(literal.substring(curPos)); + + buffer.append('\''); + } + // handle byte pretty formatting + else if (object instanceof Byte) { + IDUtil.appendFormattedByte(buffer, (Byte) object); + } else if (object instanceof Number) { + // process numeric value (do something smart in the future) + buffer.append(object); + } else if (object instanceof java.sql.Date) { + buffer.append('\'').append(object).append('\''); + } else if (object instanceof java.sql.Time) { + buffer.append('\'').append(object).append('\''); + } else if (object instanceof java.util.Date) { + long time = ((java.util.Date) object).getTime(); + buffer.append('\'').append(new java.sql.Timestamp(time)).append('\''); + } else if (object instanceof java.util.Calendar) { + long time = ((java.util.Calendar) object).getTimeInMillis(); + buffer.append(object.getClass().getName()).append('(').append(new java.sql.Timestamp(time)).append(')'); + } else if (object instanceof Character) { + buffer.append(((Character) object).charValue()); + } else if (object instanceof Boolean) { + buffer.append('\'').append(object).append('\''); + } else if (object instanceof Enum<?>) { + // buffer.append(object.getClass().getName()).append("."); + buffer.append(((Enum<?>) object).name()).append("="); + if (object instanceof ExtendedEnumeration) { + Object value = ((ExtendedEnumeration) object).getDatabaseValue(); + if (value instanceof String) + buffer.append("'"); + buffer.append(value); + if (value instanceof String) + buffer.append("'"); + } else { + buffer.append(((Enum<?>) object).ordinal()); + // FIXME -- this isn't quite right + } + } else if (object instanceof ParameterBinding) { + sqlLiteralForObject(buffer, ((ParameterBinding) object).getValue()); + } else if (object.getClass().isArray()) { + buffer.append("< "); + + int len = Array.getLength(object); + boolean trimming = false; + if (len > TRIM_VALUES_THRESHOLD) { + len = TRIM_VALUES_THRESHOLD; + trimming = true; + } + + for (int i = 0; i < len; i++) { + if (i > 0) { + buffer.append(","); + } + sqlLiteralForObject(buffer, Array.get(object, i)); + } + + if (trimming) { + buffer.append("..."); + } + + buffer.append('>'); + } else { + buffer.append(object.getClass().getName()).append("@").append(System.identityHashCode(object)); + } + } + + @Override + public void log(String message) { + if (message != null) { + logger.info(message); + } + } + + @Deprecated + @Override + public void logConnect(String dataSource) { + if (isLoggable()) { + logger.info("Connecting. JNDI path: " + dataSource); + } + } + + @Deprecated + @Override + public void logConnect(String url, String userName, String password) { + if (isLoggable()) { + // append URL on the same line to make log somewhat grep-friendly + logger.info("Opening connection: " + url + "\n\tLogin: " + userName + "\n\tPassword: *******"); + } + } + + @Deprecated + @Override + public void logPoolCreated(DataSourceInfo dsi) { + if (isLoggable()) { + StringBuilder buf = new StringBuilder("Created connection pool: "); + + if (dsi != null) { + // append URL on the same line to make log somewhat + // grep-friendly + buf.append(dsi.getDataSourceUrl()); + + if (dsi.getAdapterClassName() != null) { + buf.append("\n\tCayenne DbAdapter: ").append(dsi.getAdapterClassName()); + } + + buf.append("\n\tDriver class: ").append(dsi.getJdbcDriver()); + + if (dsi.getMinConnections() >= 0) { + buf.append("\n\tMin. connections in the pool: ").append(dsi.getMinConnections()); + } + if (dsi.getMaxConnections() >= 0) { + buf.append("\n\tMax. connections in the pool: ").append(dsi.getMaxConnections()); + } + } else { + buf.append(" pool information unavailable"); + } + + logger.info(buf.toString()); + } + } + + @Deprecated + @Override + public void logConnectSuccess() { + logger.info("+++ Connecting: SUCCESS."); + } + + @Deprecated + @Override + public void logConnectFailure(Throwable th) { + logger.info("*** Connecting: FAILURE.", th); + } + + @Override + public void logGeneratedKey(DbAttribute attribute, Object value) { + if (isLoggable()) { + String entity = attribute.getEntity().getName(); + logger.info("Generated PK: " + entity + "." + attribute.getName() + " = " + value); + } + } + + /** + * @deprecated since 4.0 use + * {@link #logQuery(String, ParameterBinding[], long)}. + */ + @Deprecated + @Override + public void logQuery(String queryStr, List<?> params) { + logQuery(queryStr, null, params, -1); + } + + /** + * @deprecated since 4.0 uses old style of parameter logging. + */ + @Deprecated + private void buildLog(StringBuilder buffer, String prefix, String postfix, List<DbAttribute> attributes, + List<?> parameters, boolean isInserting) { + if (parameters != null && parameters.size() > 0) { + Iterator<DbAttribute> attributeIterator = null; + int position = 0; + + if (attributes != null) + attributeIterator = attributes.iterator(); + + for (Object parameter : parameters) { + // If at the beginning, output the prefix, otherwise a + // separator. + if (position++ == 0) + buffer.append(prefix); + else + buffer.append(", "); + + // Find the next attribute and SKIP generated attributes. Only + // skip when logging inserts, though. Should show previously + // generated keys on DELETE, UPDATE, or SELECT. + DbAttribute attribute = null; + while (attributeIterator != null && attributeIterator.hasNext()) { + attribute = attributeIterator.next(); + + if (!isInserting || !attribute.isGenerated()) + break; + } + + buffer.append(position); + + if (attribute != null) { + buffer.append("->"); + buffer.append(attribute.getName()); + } + + buffer.append(":"); + sqlLiteralForObject(buffer, parameter); + } + + buffer.append(postfix); + } + } + + private boolean isInserting(String query) { + if (query == null || query.length() == 0) + return false; + + char firstCharacter = query.charAt(0); + + return firstCharacter == 'I' || firstCharacter == 'i'; + } + + @Override + public void logQuery(String sql, ParameterBinding[] bindings, long translatedIn) { + if (isLoggable()) { + + StringBuilder buffer = new StringBuilder(sql).append(" "); + appendParameters(buffer, "bind", bindings); + + if (buffer.length() > 0) { + logger.info(buffer.toString()); + } + } + } + + @Deprecated + @Override + public void logQuery(String queryStr, List<DbAttribute> attrs, List<?> params, long time) { + if (isLoggable()) { + StringBuilder buffer = new StringBuilder(queryStr); + buildLog(buffer, " [bind: ", "]", attrs, params, isInserting(queryStr)); + + // log preparation time only if it is something significant + if (time > 5) { + buffer.append(" - prepared in ").append(time).append(" ms."); + } + + logger.info(buffer.toString()); + } + } + + /** + * @deprecated since 4.0 + */ + @Deprecated + @Override + public void logQueryParameters(String label, List<DbAttribute> attrs, List<Object> parameters, boolean isInserting) { + String prefix = "[" + label + ": "; + if (isLoggable() && parameters.size() > 0) { + StringBuilder buffer = new StringBuilder(); + buildLog(buffer, prefix, "]", attrs, parameters, isInserting); + logger.info(buffer.toString()); + } + } + + @Override + public void logQueryParameters(String label, ParameterBinding[] bindings) { + + if (isLoggable() && bindings.length > 0) { + + StringBuilder buffer = new StringBuilder(); + appendParameters(buffer, label, bindings); + + if (buffer.length() > 0) { + logger.info(buffer.toString()); + } + } + } + + @SuppressWarnings("unchecked") + private void appendParameters(StringBuilder buffer, String label, ParameterBinding[] bindings) { + + int len = bindings.length; + if (len > 0) { + + boolean hasIncluded = false; + + for (int i = 0, j = 1; i < len; i++) { + ParameterBinding b = bindings[i]; + + if (b.isExcluded()) { + continue; + } + + if (hasIncluded) { + buffer.append(", "); + } else { + hasIncluded = true; + buffer.append("[").append(label).append(": "); + } + + + buffer.append(j++); + + if(b instanceof DbAttributeBinding) { + DbAttribute attribute = ((DbAttributeBinding) b).getAttribute(); + if (attribute != null) { + buffer.append("->"); + buffer.append(attribute.getName()); + } + } + + buffer.append(":"); + + if (b.getExtendedType() != null) { + buffer.append(b.getExtendedType().toString(b.getValue())); + } else if(b.getValue() == null) { + buffer.append("NULL"); + } else { + buffer.append(b.getValue().getClass().getName()) + .append("@") + .append(System.identityHashCode(b.getValue())); + } + } + + if (hasIncluded) { + buffer.append("]"); + } + } + } + + @Override + public void logSelectCount(int count, long time) { + logSelectCount(count, time, null); + } + + @Override + public void logSelectCount(int count, long time, String sql) { + + if (isLoggable()) { + StringBuilder buf = new StringBuilder(); + + if (count == 1) { + buf.append("=== returned 1 row."); + } else { + buf.append("=== returned ").append(count).append(" rows."); + } + + if (time >= 0) { + buf.append(" - took ").append(time).append(" ms."); + } + + logger.info(buf.toString()); + } + + if (queryExecutionTimeLoggingThreshold > 0 && time > queryExecutionTimeLoggingThreshold) { + String message = "Query time exceeded threshold (" + time + " ms): "; + logger.warn(message + sql, new CayenneRuntimeException(message + "%s", sql)); + } + } + + @Override + public void logUpdateCount(int count) { + if (isLoggable()) { + if (count < 0) { + logger.info("=== updated ? rows"); + } else { + String countStr = (count == 1) ? "=== updated 1 row." : "=== updated " + count + " rows."; + logger.info(countStr); + } + } + } + + @Override + public void logBeginTransaction(String transactionLabel) { + logger.info("--- " + transactionLabel); + } + + @Override + public void logCommitTransaction(String transactionLabel) { + logger.info("+++ " + transactionLabel); + } + + @Override + public void logRollbackTransaction(String transactionLabel) { + logger.info("*** " + transactionLabel); + } + + @Override + public void logQueryError(Throwable th) { + if (isLoggable()) { + if (th != null) { + th = Util.unwindException(th); + } + + logger.info("*** error.", th); + + if (th instanceof SQLException) { + SQLException sqlException = ((SQLException) th).getNextException(); + while (sqlException != null) { + logger.info("*** nested SQL error.", sqlException); + sqlException = sqlException.getNextException(); + } + } + } + } + + @Override + public boolean isLoggable() { + return logger.isInfoEnabled(); + } +} http://git-wip-us.apache.org/repos/asf/cayenne/blob/a2e0452d/cayenne-server/src/test/java/org/apache/cayenne/access/DefaultDataRowStoreFactoryIT.java ---------------------------------------------------------------------- diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DefaultDataRowStoreFactoryIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DefaultDataRowStoreFactoryIT.java index 7aeb303..c46c04f 100644 --- a/cayenne-server/src/test/java/org/apache/cayenne/access/DefaultDataRowStoreFactoryIT.java +++ b/cayenne-server/src/test/java/org/apache/cayenne/access/DefaultDataRowStoreFactoryIT.java @@ -33,7 +33,7 @@ import org.apache.cayenne.event.NoopEventBridgeProvider; import org.apache.cayenne.event.EventManager; import org.apache.cayenne.event.MockEventBridge; import org.apache.cayenne.event.MockEventBridgeProvider; -import org.apache.cayenne.log.CommonsJdbcEventLogger; +import org.apache.cayenne.log.Slf4jJdbcEventLogger; import org.apache.cayenne.log.JdbcEventLogger; import org.apache.cayenne.tx.DefaultTransactionFactory; import org.apache.cayenne.tx.DefaultTransactionManager; @@ -71,7 +71,7 @@ public class DefaultDataRowStoreFactoryIT extends ServerCase { binder.bind(EventManager.class).toInstance(EVENT_MANAGER); binder.bind(TransactionManager.class).to(DefaultTransactionManager.class); binder.bind(TransactionFactory.class).to(DefaultTransactionFactory.class); - binder.bind(JdbcEventLogger.class).to(CommonsJdbcEventLogger.class); + binder.bind(JdbcEventLogger.class).to(Slf4jJdbcEventLogger.class); binder.bind(RuntimeProperties.class).to(DefaultRuntimeProperties.class); binder.bind(EventBridge.class).toProvider(NoopEventBridgeProvider.class); binder.bind(DataRowStoreFactory.class).to(DefaultDataRowStoreFactory.class); @@ -98,7 +98,7 @@ public class DefaultDataRowStoreFactoryIT extends ServerCase { binder.bind(EventManager.class).toInstance(EVENT_MANAGER); binder.bind(TransactionManager.class).to(DefaultTransactionManager.class); binder.bind(TransactionFactory.class).to(DefaultTransactionFactory.class); - binder.bind(JdbcEventLogger.class).to(CommonsJdbcEventLogger.class); + binder.bind(JdbcEventLogger.class).to(Slf4jJdbcEventLogger.class); binder.bind(RuntimeProperties.class).to(DefaultRuntimeProperties.class); binder.bind(EventBridge.class).toProvider(MockEventBridgeProvider.class); binder.bind(DataRowStoreFactory.class).to(DefaultDataRowStoreFactory.class); http://git-wip-us.apache.org/repos/asf/cayenne/blob/a2e0452d/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/DataContextFactoryTest.java ---------------------------------------------------------------------- diff --git a/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/DataContextFactoryTest.java b/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/DataContextFactoryTest.java index 3eca368..cde7125 100644 --- a/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/DataContextFactoryTest.java +++ b/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/DataContextFactoryTest.java @@ -38,7 +38,7 @@ import org.apache.cayenne.event.NoopEventBridgeProvider; import org.apache.cayenne.event.EventBridge; import org.apache.cayenne.event.EventManager; import org.apache.cayenne.event.MockEventManager; -import org.apache.cayenne.log.CommonsJdbcEventLogger; +import org.apache.cayenne.log.Slf4jJdbcEventLogger; import org.apache.cayenne.log.JdbcEventLogger; import org.apache.cayenne.tx.DefaultTransactionFactory; import org.apache.cayenne.tx.DefaultTransactionManager; @@ -67,7 +67,7 @@ public class DataContextFactoryTest { Module testModule = new Module() { public void configure(Binder binder) { - binder.bind(JdbcEventLogger.class).to(CommonsJdbcEventLogger.class); + binder.bind(JdbcEventLogger.class).to(Slf4jJdbcEventLogger.class); binder.bind(DataDomain.class).toInstance(domain); binder.bind(EventManager.class).toInstance(eventManager); binder.bind(QueryCache.class).toInstance(new MapQueryCache(5)); @@ -107,7 +107,7 @@ public class DataContextFactoryTest { Module testModule = new Module() { public void configure(Binder binder) { - binder.bind(JdbcEventLogger.class).to(CommonsJdbcEventLogger.class); + binder.bind(JdbcEventLogger.class).to(Slf4jJdbcEventLogger.class); binder.bind(DataDomain.class).toInstance(domain); binder.bind(EventManager.class).toInstance(eventManager); binder.bind(QueryCache.class).toInstance(new MapQueryCache(5)); http://git-wip-us.apache.org/repos/asf/cayenne/blob/a2e0452d/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/DataDomainProviderTest.java ---------------------------------------------------------------------- diff --git a/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/DataDomainProviderTest.java b/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/DataDomainProviderTest.java index 8a30ae8..14cc126 100644 --- a/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/DataDomainProviderTest.java +++ b/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/DataDomainProviderTest.java @@ -81,7 +81,7 @@ import org.apache.cayenne.event.EventBridge; import org.apache.cayenne.event.NoopEventBridgeProvider; import org.apache.cayenne.event.EventManager; import org.apache.cayenne.event.MockEventManager; -import org.apache.cayenne.log.CommonsJdbcEventLogger; +import org.apache.cayenne.log.Slf4jJdbcEventLogger; import org.apache.cayenne.log.JdbcEventLogger; import org.apache.cayenne.map.DataMap; import org.apache.cayenne.map.EntitySorter; @@ -199,7 +199,7 @@ public class DataDomainProviderTest { binder.bind(SelectTranslatorFactory.class).to(DefaultSelectTranslatorFactory.class); binder.bind(DataSourceFactory.class).toInstance(new MockDataSourceFactory()); - binder.bind(JdbcEventLogger.class).to(CommonsJdbcEventLogger.class); + binder.bind(JdbcEventLogger.class).to(Slf4jJdbcEventLogger.class); binder.bind(QueryCache.class).toInstance(mock(QueryCache.class)); binder.bind(RowReaderFactory.class).toInstance(mock(RowReaderFactory.class)); binder.bind(DataNodeFactory.class).to(DefaultDataNodeFactory.class); http://git-wip-us.apache.org/repos/asf/cayenne/blob/a2e0452d/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/DefaultDataSourceFactoryLoaderTest.java ---------------------------------------------------------------------- diff --git a/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/DefaultDataSourceFactoryLoaderTest.java b/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/DefaultDataSourceFactoryLoaderTest.java index 5135cb5..b592753 100644 --- a/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/DefaultDataSourceFactoryLoaderTest.java +++ b/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/DefaultDataSourceFactoryLoaderTest.java @@ -33,7 +33,7 @@ import org.apache.cayenne.di.Key; import org.apache.cayenne.di.Module; import org.apache.cayenne.di.spi.DefaultAdhocObjectFactory; import org.apache.cayenne.di.spi.DefaultClassLoaderManager; -import org.apache.cayenne.log.CommonsJdbcEventLogger; +import org.apache.cayenne.log.Slf4jJdbcEventLogger; import org.apache.cayenne.log.JdbcEventLogger; import org.apache.cayenne.resource.ResourceLocator; import org.apache.cayenne.resource.mock.MockResourceLocator; @@ -62,7 +62,7 @@ public class DefaultDataSourceFactoryLoaderTest { binder.bind(ResourceLocator.class).to(MockResourceLocator.class); binder.bind(Key.get(ResourceLocator.class, Constants.SERVER_RESOURCE_LOCATOR)).to(MockResourceLocator.class); binder.bind(RuntimeProperties.class).toInstance(mock(RuntimeProperties.class)); - binder.bind(JdbcEventLogger.class).to(CommonsJdbcEventLogger.class); + binder.bind(JdbcEventLogger.class).to(Slf4jJdbcEventLogger.class); } }; @@ -123,7 +123,7 @@ public class DefaultDataSourceFactoryLoaderTest { binder.bind(ResourceLocator.class).to(MockResourceLocator.class); binder.bind(Key.get(ResourceLocator.class, Constants.SERVER_RESOURCE_LOCATOR)).to(MockResourceLocator.class); binder.bind(RuntimeProperties.class).toInstance(properties); - binder.bind(JdbcEventLogger.class).to(CommonsJdbcEventLogger.class); + binder.bind(JdbcEventLogger.class).to(Slf4jJdbcEventLogger.class); } }; http://git-wip-us.apache.org/repos/asf/cayenne/blob/a2e0452d/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/DefaultDbAdapterFactoryTest.java ---------------------------------------------------------------------- diff --git a/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/DefaultDbAdapterFactoryTest.java b/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/DefaultDbAdapterFactoryTest.java index a4709c1..b5ed0c4 100644 --- a/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/DefaultDbAdapterFactoryTest.java +++ b/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/DefaultDbAdapterFactoryTest.java @@ -39,7 +39,7 @@ import org.apache.cayenne.di.Key; import org.apache.cayenne.di.Module; import org.apache.cayenne.di.spi.DefaultAdhocObjectFactory; import org.apache.cayenne.di.spi.DefaultClassLoaderManager; -import org.apache.cayenne.log.CommonsJdbcEventLogger; +import org.apache.cayenne.log.Slf4jJdbcEventLogger; import org.apache.cayenne.log.JdbcEventLogger; import org.apache.cayenne.map.DbEntity; import org.apache.cayenne.resource.ClassLoaderResourceLocator; @@ -84,7 +84,7 @@ public class DefaultDbAdapterFactoryTest { public void configure(Binder binder) { ServerModule.contributeProperties(binder); - binder.bind(JdbcEventLogger.class).to(CommonsJdbcEventLogger.class); + binder.bind(JdbcEventLogger.class).to(Slf4jJdbcEventLogger.class); binder.bind(ClassLoaderManager.class).to(DefaultClassLoaderManager.class); binder.bind(AdhocObjectFactory.class).to(DefaultAdhocObjectFactory.class); binder.bind(RuntimeProperties.class).to(DefaultRuntimeProperties.class); @@ -114,7 +114,7 @@ public class DefaultDbAdapterFactoryTest { ServerModule.contributeUserTypes(binder); ServerModule.contributeTypeFactories(binder); - binder.bind(JdbcEventLogger.class).to(CommonsJdbcEventLogger.class); + binder.bind(JdbcEventLogger.class).to(Slf4jJdbcEventLogger.class); binder.bind(ClassLoaderManager.class).to(DefaultClassLoaderManager.class); binder.bind(AdhocObjectFactory.class).to(DefaultAdhocObjectFactory.class); binder.bind(ResourceLocator.class).to(ClassLoaderResourceLocator.class); @@ -154,7 +154,7 @@ public class DefaultDbAdapterFactoryTest { ServerModule.contributeUserTypes(binder); ServerModule.contributeTypeFactories(binder); - binder.bind(JdbcEventLogger.class).to(CommonsJdbcEventLogger.class); + binder.bind(JdbcEventLogger.class).to(Slf4jJdbcEventLogger.class); binder.bind(ClassLoaderManager.class).to(DefaultClassLoaderManager.class); binder.bind(AdhocObjectFactory.class).to(DefaultAdhocObjectFactory.class); binder.bind(ResourceLocator.class).to(ClassLoaderResourceLocator.class); @@ -202,7 +202,7 @@ public class DefaultDbAdapterFactoryTest { ServerModule.contributeProperties(binder); binder.bind(ClassLoaderManager.class).to(DefaultClassLoaderManager.class); - binder.bind(JdbcEventLogger.class).to(CommonsJdbcEventLogger.class); + binder.bind(JdbcEventLogger.class).to(Slf4jJdbcEventLogger.class); binder.bind(AdhocObjectFactory.class).to(DefaultAdhocObjectFactory.class); binder.bind(RuntimeProperties.class).to(DefaultRuntimeProperties.class); } http://git-wip-us.apache.org/repos/asf/cayenne/blob/a2e0452d/cayenne-server/src/test/java/org/apache/cayenne/dba/PerAdapterProviderTest.java ---------------------------------------------------------------------- diff --git a/cayenne-server/src/test/java/org/apache/cayenne/dba/PerAdapterProviderTest.java b/cayenne-server/src/test/java/org/apache/cayenne/dba/PerAdapterProviderTest.java index 505aefb..802e4d3 100644 --- a/cayenne-server/src/test/java/org/apache/cayenne/dba/PerAdapterProviderTest.java +++ b/cayenne-server/src/test/java/org/apache/cayenne/dba/PerAdapterProviderTest.java @@ -27,7 +27,7 @@ import org.apache.cayenne.dba.oracle.OracleAdapter; import org.apache.cayenne.di.DIRuntimeException; import org.apache.cayenne.di.Provider; import org.apache.cayenne.di.spi.DefaultClassLoaderManager; -import org.apache.cayenne.log.CommonsJdbcEventLogger; +import org.apache.cayenne.log.Slf4jJdbcEventLogger; import org.apache.cayenne.resource.ClassLoaderResourceLocator; import org.apache.cayenne.resource.ResourceLocator; import org.junit.Before; @@ -69,7 +69,7 @@ public class PerAdapterProviderTest { public DbAdapter get() throws DIRuntimeException { return derbyAdapter; } - }, new CommonsJdbcEventLogger(runtimeProperties)); + }, new Slf4jJdbcEventLogger(runtimeProperties)); } @Test http://git-wip-us.apache.org/repos/asf/cayenne/blob/a2e0452d/cayenne-server/src/test/java/org/apache/cayenne/log/CommonsJdbcEventLoggerTest.java ---------------------------------------------------------------------- diff --git a/cayenne-server/src/test/java/org/apache/cayenne/log/CommonsJdbcEventLoggerTest.java b/cayenne-server/src/test/java/org/apache/cayenne/log/CommonsJdbcEventLoggerTest.java deleted file mode 100644 index 7e421df..0000000 --- a/cayenne-server/src/test/java/org/apache/cayenne/log/CommonsJdbcEventLoggerTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/***************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - ****************************************************************/ -package org.apache.cayenne.log; - -import org.apache.cayenne.configuration.DefaultRuntimeProperties; -import org.apache.cayenne.util.IDUtil; -import org.junit.Test; - -import java.util.Collections; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -public class CommonsJdbcEventLoggerTest { - - @Test - public void testSqlLiteralForObject() throws Exception { - StringBuilder buf = new StringBuilder(); - - // test unsupported type - new CommonsJdbcEventLogger(new DefaultRuntimeProperties(Collections.EMPTY_MAP)).sqlLiteralForObject(buf, new Object()); - assertTrue(buf.length() > 0); - } - - @Test - public void testAppendFormattedByte() throws Exception { - assertFormatting((byte) 0, "00"); - assertFormatting((byte) 1, "01"); - assertFormatting((byte) 10, "0A"); - assertFormatting(Byte.MAX_VALUE, "7F"); - assertFormatting((byte) -1, "FF"); - assertFormatting(Byte.MIN_VALUE, "80"); - } - - private void assertFormatting(byte b, String formatted) throws Exception { - StringBuffer buffer = new StringBuffer(); - IDUtil.appendFormattedByte(buffer, b); - assertEquals(formatted, buffer.toString()); - } -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/a2e0452d/cayenne-server/src/test/java/org/apache/cayenne/log/Slf4jJdbcEventLoggerTest.java ---------------------------------------------------------------------- diff --git a/cayenne-server/src/test/java/org/apache/cayenne/log/Slf4jJdbcEventLoggerTest.java b/cayenne-server/src/test/java/org/apache/cayenne/log/Slf4jJdbcEventLoggerTest.java new file mode 100644 index 0000000..5074ee4 --- /dev/null +++ b/cayenne-server/src/test/java/org/apache/cayenne/log/Slf4jJdbcEventLoggerTest.java @@ -0,0 +1,57 @@ +/***************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + ****************************************************************/ +package org.apache.cayenne.log; + +import org.apache.cayenne.configuration.DefaultRuntimeProperties; +import org.apache.cayenne.util.IDUtil; +import org.junit.Test; + +import java.util.Collections; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +public class Slf4jJdbcEventLoggerTest { + + @Test + public void testSqlLiteralForObject() throws Exception { + StringBuilder buf = new StringBuilder(); + + // test unsupported type + new Slf4jJdbcEventLogger(new DefaultRuntimeProperties(Collections.<String, String>emptyMap())) + .sqlLiteralForObject(buf, new Object()); + assertTrue(buf.length() > 0); + } + + @Test + public void testAppendFormattedByte() throws Exception { + assertFormatting((byte) 0, "00"); + assertFormatting((byte) 1, "01"); + assertFormatting((byte) 10, "0A"); + assertFormatting(Byte.MAX_VALUE, "7F"); + assertFormatting((byte) -1, "FF"); + assertFormatting(Byte.MIN_VALUE, "80"); + } + + private void assertFormatting(byte b, String formatted) throws Exception { + StringBuffer buffer = new StringBuffer(); + IDUtil.appendFormattedByte(buffer, b); + assertEquals(formatted, buffer.toString()); + } +} http://git-wip-us.apache.org/repos/asf/cayenne/blob/a2e0452d/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseModule.java ---------------------------------------------------------------------- diff --git a/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseModule.java b/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseModule.java index 7e1f2dd..ae4e01b 100644 --- a/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseModule.java +++ b/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseModule.java @@ -82,7 +82,7 @@ import org.apache.cayenne.di.Module; import org.apache.cayenne.di.spi.DefaultAdhocObjectFactory; import org.apache.cayenne.di.spi.DefaultClassLoaderManager; import org.apache.cayenne.di.spi.DefaultScope; -import org.apache.cayenne.log.CommonsJdbcEventLogger; +import org.apache.cayenne.log.Slf4jJdbcEventLogger; import org.apache.cayenne.log.JdbcEventLogger; import org.apache.cayenne.map.EntityResolver; import org.apache.cayenne.resource.ClassLoaderResourceLocator; @@ -171,7 +171,7 @@ public class ServerCaseModule implements Module { binder.bind(ValueObjectTypeRegistry.class).to(DefaultValueObjectTypeRegistry.class); binder.bind(SchemaBuilder.class).to(SchemaBuilder.class); - binder.bind(JdbcEventLogger.class).to(CommonsJdbcEventLogger.class); + binder.bind(JdbcEventLogger.class).to(Slf4jJdbcEventLogger.class); binder.bind(RuntimeProperties.class).to(DefaultRuntimeProperties.class); binder.bind(ObjectMapRetainStrategy.class).to(DefaultObjectMapRetainStrategy.class); http://git-wip-us.apache.org/repos/asf/cayenne/blob/a2e0452d/docs/doc/src/main/resources/UPGRADE.txt ---------------------------------------------------------------------- diff --git a/docs/doc/src/main/resources/UPGRADE.txt b/docs/doc/src/main/resources/UPGRADE.txt index 0418ccb..4cd9d98 100644 --- a/docs/doc/src/main/resources/UPGRADE.txt +++ b/docs/doc/src/main/resources/UPGRADE.txt @@ -17,6 +17,10 @@ UPGRADING TO 4.0.M6 - remove commons-logging dependency if you have it - add to your project slf4j-jcl dependency + As a part of this change classes CommonsJdbcEventLogger and FormattedCommonsJdbcEventLogger + were renamed to Slf4jJdbcEventLogger and FormattedSlf4jJdbcEventLogger respectively. + Internally they are using now org.apache.cayenne.log.JdbcEventLogger interface as a logger name. + * Per CAY-2278 The org.apache.cayenne.lifecycle.audit package (with the exception of AuditableChild annotation) and the org.apache.cayenne.lifecycle.changeset package where deprecated. Weighted graph sorter moved to cayenne-server into org.apache.cayenne.ashwood package. http://git-wip-us.apache.org/repos/asf/cayenne/blob/a2e0452d/docs/docbook/cayenne-guide/src/docbkx/customizing-cayenne-runtime.xml ---------------------------------------------------------------------- diff --git a/docs/docbook/cayenne-guide/src/docbkx/customizing-cayenne-runtime.xml b/docs/docbook/cayenne-guide/src/docbkx/customizing-cayenne-runtime.xml index a26629d..3d3feb6 100644 --- a/docs/docbook/cayenne-guide/src/docbkx/customizing-cayenne-runtime.xml +++ b/docs/docbook/cayenne-guide/src/docbkx/customizing-cayenne-runtime.xml @@ -381,9 +381,9 @@ ServerRuntime runtime = ServerRuntime.builder() <para><code>org.apache.cayenne.log.JdbcEventLogger</code> is the service that defines logging API for Cayenne internals. It provides facilities for logging queries, commits, transactions, etc. The default implementation is - <code>org.apache.cayenne.log.CommonsJdbcEventLogger</code> that performs logging + <code>org.apache.cayenne.log.Slf4jJdbcEventLogger</code> that performs logging via slf4j-api library. Cayenne library includes another potentially useful - logger - <code>org.apache.cayenne.log.FormattedCommonsJdbcEventLogger</code> that + logger - <code>org.apache.cayenne.log.FormattedSlf4jJdbcEventLogger</code> that produces formatted multiline SQL output that can be easier to read.</para> </section> <section xml:id="datasourcefactory"> http://git-wip-us.apache.org/repos/asf/cayenne/blob/a2e0452d/eventbridges/cayenne-jgroups/src/test/java/org/apache/cayenne/event/JavaGroupsBridgeProviderTest.java ---------------------------------------------------------------------- diff --git a/eventbridges/cayenne-jgroups/src/test/java/org/apache/cayenne/event/JavaGroupsBridgeProviderTest.java b/eventbridges/cayenne-jgroups/src/test/java/org/apache/cayenne/event/JavaGroupsBridgeProviderTest.java index 5d860f3..7f47201 100644 --- a/eventbridges/cayenne-jgroups/src/test/java/org/apache/cayenne/event/JavaGroupsBridgeProviderTest.java +++ b/eventbridges/cayenne-jgroups/src/test/java/org/apache/cayenne/event/JavaGroupsBridgeProviderTest.java @@ -27,7 +27,7 @@ import org.apache.cayenne.di.Binder; import org.apache.cayenne.di.DIBootstrap; import org.apache.cayenne.di.Injector; import org.apache.cayenne.di.Module; -import org.apache.cayenne.log.CommonsJdbcEventLogger; +import org.apache.cayenne.log.Slf4jJdbcEventLogger; import org.apache.cayenne.log.JdbcEventLogger; import org.apache.cayenne.tx.DefaultTransactionFactory; import org.apache.cayenne.tx.DefaultTransactionManager; @@ -92,7 +92,7 @@ public class JavaGroupsBridgeProviderTest { binder.bind(EventManager.class).toInstance(EVENT_MANAGER); binder.bind(TransactionManager.class).to(DefaultTransactionManager.class); binder.bind(TransactionFactory.class).to(DefaultTransactionFactory.class); - binder.bind(JdbcEventLogger.class).to(CommonsJdbcEventLogger.class); + binder.bind(JdbcEventLogger.class).to(Slf4jJdbcEventLogger.class); binder.bind(RuntimeProperties.class).to(DefaultRuntimeProperties.class); } } http://git-wip-us.apache.org/repos/asf/cayenne/blob/a2e0452d/eventbridges/cayenne-jms/src/test/java/org/apache/cayenne/event/JMSBridgeProviderTest.java ---------------------------------------------------------------------- diff --git a/eventbridges/cayenne-jms/src/test/java/org/apache/cayenne/event/JMSBridgeProviderTest.java b/eventbridges/cayenne-jms/src/test/java/org/apache/cayenne/event/JMSBridgeProviderTest.java index c822644..a96e349 100644 --- a/eventbridges/cayenne-jms/src/test/java/org/apache/cayenne/event/JMSBridgeProviderTest.java +++ b/eventbridges/cayenne-jms/src/test/java/org/apache/cayenne/event/JMSBridgeProviderTest.java @@ -27,7 +27,7 @@ import org.apache.cayenne.di.Binder; import org.apache.cayenne.di.DIBootstrap; import org.apache.cayenne.di.Injector; import org.apache.cayenne.di.Module; -import org.apache.cayenne.log.CommonsJdbcEventLogger; +import org.apache.cayenne.log.Slf4jJdbcEventLogger; import org.apache.cayenne.log.JdbcEventLogger; import org.apache.cayenne.tx.DefaultTransactionFactory; import org.apache.cayenne.tx.DefaultTransactionManager; @@ -85,7 +85,7 @@ public class JMSBridgeProviderTest { binder.bind(EventManager.class).toInstance(EVENT_MANAGER); binder.bind(TransactionManager.class).to(DefaultTransactionManager.class); binder.bind(TransactionFactory.class).to(DefaultTransactionFactory.class); - binder.bind(JdbcEventLogger.class).to(CommonsJdbcEventLogger.class); + binder.bind(JdbcEventLogger.class).to(Slf4jJdbcEventLogger.class); binder.bind(RuntimeProperties.class).to(DefaultRuntimeProperties.class); } } http://git-wip-us.apache.org/repos/asf/cayenne/blob/a2e0452d/eventbridges/cayenne-xmpp/src/test/java/org/apache/cayenne/event/XMPPBridgeProviderTest.java ---------------------------------------------------------------------- diff --git a/eventbridges/cayenne-xmpp/src/test/java/org/apache/cayenne/event/XMPPBridgeProviderTest.java b/eventbridges/cayenne-xmpp/src/test/java/org/apache/cayenne/event/XMPPBridgeProviderTest.java index a859677..93b2c0f 100644 --- a/eventbridges/cayenne-xmpp/src/test/java/org/apache/cayenne/event/XMPPBridgeProviderTest.java +++ b/eventbridges/cayenne-xmpp/src/test/java/org/apache/cayenne/event/XMPPBridgeProviderTest.java @@ -27,7 +27,7 @@ import org.apache.cayenne.di.Binder; import org.apache.cayenne.di.DIBootstrap; import org.apache.cayenne.di.Injector; import org.apache.cayenne.di.Module; -import org.apache.cayenne.log.CommonsJdbcEventLogger; +import org.apache.cayenne.log.Slf4jJdbcEventLogger; import org.apache.cayenne.log.JdbcEventLogger; import org.apache.cayenne.tx.DefaultTransactionFactory; import org.apache.cayenne.tx.DefaultTransactionManager; @@ -100,7 +100,7 @@ public class XMPPBridgeProviderTest { binder.bind(EventManager.class).toInstance(EVENT_MANAGER); binder.bind(TransactionManager.class).to(DefaultTransactionManager.class); binder.bind(TransactionFactory.class).to(DefaultTransactionFactory.class); - binder.bind(JdbcEventLogger.class).to(CommonsJdbcEventLogger.class); + binder.bind(JdbcEventLogger.class).to(Slf4jJdbcEventLogger.class); binder.bind(RuntimeProperties.class).to(DefaultRuntimeProperties.class); } }