You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2018/01/13 05:11:10 UTC
logging-log4j2 git commit: [LOG4J2-2185] Add a simple JDBC
DriverManager-based ConnectionSource that uses JDBC's
DriverManager#getConnection(String, String,
String). Forgot @PluginBuilderFactory.
Repository: logging-log4j2
Updated Branches:
refs/heads/master 2eb136ba0 -> 3c584bedb
[LOG4J2-2185] Add a simple JDBC DriverManager-based ConnectionSource
that uses JDBC's DriverManager#getConnection(String, String, String).
Forgot @PluginBuilderFactory.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/3c584bed
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/3c584bed
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/3c584bed
Branch: refs/heads/master
Commit: 3c584bedba28d11e7c6372896e9f5bdfabfd4886
Parents: 2eb136b
Author: Gary Gregory <gg...@apache.org>
Authored: Fri Jan 12 22:11:06 2018 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Fri Jan 12 22:11:06 2018 -0700
----------------------------------------------------------------------
.../db/jdbc/DriverManagerConnectionSource.java | 22 +++++++++++++-------
1 file changed, 14 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3c584bed/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/jdbc/DriverManagerConnectionSource.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/jdbc/DriverManagerConnectionSource.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/jdbc/DriverManagerConnectionSource.java
index 2be6f68..60bdc09 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/jdbc/DriverManagerConnectionSource.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/jdbc/DriverManagerConnectionSource.java
@@ -26,6 +26,7 @@ import org.apache.logging.log4j.core.Core;
import org.apache.logging.log4j.core.config.Property;
import org.apache.logging.log4j.core.config.plugins.Plugin;
import org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute;
+import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
import org.apache.logging.log4j.core.config.plugins.PluginElement;
import org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
import org.apache.logging.log4j.status.StatusLogger;
@@ -103,6 +104,11 @@ public final class DriverManagerConnectionSource implements ConnectionSource {
}
private static final Logger LOGGER = StatusLogger.getLogger();
+
+ @PluginBuilderFactory
+ public static <B extends Builder<B>> B newBuilder() {
+ return new Builder<B>().asBuilder();
+ }
private final String connectionString;
private final String driverClassName;
@@ -134,14 +140,6 @@ public final class DriverManagerConnectionSource implements ConnectionSource {
return DriverManager.getConnection(connectionString, toString(userName), toString(password));
}
- private Properties toProperties(Property[] properties) {
- Properties props = new Properties();
- for (Property property : properties) {
- props.setProperty(property.getName(), property.getValue());
- }
- return props;
- }
-
private void loadDriver() throws SQLException {
if (driverClassName != null) {
// Hack for old JDBC drivers.
@@ -154,6 +152,14 @@ public final class DriverManagerConnectionSource implements ConnectionSource {
}
}
+ private Properties toProperties(Property[] properties) {
+ Properties props = new Properties();
+ for (Property property : properties) {
+ props.setProperty(property.getName(), property.getValue());
+ }
+ return props;
+ }
+
@Override
public String toString() {
return this.connectionString;