diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 41cd493..f9ae410 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -17,7 +17,7 @@ - + diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 41cd493..f9ae410 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -17,7 +17,7 @@ - + diff --git a/.idea/libraries-with-intellij-classes.xml b/.idea/libraries-with-intellij-classes.xml new file mode 100644 index 0000000..9fa3156 --- /dev/null +++ b/.idea/libraries-with-intellij-classes.xml @@ -0,0 +1,65 @@ + + + + + + \ No newline at end of file diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 41cd493..f9ae410 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -17,7 +17,7 @@ - + diff --git a/.idea/libraries-with-intellij-classes.xml b/.idea/libraries-with-intellij-classes.xml new file mode 100644 index 0000000..9fa3156 --- /dev/null +++ b/.idea/libraries-with-intellij-classes.xml @@ -0,0 +1,65 @@ + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml new file mode 100644 index 0000000..c108f80 --- /dev/null +++ b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 41cd493..f9ae410 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -17,7 +17,7 @@ - + diff --git a/.idea/libraries-with-intellij-classes.xml b/.idea/libraries-with-intellij-classes.xml new file mode 100644 index 0000000..9fa3156 --- /dev/null +++ b/.idea/libraries-with-intellij-classes.xml @@ -0,0 +1,65 @@ + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml new file mode 100644 index 0000000..c108f80 --- /dev/null +++ b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml b/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml deleted file mode 100644 index 9a00155..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 41cd493..f9ae410 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -17,7 +17,7 @@ - + diff --git a/.idea/libraries-with-intellij-classes.xml b/.idea/libraries-with-intellij-classes.xml new file mode 100644 index 0000000..9fa3156 --- /dev/null +++ b/.idea/libraries-with-intellij-classes.xml @@ -0,0 +1,65 @@ + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml new file mode 100644 index 0000000..c108f80 --- /dev/null +++ b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml b/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml deleted file mode 100644 index 9a00155..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml b/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml deleted file mode 100644 index 873c2c0..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 41cd493..f9ae410 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -17,7 +17,7 @@ - + diff --git a/.idea/libraries-with-intellij-classes.xml b/.idea/libraries-with-intellij-classes.xml new file mode 100644 index 0000000..9fa3156 --- /dev/null +++ b/.idea/libraries-with-intellij-classes.xml @@ -0,0 +1,65 @@ + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml new file mode 100644 index 0000000..c108f80 --- /dev/null +++ b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml b/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml deleted file mode 100644 index 9a00155..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml b/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml deleted file mode 100644 index 873c2c0..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml new file mode 100644 index 0000000..7d1fc19 --- /dev/null +++ b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 41cd493..f9ae410 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -17,7 +17,7 @@ - + diff --git a/.idea/libraries-with-intellij-classes.xml b/.idea/libraries-with-intellij-classes.xml new file mode 100644 index 0000000..9fa3156 --- /dev/null +++ b/.idea/libraries-with-intellij-classes.xml @@ -0,0 +1,65 @@ + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml new file mode 100644 index 0000000..c108f80 --- /dev/null +++ b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml b/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml deleted file mode 100644 index 9a00155..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml b/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml deleted file mode 100644 index 873c2c0..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml new file mode 100644 index 0000000..7d1fc19 --- /dev/null +++ b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index be926a3..6d93540 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,7 +8,7 @@ http://www.w3.org/1999/xhtml - + diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 41cd493..f9ae410 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -17,7 +17,7 @@ - + diff --git a/.idea/libraries-with-intellij-classes.xml b/.idea/libraries-with-intellij-classes.xml new file mode 100644 index 0000000..9fa3156 --- /dev/null +++ b/.idea/libraries-with-intellij-classes.xml @@ -0,0 +1,65 @@ + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml new file mode 100644 index 0000000..c108f80 --- /dev/null +++ b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml b/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml deleted file mode 100644 index 9a00155..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml b/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml deleted file mode 100644 index 873c2c0..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml new file mode 100644 index 0000000..7d1fc19 --- /dev/null +++ b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index be926a3..6d93540 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,7 +8,7 @@ http://www.w3.org/1999/xhtml - + diff --git a/.idea/modules/simple-jdbc-stats.main.iml b/.idea/modules/simple-jdbc-stats.main.iml index 578407e..50faa2e 100644 --- a/.idea/modules/simple-jdbc-stats.main.iml +++ b/.idea/modules/simple-jdbc-stats.main.iml @@ -1,15 +1,15 @@ - + - - + + \ No newline at end of file diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 41cd493..f9ae410 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -17,7 +17,7 @@ - + diff --git a/.idea/libraries-with-intellij-classes.xml b/.idea/libraries-with-intellij-classes.xml new file mode 100644 index 0000000..9fa3156 --- /dev/null +++ b/.idea/libraries-with-intellij-classes.xml @@ -0,0 +1,65 @@ + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml new file mode 100644 index 0000000..c108f80 --- /dev/null +++ b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml b/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml deleted file mode 100644 index 9a00155..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml b/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml deleted file mode 100644 index 873c2c0..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml new file mode 100644 index 0000000..7d1fc19 --- /dev/null +++ b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index be926a3..6d93540 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,7 +8,7 @@ http://www.w3.org/1999/xhtml - + diff --git a/.idea/modules/simple-jdbc-stats.main.iml b/.idea/modules/simple-jdbc-stats.main.iml index 578407e..50faa2e 100644 --- a/.idea/modules/simple-jdbc-stats.main.iml +++ b/.idea/modules/simple-jdbc-stats.main.iml @@ -1,15 +1,15 @@ - + - - + + \ No newline at end of file diff --git a/.idea/modules/simple-jdbc-stats.test.iml b/.idea/modules/simple-jdbc-stats.test.iml index 62ffcca..f5baeeb 100644 --- a/.idea/modules/simple-jdbc-stats.test.iml +++ b/.idea/modules/simple-jdbc-stats.test.iml @@ -1,7 +1,7 @@ - + @@ -10,8 +10,8 @@ - - + + diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 41cd493..f9ae410 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -17,7 +17,7 @@ - + diff --git a/.idea/libraries-with-intellij-classes.xml b/.idea/libraries-with-intellij-classes.xml new file mode 100644 index 0000000..9fa3156 --- /dev/null +++ b/.idea/libraries-with-intellij-classes.xml @@ -0,0 +1,65 @@ + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml new file mode 100644 index 0000000..c108f80 --- /dev/null +++ b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml b/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml deleted file mode 100644 index 9a00155..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml b/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml deleted file mode 100644 index 873c2c0..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml new file mode 100644 index 0000000..7d1fc19 --- /dev/null +++ b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index be926a3..6d93540 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,7 +8,7 @@ http://www.w3.org/1999/xhtml - + diff --git a/.idea/modules/simple-jdbc-stats.main.iml b/.idea/modules/simple-jdbc-stats.main.iml index 578407e..50faa2e 100644 --- a/.idea/modules/simple-jdbc-stats.main.iml +++ b/.idea/modules/simple-jdbc-stats.main.iml @@ -1,15 +1,15 @@ - + - - + + \ No newline at end of file diff --git a/.idea/modules/simple-jdbc-stats.test.iml b/.idea/modules/simple-jdbc-stats.test.iml index 62ffcca..f5baeeb 100644 --- a/.idea/modules/simple-jdbc-stats.test.iml +++ b/.idea/modules/simple-jdbc-stats.test.iml @@ -1,7 +1,7 @@ - + @@ -10,8 +10,8 @@ - - + + diff --git a/build.gradle b/build.gradle index 8791f4a..559db71 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,6 @@ apply plugin: 'java' apply plugin: 'idea' apply plugin: 'maven' -apply plugin: 'findbugs' apply plugin: 'maven-publish' sourceSets { @@ -15,8 +14,8 @@ test.resources.srcDirs += 'test' } -sourceCompatibility = 1.5 -targetCompatibility = 1.5 +sourceCompatibility = 1.6 +targetCompatibility = 1.6 repositories { maven { @@ -24,18 +23,23 @@ } } +ext { + PUBLISH_GROUP_ID = group + PUBLISH_VERSION = version + PUBLISH_ARTIFACT_ID = name +} + +apply from: "${rootProject.projectDir}/scripts/publish-mavencentral.gradle" + dependencies { testCompile group: 'junit', name: 'junit', version: '4.12' - testCompile "org.slf4j:slf4j-simple:1.7.21" testCompile "com.h2database:h2:1.4.+" - compile "nl.astraeus.template:very-simple-templates:1.3" - compile "nl.astraeus.web:simple-web:0.3" - compile "org.slf4j:slf4j-api:1.7.21" + compile "com.samskivert:jmustache:1.15" + compile "org.nanohttpd:nanohttpd:2.2.0" configurations.compile.exclude module: 'javax.servlet-api' - configurations.compile.exclude module: 'slf4j-simple' } uploadArchives { @@ -51,10 +55,6 @@ } } -findbugs { - ignoreFailures = true -} - javadoc { failOnError = false } diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 41cd493..f9ae410 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -17,7 +17,7 @@ - + diff --git a/.idea/libraries-with-intellij-classes.xml b/.idea/libraries-with-intellij-classes.xml new file mode 100644 index 0000000..9fa3156 --- /dev/null +++ b/.idea/libraries-with-intellij-classes.xml @@ -0,0 +1,65 @@ + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml new file mode 100644 index 0000000..c108f80 --- /dev/null +++ b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml b/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml deleted file mode 100644 index 9a00155..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml b/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml deleted file mode 100644 index 873c2c0..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml new file mode 100644 index 0000000..7d1fc19 --- /dev/null +++ b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index be926a3..6d93540 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,7 +8,7 @@ http://www.w3.org/1999/xhtml - + diff --git a/.idea/modules/simple-jdbc-stats.main.iml b/.idea/modules/simple-jdbc-stats.main.iml index 578407e..50faa2e 100644 --- a/.idea/modules/simple-jdbc-stats.main.iml +++ b/.idea/modules/simple-jdbc-stats.main.iml @@ -1,15 +1,15 @@ - + - - + + \ No newline at end of file diff --git a/.idea/modules/simple-jdbc-stats.test.iml b/.idea/modules/simple-jdbc-stats.test.iml index 62ffcca..f5baeeb 100644 --- a/.idea/modules/simple-jdbc-stats.test.iml +++ b/.idea/modules/simple-jdbc-stats.test.iml @@ -1,7 +1,7 @@ - + @@ -10,8 +10,8 @@ - - + + diff --git a/build.gradle b/build.gradle index 8791f4a..559db71 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,6 @@ apply plugin: 'java' apply plugin: 'idea' apply plugin: 'maven' -apply plugin: 'findbugs' apply plugin: 'maven-publish' sourceSets { @@ -15,8 +14,8 @@ test.resources.srcDirs += 'test' } -sourceCompatibility = 1.5 -targetCompatibility = 1.5 +sourceCompatibility = 1.6 +targetCompatibility = 1.6 repositories { maven { @@ -24,18 +23,23 @@ } } +ext { + PUBLISH_GROUP_ID = group + PUBLISH_VERSION = version + PUBLISH_ARTIFACT_ID = name +} + +apply from: "${rootProject.projectDir}/scripts/publish-mavencentral.gradle" + dependencies { testCompile group: 'junit', name: 'junit', version: '4.12' - testCompile "org.slf4j:slf4j-simple:1.7.21" testCompile "com.h2database:h2:1.4.+" - compile "nl.astraeus.template:very-simple-templates:1.3" - compile "nl.astraeus.web:simple-web:0.3" - compile "org.slf4j:slf4j-api:1.7.21" + compile "com.samskivert:jmustache:1.15" + compile "org.nanohttpd:nanohttpd:2.2.0" configurations.compile.exclude module: 'javax.servlet-api' - configurations.compile.exclude module: 'slf4j-simple' } uploadArchives { @@ -51,10 +55,6 @@ } } -findbugs { - ignoreFailures = true -} - javadoc { failOnError = false } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 088b40b..bd4ca84 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 41cd493..f9ae410 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -17,7 +17,7 @@ - + diff --git a/.idea/libraries-with-intellij-classes.xml b/.idea/libraries-with-intellij-classes.xml new file mode 100644 index 0000000..9fa3156 --- /dev/null +++ b/.idea/libraries-with-intellij-classes.xml @@ -0,0 +1,65 @@ + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml new file mode 100644 index 0000000..c108f80 --- /dev/null +++ b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml b/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml deleted file mode 100644 index 9a00155..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml b/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml deleted file mode 100644 index 873c2c0..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml new file mode 100644 index 0000000..7d1fc19 --- /dev/null +++ b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index be926a3..6d93540 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,7 +8,7 @@ http://www.w3.org/1999/xhtml - + diff --git a/.idea/modules/simple-jdbc-stats.main.iml b/.idea/modules/simple-jdbc-stats.main.iml index 578407e..50faa2e 100644 --- a/.idea/modules/simple-jdbc-stats.main.iml +++ b/.idea/modules/simple-jdbc-stats.main.iml @@ -1,15 +1,15 @@ - + - - + + \ No newline at end of file diff --git a/.idea/modules/simple-jdbc-stats.test.iml b/.idea/modules/simple-jdbc-stats.test.iml index 62ffcca..f5baeeb 100644 --- a/.idea/modules/simple-jdbc-stats.test.iml +++ b/.idea/modules/simple-jdbc-stats.test.iml @@ -1,7 +1,7 @@ - + @@ -10,8 +10,8 @@ - - + + diff --git a/build.gradle b/build.gradle index 8791f4a..559db71 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,6 @@ apply plugin: 'java' apply plugin: 'idea' apply plugin: 'maven' -apply plugin: 'findbugs' apply plugin: 'maven-publish' sourceSets { @@ -15,8 +14,8 @@ test.resources.srcDirs += 'test' } -sourceCompatibility = 1.5 -targetCompatibility = 1.5 +sourceCompatibility = 1.6 +targetCompatibility = 1.6 repositories { maven { @@ -24,18 +23,23 @@ } } +ext { + PUBLISH_GROUP_ID = group + PUBLISH_VERSION = version + PUBLISH_ARTIFACT_ID = name +} + +apply from: "${rootProject.projectDir}/scripts/publish-mavencentral.gradle" + dependencies { testCompile group: 'junit', name: 'junit', version: '4.12' - testCompile "org.slf4j:slf4j-simple:1.7.21" testCompile "com.h2database:h2:1.4.+" - compile "nl.astraeus.template:very-simple-templates:1.3" - compile "nl.astraeus.web:simple-web:0.3" - compile "org.slf4j:slf4j-api:1.7.21" + compile "com.samskivert:jmustache:1.15" + compile "org.nanohttpd:nanohttpd:2.2.0" configurations.compile.exclude module: 'javax.servlet-api' - configurations.compile.exclude module: 'slf4j-simple' } uploadArchives { @@ -51,10 +55,6 @@ } } -findbugs { - ignoreFailures = true -} - javadoc { failOnError = false } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 088b40b..bd4ca84 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip diff --git a/scripts/publish-mavencentral.gradle b/scripts/publish-mavencentral.gradle new file mode 100644 index 0000000..fae9b85 --- /dev/null +++ b/scripts/publish-mavencentral.gradle @@ -0,0 +1,121 @@ + +apply plugin: 'maven-publish' +apply plugin: 'signing' + +task publishSourcesJar(type: Jar) { + archiveClassifier.set('sources') + + // For pure Kotlin libraries, in case you have them + from sourceSets.main.java.srcDirs + //from sourceSets.main.kotlin.srcDirs +} + +task packageJavadoc(type: Jar) { + from javadoc + classifier = 'javadoc' +} + +artifacts { + archives publishSourcesJar +} + +File secretPropsFile = project.rootProject.file('local.properties') + +ext["signing.keyId"] = '' +ext["signing.password"] = '' +ext["signing.secretKeyRingFile"] = '' +ext["ossrhUsername"] = '' +ext["ossrhPassword"] = '' +ext["sonatypeStagingProfileId"] = '' + +if (secretPropsFile.exists()) { + Properties p = new Properties() + + new FileInputStream(secretPropsFile).withCloseable { is -> + p.load(is) + } + + p.each { name, value -> + ext[name] = value + } +} + +afterEvaluate { + publishing { + publications { + relase(MavenPublication) { + // The coordinates of the library, being set from variables that + // we'll set up later + groupId PUBLISH_GROUP_ID + artifactId PUBLISH_ARTIFACT_ID + version PUBLISH_VERSION + + // Two artifacts, the `aar` (or `jar`) and the sources + if (project.plugins.findPlugin("com.android.library")) { + artifact("$buildDir/outputs/aar/${project.getName()}-release.aar") + } else { + artifact("$buildDir/libs/${project.getName()}-${version}.jar") + } + artifact publishSourcesJar + artifact packageJavadoc + + // Mostly self-explanatory metadata + pom { + name = PUBLISH_ARTIFACT_ID + description = 'Simple JDBC wrapper for query statistics' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics' + licenses { + license { + name = 'MIT License' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics/blob/master/LICENCE.txt' + } + } + developers { + developer { + id = 'rnentjes' + name = 'Rien Nentjes' + email = 'info@nentjes.com' + } + // Add all other devs here... + } + // Version control info - if you're using GitHub, follow the format as seen here + scm { + connection = 'scm:git:github.com/rnentjes/Simple-jdbc-statistics.git' + developerConnection = 'scm:git:ssh://github.com/rnentjes/Simple-jdbc-statistics.git' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics.git/tree/main' + } + // A slightly hacky fix so that your POM will include any transitive dependencies + // that your library builds upon + /* + witXml { + def dependenciesNode = asNode().appendNode('dependencies') + + project.configurations.implementation.allDependencies.each { + def dependencyNode = dependenciesNode.appendNode('dependency') + dependencyNode.appendNode('groupId', it.group) + dependencyNode.appendNode('artifactId', it.name) + dependencyNode.appendNode('version', it.version) + } + }*/ + } + } + } + // The repository to publish to, Sonatype/MavenCentral + repositories { + maven { + // This is an arbitrary name, you may also use "mavencentral" or + // any other name that's descriptive for you + name = "sonatype" + url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" + credentials { + username ossrhUsername + password ossrhPassword + } + } + } + } +} + +signing { + sign publishing.publications +} diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 41cd493..f9ae410 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -17,7 +17,7 @@ - + diff --git a/.idea/libraries-with-intellij-classes.xml b/.idea/libraries-with-intellij-classes.xml new file mode 100644 index 0000000..9fa3156 --- /dev/null +++ b/.idea/libraries-with-intellij-classes.xml @@ -0,0 +1,65 @@ + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml new file mode 100644 index 0000000..c108f80 --- /dev/null +++ b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml b/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml deleted file mode 100644 index 9a00155..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml b/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml deleted file mode 100644 index 873c2c0..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml new file mode 100644 index 0000000..7d1fc19 --- /dev/null +++ b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index be926a3..6d93540 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,7 +8,7 @@ http://www.w3.org/1999/xhtml - + diff --git a/.idea/modules/simple-jdbc-stats.main.iml b/.idea/modules/simple-jdbc-stats.main.iml index 578407e..50faa2e 100644 --- a/.idea/modules/simple-jdbc-stats.main.iml +++ b/.idea/modules/simple-jdbc-stats.main.iml @@ -1,15 +1,15 @@ - + - - + + \ No newline at end of file diff --git a/.idea/modules/simple-jdbc-stats.test.iml b/.idea/modules/simple-jdbc-stats.test.iml index 62ffcca..f5baeeb 100644 --- a/.idea/modules/simple-jdbc-stats.test.iml +++ b/.idea/modules/simple-jdbc-stats.test.iml @@ -1,7 +1,7 @@ - + @@ -10,8 +10,8 @@ - - + + diff --git a/build.gradle b/build.gradle index 8791f4a..559db71 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,6 @@ apply plugin: 'java' apply plugin: 'idea' apply plugin: 'maven' -apply plugin: 'findbugs' apply plugin: 'maven-publish' sourceSets { @@ -15,8 +14,8 @@ test.resources.srcDirs += 'test' } -sourceCompatibility = 1.5 -targetCompatibility = 1.5 +sourceCompatibility = 1.6 +targetCompatibility = 1.6 repositories { maven { @@ -24,18 +23,23 @@ } } +ext { + PUBLISH_GROUP_ID = group + PUBLISH_VERSION = version + PUBLISH_ARTIFACT_ID = name +} + +apply from: "${rootProject.projectDir}/scripts/publish-mavencentral.gradle" + dependencies { testCompile group: 'junit', name: 'junit', version: '4.12' - testCompile "org.slf4j:slf4j-simple:1.7.21" testCompile "com.h2database:h2:1.4.+" - compile "nl.astraeus.template:very-simple-templates:1.3" - compile "nl.astraeus.web:simple-web:0.3" - compile "org.slf4j:slf4j-api:1.7.21" + compile "com.samskivert:jmustache:1.15" + compile "org.nanohttpd:nanohttpd:2.2.0" configurations.compile.exclude module: 'javax.servlet-api' - configurations.compile.exclude module: 'slf4j-simple' } uploadArchives { @@ -51,10 +55,6 @@ } } -findbugs { - ignoreFailures = true -} - javadoc { failOnError = false } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 088b40b..bd4ca84 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip diff --git a/scripts/publish-mavencentral.gradle b/scripts/publish-mavencentral.gradle new file mode 100644 index 0000000..fae9b85 --- /dev/null +++ b/scripts/publish-mavencentral.gradle @@ -0,0 +1,121 @@ + +apply plugin: 'maven-publish' +apply plugin: 'signing' + +task publishSourcesJar(type: Jar) { + archiveClassifier.set('sources') + + // For pure Kotlin libraries, in case you have them + from sourceSets.main.java.srcDirs + //from sourceSets.main.kotlin.srcDirs +} + +task packageJavadoc(type: Jar) { + from javadoc + classifier = 'javadoc' +} + +artifacts { + archives publishSourcesJar +} + +File secretPropsFile = project.rootProject.file('local.properties') + +ext["signing.keyId"] = '' +ext["signing.password"] = '' +ext["signing.secretKeyRingFile"] = '' +ext["ossrhUsername"] = '' +ext["ossrhPassword"] = '' +ext["sonatypeStagingProfileId"] = '' + +if (secretPropsFile.exists()) { + Properties p = new Properties() + + new FileInputStream(secretPropsFile).withCloseable { is -> + p.load(is) + } + + p.each { name, value -> + ext[name] = value + } +} + +afterEvaluate { + publishing { + publications { + relase(MavenPublication) { + // The coordinates of the library, being set from variables that + // we'll set up later + groupId PUBLISH_GROUP_ID + artifactId PUBLISH_ARTIFACT_ID + version PUBLISH_VERSION + + // Two artifacts, the `aar` (or `jar`) and the sources + if (project.plugins.findPlugin("com.android.library")) { + artifact("$buildDir/outputs/aar/${project.getName()}-release.aar") + } else { + artifact("$buildDir/libs/${project.getName()}-${version}.jar") + } + artifact publishSourcesJar + artifact packageJavadoc + + // Mostly self-explanatory metadata + pom { + name = PUBLISH_ARTIFACT_ID + description = 'Simple JDBC wrapper for query statistics' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics' + licenses { + license { + name = 'MIT License' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics/blob/master/LICENCE.txt' + } + } + developers { + developer { + id = 'rnentjes' + name = 'Rien Nentjes' + email = 'info@nentjes.com' + } + // Add all other devs here... + } + // Version control info - if you're using GitHub, follow the format as seen here + scm { + connection = 'scm:git:github.com/rnentjes/Simple-jdbc-statistics.git' + developerConnection = 'scm:git:ssh://github.com/rnentjes/Simple-jdbc-statistics.git' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics.git/tree/main' + } + // A slightly hacky fix so that your POM will include any transitive dependencies + // that your library builds upon + /* + witXml { + def dependenciesNode = asNode().appendNode('dependencies') + + project.configurations.implementation.allDependencies.each { + def dependencyNode = dependenciesNode.appendNode('dependency') + dependencyNode.appendNode('groupId', it.group) + dependencyNode.appendNode('artifactId', it.name) + dependencyNode.appendNode('version', it.version) + } + }*/ + } + } + } + // The repository to publish to, Sonatype/MavenCentral + repositories { + maven { + // This is an arbitrary name, you may also use "mavencentral" or + // any other name that's descriptive for you + name = "sonatype" + url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" + credentials { + username ossrhUsername + password ossrhPassword + } + } + } + } +} + +signing { + sign publishing.publications +} diff --git a/src/nl/astraeus/jdbc/CallableStatementLogger.java b/src/nl/astraeus/jdbc/CallableStatementLogger.java index 2e9f173..39be81c 100644 --- a/src/nl/astraeus/jdbc/CallableStatementLogger.java +++ b/src/nl/astraeus/jdbc/CallableStatementLogger.java @@ -1,8 +1,5 @@ package nl.astraeus.jdbc; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; @@ -17,8 +14,6 @@ * Time: 9:48 PM */ public class CallableStatementLogger implements CallableStatement { - private final static Logger log = LoggerFactory.getLogger(PreparedStatementLogger.class); - private JdbcLogger logger; private CallableStatement statement; diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 41cd493..f9ae410 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -17,7 +17,7 @@ - + diff --git a/.idea/libraries-with-intellij-classes.xml b/.idea/libraries-with-intellij-classes.xml new file mode 100644 index 0000000..9fa3156 --- /dev/null +++ b/.idea/libraries-with-intellij-classes.xml @@ -0,0 +1,65 @@ + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml new file mode 100644 index 0000000..c108f80 --- /dev/null +++ b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml b/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml deleted file mode 100644 index 9a00155..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml b/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml deleted file mode 100644 index 873c2c0..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml new file mode 100644 index 0000000..7d1fc19 --- /dev/null +++ b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index be926a3..6d93540 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,7 +8,7 @@ http://www.w3.org/1999/xhtml - + diff --git a/.idea/modules/simple-jdbc-stats.main.iml b/.idea/modules/simple-jdbc-stats.main.iml index 578407e..50faa2e 100644 --- a/.idea/modules/simple-jdbc-stats.main.iml +++ b/.idea/modules/simple-jdbc-stats.main.iml @@ -1,15 +1,15 @@ - + - - + + \ No newline at end of file diff --git a/.idea/modules/simple-jdbc-stats.test.iml b/.idea/modules/simple-jdbc-stats.test.iml index 62ffcca..f5baeeb 100644 --- a/.idea/modules/simple-jdbc-stats.test.iml +++ b/.idea/modules/simple-jdbc-stats.test.iml @@ -1,7 +1,7 @@ - + @@ -10,8 +10,8 @@ - - + + diff --git a/build.gradle b/build.gradle index 8791f4a..559db71 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,6 @@ apply plugin: 'java' apply plugin: 'idea' apply plugin: 'maven' -apply plugin: 'findbugs' apply plugin: 'maven-publish' sourceSets { @@ -15,8 +14,8 @@ test.resources.srcDirs += 'test' } -sourceCompatibility = 1.5 -targetCompatibility = 1.5 +sourceCompatibility = 1.6 +targetCompatibility = 1.6 repositories { maven { @@ -24,18 +23,23 @@ } } +ext { + PUBLISH_GROUP_ID = group + PUBLISH_VERSION = version + PUBLISH_ARTIFACT_ID = name +} + +apply from: "${rootProject.projectDir}/scripts/publish-mavencentral.gradle" + dependencies { testCompile group: 'junit', name: 'junit', version: '4.12' - testCompile "org.slf4j:slf4j-simple:1.7.21" testCompile "com.h2database:h2:1.4.+" - compile "nl.astraeus.template:very-simple-templates:1.3" - compile "nl.astraeus.web:simple-web:0.3" - compile "org.slf4j:slf4j-api:1.7.21" + compile "com.samskivert:jmustache:1.15" + compile "org.nanohttpd:nanohttpd:2.2.0" configurations.compile.exclude module: 'javax.servlet-api' - configurations.compile.exclude module: 'slf4j-simple' } uploadArchives { @@ -51,10 +55,6 @@ } } -findbugs { - ignoreFailures = true -} - javadoc { failOnError = false } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 088b40b..bd4ca84 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip diff --git a/scripts/publish-mavencentral.gradle b/scripts/publish-mavencentral.gradle new file mode 100644 index 0000000..fae9b85 --- /dev/null +++ b/scripts/publish-mavencentral.gradle @@ -0,0 +1,121 @@ + +apply plugin: 'maven-publish' +apply plugin: 'signing' + +task publishSourcesJar(type: Jar) { + archiveClassifier.set('sources') + + // For pure Kotlin libraries, in case you have them + from sourceSets.main.java.srcDirs + //from sourceSets.main.kotlin.srcDirs +} + +task packageJavadoc(type: Jar) { + from javadoc + classifier = 'javadoc' +} + +artifacts { + archives publishSourcesJar +} + +File secretPropsFile = project.rootProject.file('local.properties') + +ext["signing.keyId"] = '' +ext["signing.password"] = '' +ext["signing.secretKeyRingFile"] = '' +ext["ossrhUsername"] = '' +ext["ossrhPassword"] = '' +ext["sonatypeStagingProfileId"] = '' + +if (secretPropsFile.exists()) { + Properties p = new Properties() + + new FileInputStream(secretPropsFile).withCloseable { is -> + p.load(is) + } + + p.each { name, value -> + ext[name] = value + } +} + +afterEvaluate { + publishing { + publications { + relase(MavenPublication) { + // The coordinates of the library, being set from variables that + // we'll set up later + groupId PUBLISH_GROUP_ID + artifactId PUBLISH_ARTIFACT_ID + version PUBLISH_VERSION + + // Two artifacts, the `aar` (or `jar`) and the sources + if (project.plugins.findPlugin("com.android.library")) { + artifact("$buildDir/outputs/aar/${project.getName()}-release.aar") + } else { + artifact("$buildDir/libs/${project.getName()}-${version}.jar") + } + artifact publishSourcesJar + artifact packageJavadoc + + // Mostly self-explanatory metadata + pom { + name = PUBLISH_ARTIFACT_ID + description = 'Simple JDBC wrapper for query statistics' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics' + licenses { + license { + name = 'MIT License' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics/blob/master/LICENCE.txt' + } + } + developers { + developer { + id = 'rnentjes' + name = 'Rien Nentjes' + email = 'info@nentjes.com' + } + // Add all other devs here... + } + // Version control info - if you're using GitHub, follow the format as seen here + scm { + connection = 'scm:git:github.com/rnentjes/Simple-jdbc-statistics.git' + developerConnection = 'scm:git:ssh://github.com/rnentjes/Simple-jdbc-statistics.git' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics.git/tree/main' + } + // A slightly hacky fix so that your POM will include any transitive dependencies + // that your library builds upon + /* + witXml { + def dependenciesNode = asNode().appendNode('dependencies') + + project.configurations.implementation.allDependencies.each { + def dependencyNode = dependenciesNode.appendNode('dependency') + dependencyNode.appendNode('groupId', it.group) + dependencyNode.appendNode('artifactId', it.name) + dependencyNode.appendNode('version', it.version) + } + }*/ + } + } + } + // The repository to publish to, Sonatype/MavenCentral + repositories { + maven { + // This is an arbitrary name, you may also use "mavencentral" or + // any other name that's descriptive for you + name = "sonatype" + url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" + credentials { + username ossrhUsername + password ossrhPassword + } + } + } + } +} + +signing { + sign publishing.publications +} diff --git a/src/nl/astraeus/jdbc/CallableStatementLogger.java b/src/nl/astraeus/jdbc/CallableStatementLogger.java index 2e9f173..39be81c 100644 --- a/src/nl/astraeus/jdbc/CallableStatementLogger.java +++ b/src/nl/astraeus/jdbc/CallableStatementLogger.java @@ -1,8 +1,5 @@ package nl.astraeus.jdbc; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; @@ -17,8 +14,6 @@ * Time: 9:48 PM */ public class CallableStatementLogger implements CallableStatement { - private final static Logger log = LoggerFactory.getLogger(PreparedStatementLogger.class); - private JdbcLogger logger; private CallableStatement statement; diff --git a/src/nl/astraeus/jdbc/Driver.java b/src/nl/astraeus/jdbc/Driver.java index 046d756..e230a06 100644 --- a/src/nl/astraeus/jdbc/Driver.java +++ b/src/nl/astraeus/jdbc/Driver.java @@ -11,44 +11,38 @@ import java.util.concurrent.ConcurrentHashMap; import nl.astraeus.jdbc.web.JdbcStatsMappingProvider; +import nl.astraeus.jdbc.web.NanoHttpdSimpleWeb; import nl.astraeus.jdbc.web.model.Settings; -import nl.astraeus.web.NanoHttpdSimpleWeb; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * User: riennentjes * Date: Jul 10, 2008 * Time: 8:54:37 PM - * + *

* Test a little change - * */ public class Driver implements java.sql.Driver { - private final static Logger log = LoggerFactory.getLogger(Driver.class); - - final private static String URL_PREFIX = "jdbc:stat:"; - final private static String URL_SECURE_PREFIX = "jdbc:secstat:"; + final private static String URL_PREFIX = "jdbc:stat:"; + final private static String URL_SECURE_PREFIX = "jdbc:secstat:"; public static class StatsLogger { - private volatile boolean started = false; - private NanoHttpdSimpleWeb server = null; - private java.sql.Driver driver = null; - private Settings settings = new Settings(); - private String targetUrl = null; + private volatile boolean started = false; + private NanoHttpdSimpleWeb server = null; + private java.sql.Driver driver = null; + private Settings settings = new Settings(); + private String targetUrl = null; public Settings getSettings() { return settings; } } - private static Map loggers = new ConcurrentHashMap(); - private static Map portMapping = new ConcurrentHashMap(); + private static Map loggers = new ConcurrentHashMap(); + private static Map portMapping = new ConcurrentHashMap(); public static StatsLogger get(String url) { if (!loggers.containsKey(url)) { - throw new IllegalArgumentException("No jdbc statistics logger found for url: "+url); + throw new IllegalArgumentException("No jdbc statistics logger found for url: " + url); } return loggers.get(url); @@ -56,7 +50,7 @@ public static StatsLogger get(int port) { if (!portMapping.containsKey(port)) { - throw new IllegalArgumentException("No jdbc statistics logger found on port: "+port); + throw new IllegalArgumentException("No jdbc statistics logger found on port: " + port); } return portMapping.get(port); @@ -75,7 +69,8 @@ "org.apache.derby.jdbc.EmbeddedDriver", "com.mysql.jdbc.Driver", "org.hsqldb.jdbcDriver", - "org.h2.Driver" }; + "org.h2.Driver" + }; static { log.debug("Loading driver class " + Driver.class.getName()); @@ -123,8 +118,8 @@ logger.settings.setSecure(true); } - String [] parts = url.split("\\:"); - String settingsString = "webServerConnections=5;numberOfQueries=2500;logStacktraces=true;formattedQueries=true"; + String[] parts = url.split("\\:"); + String settingsString = "webServerConnections=5;numberOfQueries=2500;logStacktraces=true;formattedQueries=true"; if (parts.length > 3) { settingsString = parts[2]; @@ -146,7 +141,7 @@ } if (logger.settings.isSecure()) { - String user = info.getProperty("user"); + String user = info.getProperty("user"); String password = info.getProperty("password"); if (user == null || password == null) { @@ -161,15 +156,21 @@ synchronized (this) { if (!logger.started) { try { - NanoHttpdSimpleWeb server = new NanoHttpdSimpleWeb(logger.settings.getWebServerPort(), new JdbcStatsMappingProvider()); + NanoHttpdSimpleWeb server = new NanoHttpdSimpleWeb( + logger.settings.getWebServerPort(), + new JdbcStatsMappingProvider() + ); server.start(); - System.out.println("Started Simple JDBC Statistics\n\turl: "+url+"\n\tport: "+logger.settings.getWebServerPort()); + System.out.println("Started Simple JDBC Statistics\n\turl: " + + url + + "\n\tport: " + + logger.settings.getWebServerPort()); logger.started = true; } catch (Exception e) { - log.error(e.getMessage(),e); + log.error(e.getMessage(), e); } } } diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 41cd493..f9ae410 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -17,7 +17,7 @@ - + diff --git a/.idea/libraries-with-intellij-classes.xml b/.idea/libraries-with-intellij-classes.xml new file mode 100644 index 0000000..9fa3156 --- /dev/null +++ b/.idea/libraries-with-intellij-classes.xml @@ -0,0 +1,65 @@ + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml new file mode 100644 index 0000000..c108f80 --- /dev/null +++ b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml b/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml deleted file mode 100644 index 9a00155..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml b/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml deleted file mode 100644 index 873c2c0..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml new file mode 100644 index 0000000..7d1fc19 --- /dev/null +++ b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index be926a3..6d93540 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,7 +8,7 @@ http://www.w3.org/1999/xhtml - + diff --git a/.idea/modules/simple-jdbc-stats.main.iml b/.idea/modules/simple-jdbc-stats.main.iml index 578407e..50faa2e 100644 --- a/.idea/modules/simple-jdbc-stats.main.iml +++ b/.idea/modules/simple-jdbc-stats.main.iml @@ -1,15 +1,15 @@ - + - - + + \ No newline at end of file diff --git a/.idea/modules/simple-jdbc-stats.test.iml b/.idea/modules/simple-jdbc-stats.test.iml index 62ffcca..f5baeeb 100644 --- a/.idea/modules/simple-jdbc-stats.test.iml +++ b/.idea/modules/simple-jdbc-stats.test.iml @@ -1,7 +1,7 @@ - + @@ -10,8 +10,8 @@ - - + + diff --git a/build.gradle b/build.gradle index 8791f4a..559db71 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,6 @@ apply plugin: 'java' apply plugin: 'idea' apply plugin: 'maven' -apply plugin: 'findbugs' apply plugin: 'maven-publish' sourceSets { @@ -15,8 +14,8 @@ test.resources.srcDirs += 'test' } -sourceCompatibility = 1.5 -targetCompatibility = 1.5 +sourceCompatibility = 1.6 +targetCompatibility = 1.6 repositories { maven { @@ -24,18 +23,23 @@ } } +ext { + PUBLISH_GROUP_ID = group + PUBLISH_VERSION = version + PUBLISH_ARTIFACT_ID = name +} + +apply from: "${rootProject.projectDir}/scripts/publish-mavencentral.gradle" + dependencies { testCompile group: 'junit', name: 'junit', version: '4.12' - testCompile "org.slf4j:slf4j-simple:1.7.21" testCompile "com.h2database:h2:1.4.+" - compile "nl.astraeus.template:very-simple-templates:1.3" - compile "nl.astraeus.web:simple-web:0.3" - compile "org.slf4j:slf4j-api:1.7.21" + compile "com.samskivert:jmustache:1.15" + compile "org.nanohttpd:nanohttpd:2.2.0" configurations.compile.exclude module: 'javax.servlet-api' - configurations.compile.exclude module: 'slf4j-simple' } uploadArchives { @@ -51,10 +55,6 @@ } } -findbugs { - ignoreFailures = true -} - javadoc { failOnError = false } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 088b40b..bd4ca84 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip diff --git a/scripts/publish-mavencentral.gradle b/scripts/publish-mavencentral.gradle new file mode 100644 index 0000000..fae9b85 --- /dev/null +++ b/scripts/publish-mavencentral.gradle @@ -0,0 +1,121 @@ + +apply plugin: 'maven-publish' +apply plugin: 'signing' + +task publishSourcesJar(type: Jar) { + archiveClassifier.set('sources') + + // For pure Kotlin libraries, in case you have them + from sourceSets.main.java.srcDirs + //from sourceSets.main.kotlin.srcDirs +} + +task packageJavadoc(type: Jar) { + from javadoc + classifier = 'javadoc' +} + +artifacts { + archives publishSourcesJar +} + +File secretPropsFile = project.rootProject.file('local.properties') + +ext["signing.keyId"] = '' +ext["signing.password"] = '' +ext["signing.secretKeyRingFile"] = '' +ext["ossrhUsername"] = '' +ext["ossrhPassword"] = '' +ext["sonatypeStagingProfileId"] = '' + +if (secretPropsFile.exists()) { + Properties p = new Properties() + + new FileInputStream(secretPropsFile).withCloseable { is -> + p.load(is) + } + + p.each { name, value -> + ext[name] = value + } +} + +afterEvaluate { + publishing { + publications { + relase(MavenPublication) { + // The coordinates of the library, being set from variables that + // we'll set up later + groupId PUBLISH_GROUP_ID + artifactId PUBLISH_ARTIFACT_ID + version PUBLISH_VERSION + + // Two artifacts, the `aar` (or `jar`) and the sources + if (project.plugins.findPlugin("com.android.library")) { + artifact("$buildDir/outputs/aar/${project.getName()}-release.aar") + } else { + artifact("$buildDir/libs/${project.getName()}-${version}.jar") + } + artifact publishSourcesJar + artifact packageJavadoc + + // Mostly self-explanatory metadata + pom { + name = PUBLISH_ARTIFACT_ID + description = 'Simple JDBC wrapper for query statistics' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics' + licenses { + license { + name = 'MIT License' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics/blob/master/LICENCE.txt' + } + } + developers { + developer { + id = 'rnentjes' + name = 'Rien Nentjes' + email = 'info@nentjes.com' + } + // Add all other devs here... + } + // Version control info - if you're using GitHub, follow the format as seen here + scm { + connection = 'scm:git:github.com/rnentjes/Simple-jdbc-statistics.git' + developerConnection = 'scm:git:ssh://github.com/rnentjes/Simple-jdbc-statistics.git' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics.git/tree/main' + } + // A slightly hacky fix so that your POM will include any transitive dependencies + // that your library builds upon + /* + witXml { + def dependenciesNode = asNode().appendNode('dependencies') + + project.configurations.implementation.allDependencies.each { + def dependencyNode = dependenciesNode.appendNode('dependency') + dependencyNode.appendNode('groupId', it.group) + dependencyNode.appendNode('artifactId', it.name) + dependencyNode.appendNode('version', it.version) + } + }*/ + } + } + } + // The repository to publish to, Sonatype/MavenCentral + repositories { + maven { + // This is an arbitrary name, you may also use "mavencentral" or + // any other name that's descriptive for you + name = "sonatype" + url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" + credentials { + username ossrhUsername + password ossrhPassword + } + } + } + } +} + +signing { + sign publishing.publications +} diff --git a/src/nl/astraeus/jdbc/CallableStatementLogger.java b/src/nl/astraeus/jdbc/CallableStatementLogger.java index 2e9f173..39be81c 100644 --- a/src/nl/astraeus/jdbc/CallableStatementLogger.java +++ b/src/nl/astraeus/jdbc/CallableStatementLogger.java @@ -1,8 +1,5 @@ package nl.astraeus.jdbc; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; @@ -17,8 +14,6 @@ * Time: 9:48 PM */ public class CallableStatementLogger implements CallableStatement { - private final static Logger log = LoggerFactory.getLogger(PreparedStatementLogger.class); - private JdbcLogger logger; private CallableStatement statement; diff --git a/src/nl/astraeus/jdbc/Driver.java b/src/nl/astraeus/jdbc/Driver.java index 046d756..e230a06 100644 --- a/src/nl/astraeus/jdbc/Driver.java +++ b/src/nl/astraeus/jdbc/Driver.java @@ -11,44 +11,38 @@ import java.util.concurrent.ConcurrentHashMap; import nl.astraeus.jdbc.web.JdbcStatsMappingProvider; +import nl.astraeus.jdbc.web.NanoHttpdSimpleWeb; import nl.astraeus.jdbc.web.model.Settings; -import nl.astraeus.web.NanoHttpdSimpleWeb; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * User: riennentjes * Date: Jul 10, 2008 * Time: 8:54:37 PM - * + *

* Test a little change - * */ public class Driver implements java.sql.Driver { - private final static Logger log = LoggerFactory.getLogger(Driver.class); - - final private static String URL_PREFIX = "jdbc:stat:"; - final private static String URL_SECURE_PREFIX = "jdbc:secstat:"; + final private static String URL_PREFIX = "jdbc:stat:"; + final private static String URL_SECURE_PREFIX = "jdbc:secstat:"; public static class StatsLogger { - private volatile boolean started = false; - private NanoHttpdSimpleWeb server = null; - private java.sql.Driver driver = null; - private Settings settings = new Settings(); - private String targetUrl = null; + private volatile boolean started = false; + private NanoHttpdSimpleWeb server = null; + private java.sql.Driver driver = null; + private Settings settings = new Settings(); + private String targetUrl = null; public Settings getSettings() { return settings; } } - private static Map loggers = new ConcurrentHashMap(); - private static Map portMapping = new ConcurrentHashMap(); + private static Map loggers = new ConcurrentHashMap(); + private static Map portMapping = new ConcurrentHashMap(); public static StatsLogger get(String url) { if (!loggers.containsKey(url)) { - throw new IllegalArgumentException("No jdbc statistics logger found for url: "+url); + throw new IllegalArgumentException("No jdbc statistics logger found for url: " + url); } return loggers.get(url); @@ -56,7 +50,7 @@ public static StatsLogger get(int port) { if (!portMapping.containsKey(port)) { - throw new IllegalArgumentException("No jdbc statistics logger found on port: "+port); + throw new IllegalArgumentException("No jdbc statistics logger found on port: " + port); } return portMapping.get(port); @@ -75,7 +69,8 @@ "org.apache.derby.jdbc.EmbeddedDriver", "com.mysql.jdbc.Driver", "org.hsqldb.jdbcDriver", - "org.h2.Driver" }; + "org.h2.Driver" + }; static { log.debug("Loading driver class " + Driver.class.getName()); @@ -123,8 +118,8 @@ logger.settings.setSecure(true); } - String [] parts = url.split("\\:"); - String settingsString = "webServerConnections=5;numberOfQueries=2500;logStacktraces=true;formattedQueries=true"; + String[] parts = url.split("\\:"); + String settingsString = "webServerConnections=5;numberOfQueries=2500;logStacktraces=true;formattedQueries=true"; if (parts.length > 3) { settingsString = parts[2]; @@ -146,7 +141,7 @@ } if (logger.settings.isSecure()) { - String user = info.getProperty("user"); + String user = info.getProperty("user"); String password = info.getProperty("password"); if (user == null || password == null) { @@ -161,15 +156,21 @@ synchronized (this) { if (!logger.started) { try { - NanoHttpdSimpleWeb server = new NanoHttpdSimpleWeb(logger.settings.getWebServerPort(), new JdbcStatsMappingProvider()); + NanoHttpdSimpleWeb server = new NanoHttpdSimpleWeb( + logger.settings.getWebServerPort(), + new JdbcStatsMappingProvider() + ); server.start(); - System.out.println("Started Simple JDBC Statistics\n\turl: "+url+"\n\tport: "+logger.settings.getWebServerPort()); + System.out.println("Started Simple JDBC Statistics\n\turl: " + + url + + "\n\tport: " + + logger.settings.getWebServerPort()); logger.started = true; } catch (Exception e) { - log.error(e.getMessage(),e); + log.error(e.getMessage(), e); } } } diff --git a/src/nl/astraeus/jdbc/JdbcLogger.java b/src/nl/astraeus/jdbc/JdbcLogger.java index 44d09e6..ac7188a 100644 --- a/src/nl/astraeus/jdbc/JdbcLogger.java +++ b/src/nl/astraeus/jdbc/JdbcLogger.java @@ -1,15 +1,10 @@ package nl.astraeus.jdbc; import nl.astraeus.jdbc.util.Util; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import java.util.HashMap; -import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; @@ -19,8 +14,6 @@ * Time: 9:15:21 AM */ public class JdbcLogger { - private final static Logger logger = LoggerFactory.getLogger(JdbcLogger.class); - private final static Map instances = new ConcurrentHashMap(); public static JdbcLogger get(int port) { diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 41cd493..f9ae410 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -17,7 +17,7 @@ - + diff --git a/.idea/libraries-with-intellij-classes.xml b/.idea/libraries-with-intellij-classes.xml new file mode 100644 index 0000000..9fa3156 --- /dev/null +++ b/.idea/libraries-with-intellij-classes.xml @@ -0,0 +1,65 @@ + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml new file mode 100644 index 0000000..c108f80 --- /dev/null +++ b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml b/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml deleted file mode 100644 index 9a00155..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml b/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml deleted file mode 100644 index 873c2c0..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml new file mode 100644 index 0000000..7d1fc19 --- /dev/null +++ b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index be926a3..6d93540 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,7 +8,7 @@ http://www.w3.org/1999/xhtml - + diff --git a/.idea/modules/simple-jdbc-stats.main.iml b/.idea/modules/simple-jdbc-stats.main.iml index 578407e..50faa2e 100644 --- a/.idea/modules/simple-jdbc-stats.main.iml +++ b/.idea/modules/simple-jdbc-stats.main.iml @@ -1,15 +1,15 @@ - + - - + + \ No newline at end of file diff --git a/.idea/modules/simple-jdbc-stats.test.iml b/.idea/modules/simple-jdbc-stats.test.iml index 62ffcca..f5baeeb 100644 --- a/.idea/modules/simple-jdbc-stats.test.iml +++ b/.idea/modules/simple-jdbc-stats.test.iml @@ -1,7 +1,7 @@ - + @@ -10,8 +10,8 @@ - - + + diff --git a/build.gradle b/build.gradle index 8791f4a..559db71 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,6 @@ apply plugin: 'java' apply plugin: 'idea' apply plugin: 'maven' -apply plugin: 'findbugs' apply plugin: 'maven-publish' sourceSets { @@ -15,8 +14,8 @@ test.resources.srcDirs += 'test' } -sourceCompatibility = 1.5 -targetCompatibility = 1.5 +sourceCompatibility = 1.6 +targetCompatibility = 1.6 repositories { maven { @@ -24,18 +23,23 @@ } } +ext { + PUBLISH_GROUP_ID = group + PUBLISH_VERSION = version + PUBLISH_ARTIFACT_ID = name +} + +apply from: "${rootProject.projectDir}/scripts/publish-mavencentral.gradle" + dependencies { testCompile group: 'junit', name: 'junit', version: '4.12' - testCompile "org.slf4j:slf4j-simple:1.7.21" testCompile "com.h2database:h2:1.4.+" - compile "nl.astraeus.template:very-simple-templates:1.3" - compile "nl.astraeus.web:simple-web:0.3" - compile "org.slf4j:slf4j-api:1.7.21" + compile "com.samskivert:jmustache:1.15" + compile "org.nanohttpd:nanohttpd:2.2.0" configurations.compile.exclude module: 'javax.servlet-api' - configurations.compile.exclude module: 'slf4j-simple' } uploadArchives { @@ -51,10 +55,6 @@ } } -findbugs { - ignoreFailures = true -} - javadoc { failOnError = false } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 088b40b..bd4ca84 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip diff --git a/scripts/publish-mavencentral.gradle b/scripts/publish-mavencentral.gradle new file mode 100644 index 0000000..fae9b85 --- /dev/null +++ b/scripts/publish-mavencentral.gradle @@ -0,0 +1,121 @@ + +apply plugin: 'maven-publish' +apply plugin: 'signing' + +task publishSourcesJar(type: Jar) { + archiveClassifier.set('sources') + + // For pure Kotlin libraries, in case you have them + from sourceSets.main.java.srcDirs + //from sourceSets.main.kotlin.srcDirs +} + +task packageJavadoc(type: Jar) { + from javadoc + classifier = 'javadoc' +} + +artifacts { + archives publishSourcesJar +} + +File secretPropsFile = project.rootProject.file('local.properties') + +ext["signing.keyId"] = '' +ext["signing.password"] = '' +ext["signing.secretKeyRingFile"] = '' +ext["ossrhUsername"] = '' +ext["ossrhPassword"] = '' +ext["sonatypeStagingProfileId"] = '' + +if (secretPropsFile.exists()) { + Properties p = new Properties() + + new FileInputStream(secretPropsFile).withCloseable { is -> + p.load(is) + } + + p.each { name, value -> + ext[name] = value + } +} + +afterEvaluate { + publishing { + publications { + relase(MavenPublication) { + // The coordinates of the library, being set from variables that + // we'll set up later + groupId PUBLISH_GROUP_ID + artifactId PUBLISH_ARTIFACT_ID + version PUBLISH_VERSION + + // Two artifacts, the `aar` (or `jar`) and the sources + if (project.plugins.findPlugin("com.android.library")) { + artifact("$buildDir/outputs/aar/${project.getName()}-release.aar") + } else { + artifact("$buildDir/libs/${project.getName()}-${version}.jar") + } + artifact publishSourcesJar + artifact packageJavadoc + + // Mostly self-explanatory metadata + pom { + name = PUBLISH_ARTIFACT_ID + description = 'Simple JDBC wrapper for query statistics' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics' + licenses { + license { + name = 'MIT License' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics/blob/master/LICENCE.txt' + } + } + developers { + developer { + id = 'rnentjes' + name = 'Rien Nentjes' + email = 'info@nentjes.com' + } + // Add all other devs here... + } + // Version control info - if you're using GitHub, follow the format as seen here + scm { + connection = 'scm:git:github.com/rnentjes/Simple-jdbc-statistics.git' + developerConnection = 'scm:git:ssh://github.com/rnentjes/Simple-jdbc-statistics.git' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics.git/tree/main' + } + // A slightly hacky fix so that your POM will include any transitive dependencies + // that your library builds upon + /* + witXml { + def dependenciesNode = asNode().appendNode('dependencies') + + project.configurations.implementation.allDependencies.each { + def dependencyNode = dependenciesNode.appendNode('dependency') + dependencyNode.appendNode('groupId', it.group) + dependencyNode.appendNode('artifactId', it.name) + dependencyNode.appendNode('version', it.version) + } + }*/ + } + } + } + // The repository to publish to, Sonatype/MavenCentral + repositories { + maven { + // This is an arbitrary name, you may also use "mavencentral" or + // any other name that's descriptive for you + name = "sonatype" + url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" + credentials { + username ossrhUsername + password ossrhPassword + } + } + } + } +} + +signing { + sign publishing.publications +} diff --git a/src/nl/astraeus/jdbc/CallableStatementLogger.java b/src/nl/astraeus/jdbc/CallableStatementLogger.java index 2e9f173..39be81c 100644 --- a/src/nl/astraeus/jdbc/CallableStatementLogger.java +++ b/src/nl/astraeus/jdbc/CallableStatementLogger.java @@ -1,8 +1,5 @@ package nl.astraeus.jdbc; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; @@ -17,8 +14,6 @@ * Time: 9:48 PM */ public class CallableStatementLogger implements CallableStatement { - private final static Logger log = LoggerFactory.getLogger(PreparedStatementLogger.class); - private JdbcLogger logger; private CallableStatement statement; diff --git a/src/nl/astraeus/jdbc/Driver.java b/src/nl/astraeus/jdbc/Driver.java index 046d756..e230a06 100644 --- a/src/nl/astraeus/jdbc/Driver.java +++ b/src/nl/astraeus/jdbc/Driver.java @@ -11,44 +11,38 @@ import java.util.concurrent.ConcurrentHashMap; import nl.astraeus.jdbc.web.JdbcStatsMappingProvider; +import nl.astraeus.jdbc.web.NanoHttpdSimpleWeb; import nl.astraeus.jdbc.web.model.Settings; -import nl.astraeus.web.NanoHttpdSimpleWeb; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * User: riennentjes * Date: Jul 10, 2008 * Time: 8:54:37 PM - * + *

* Test a little change - * */ public class Driver implements java.sql.Driver { - private final static Logger log = LoggerFactory.getLogger(Driver.class); - - final private static String URL_PREFIX = "jdbc:stat:"; - final private static String URL_SECURE_PREFIX = "jdbc:secstat:"; + final private static String URL_PREFIX = "jdbc:stat:"; + final private static String URL_SECURE_PREFIX = "jdbc:secstat:"; public static class StatsLogger { - private volatile boolean started = false; - private NanoHttpdSimpleWeb server = null; - private java.sql.Driver driver = null; - private Settings settings = new Settings(); - private String targetUrl = null; + private volatile boolean started = false; + private NanoHttpdSimpleWeb server = null; + private java.sql.Driver driver = null; + private Settings settings = new Settings(); + private String targetUrl = null; public Settings getSettings() { return settings; } } - private static Map loggers = new ConcurrentHashMap(); - private static Map portMapping = new ConcurrentHashMap(); + private static Map loggers = new ConcurrentHashMap(); + private static Map portMapping = new ConcurrentHashMap(); public static StatsLogger get(String url) { if (!loggers.containsKey(url)) { - throw new IllegalArgumentException("No jdbc statistics logger found for url: "+url); + throw new IllegalArgumentException("No jdbc statistics logger found for url: " + url); } return loggers.get(url); @@ -56,7 +50,7 @@ public static StatsLogger get(int port) { if (!portMapping.containsKey(port)) { - throw new IllegalArgumentException("No jdbc statistics logger found on port: "+port); + throw new IllegalArgumentException("No jdbc statistics logger found on port: " + port); } return portMapping.get(port); @@ -75,7 +69,8 @@ "org.apache.derby.jdbc.EmbeddedDriver", "com.mysql.jdbc.Driver", "org.hsqldb.jdbcDriver", - "org.h2.Driver" }; + "org.h2.Driver" + }; static { log.debug("Loading driver class " + Driver.class.getName()); @@ -123,8 +118,8 @@ logger.settings.setSecure(true); } - String [] parts = url.split("\\:"); - String settingsString = "webServerConnections=5;numberOfQueries=2500;logStacktraces=true;formattedQueries=true"; + String[] parts = url.split("\\:"); + String settingsString = "webServerConnections=5;numberOfQueries=2500;logStacktraces=true;formattedQueries=true"; if (parts.length > 3) { settingsString = parts[2]; @@ -146,7 +141,7 @@ } if (logger.settings.isSecure()) { - String user = info.getProperty("user"); + String user = info.getProperty("user"); String password = info.getProperty("password"); if (user == null || password == null) { @@ -161,15 +156,21 @@ synchronized (this) { if (!logger.started) { try { - NanoHttpdSimpleWeb server = new NanoHttpdSimpleWeb(logger.settings.getWebServerPort(), new JdbcStatsMappingProvider()); + NanoHttpdSimpleWeb server = new NanoHttpdSimpleWeb( + logger.settings.getWebServerPort(), + new JdbcStatsMappingProvider() + ); server.start(); - System.out.println("Started Simple JDBC Statistics\n\turl: "+url+"\n\tport: "+logger.settings.getWebServerPort()); + System.out.println("Started Simple JDBC Statistics\n\turl: " + + url + + "\n\tport: " + + logger.settings.getWebServerPort()); logger.started = true; } catch (Exception e) { - log.error(e.getMessage(),e); + log.error(e.getMessage(), e); } } } diff --git a/src/nl/astraeus/jdbc/JdbcLogger.java b/src/nl/astraeus/jdbc/JdbcLogger.java index 44d09e6..ac7188a 100644 --- a/src/nl/astraeus/jdbc/JdbcLogger.java +++ b/src/nl/astraeus/jdbc/JdbcLogger.java @@ -1,15 +1,10 @@ package nl.astraeus.jdbc; import nl.astraeus.jdbc.util.Util; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import java.util.HashMap; -import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; @@ -19,8 +14,6 @@ * Time: 9:15:21 AM */ public class JdbcLogger { - private final static Logger logger = LoggerFactory.getLogger(JdbcLogger.class); - private final static Map instances = new ConcurrentHashMap(); public static JdbcLogger get(int port) { diff --git a/src/nl/astraeus/jdbc/PreparedStatementLogger.java b/src/nl/astraeus/jdbc/PreparedStatementLogger.java index f97959a..648fea0 100644 --- a/src/nl/astraeus/jdbc/PreparedStatementLogger.java +++ b/src/nl/astraeus/jdbc/PreparedStatementLogger.java @@ -1,8 +1,5 @@ package nl.astraeus.jdbc; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; @@ -25,12 +22,8 @@ import java.sql.Time; import java.sql.Timestamp; import java.util.Calendar; -import java.util.Comparator; -import java.util.HashSet; import java.util.Map; -import java.util.Set; import java.util.TreeMap; -import java.util.TreeSet; /** * User: riennentjes @@ -38,8 +31,6 @@ * Time: 7:47:57 PM */ public class PreparedStatementLogger implements PreparedStatement { - private final static Logger log = LoggerFactory.getLogger(PreparedStatementLogger.class); - private JdbcLogger logger; private PreparedStatement statement; diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 41cd493..f9ae410 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -17,7 +17,7 @@ - + diff --git a/.idea/libraries-with-intellij-classes.xml b/.idea/libraries-with-intellij-classes.xml new file mode 100644 index 0000000..9fa3156 --- /dev/null +++ b/.idea/libraries-with-intellij-classes.xml @@ -0,0 +1,65 @@ + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml new file mode 100644 index 0000000..c108f80 --- /dev/null +++ b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml b/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml deleted file mode 100644 index 9a00155..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml b/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml deleted file mode 100644 index 873c2c0..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml new file mode 100644 index 0000000..7d1fc19 --- /dev/null +++ b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index be926a3..6d93540 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,7 +8,7 @@ http://www.w3.org/1999/xhtml - + diff --git a/.idea/modules/simple-jdbc-stats.main.iml b/.idea/modules/simple-jdbc-stats.main.iml index 578407e..50faa2e 100644 --- a/.idea/modules/simple-jdbc-stats.main.iml +++ b/.idea/modules/simple-jdbc-stats.main.iml @@ -1,15 +1,15 @@ - + - - + + \ No newline at end of file diff --git a/.idea/modules/simple-jdbc-stats.test.iml b/.idea/modules/simple-jdbc-stats.test.iml index 62ffcca..f5baeeb 100644 --- a/.idea/modules/simple-jdbc-stats.test.iml +++ b/.idea/modules/simple-jdbc-stats.test.iml @@ -1,7 +1,7 @@ - + @@ -10,8 +10,8 @@ - - + + diff --git a/build.gradle b/build.gradle index 8791f4a..559db71 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,6 @@ apply plugin: 'java' apply plugin: 'idea' apply plugin: 'maven' -apply plugin: 'findbugs' apply plugin: 'maven-publish' sourceSets { @@ -15,8 +14,8 @@ test.resources.srcDirs += 'test' } -sourceCompatibility = 1.5 -targetCompatibility = 1.5 +sourceCompatibility = 1.6 +targetCompatibility = 1.6 repositories { maven { @@ -24,18 +23,23 @@ } } +ext { + PUBLISH_GROUP_ID = group + PUBLISH_VERSION = version + PUBLISH_ARTIFACT_ID = name +} + +apply from: "${rootProject.projectDir}/scripts/publish-mavencentral.gradle" + dependencies { testCompile group: 'junit', name: 'junit', version: '4.12' - testCompile "org.slf4j:slf4j-simple:1.7.21" testCompile "com.h2database:h2:1.4.+" - compile "nl.astraeus.template:very-simple-templates:1.3" - compile "nl.astraeus.web:simple-web:0.3" - compile "org.slf4j:slf4j-api:1.7.21" + compile "com.samskivert:jmustache:1.15" + compile "org.nanohttpd:nanohttpd:2.2.0" configurations.compile.exclude module: 'javax.servlet-api' - configurations.compile.exclude module: 'slf4j-simple' } uploadArchives { @@ -51,10 +55,6 @@ } } -findbugs { - ignoreFailures = true -} - javadoc { failOnError = false } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 088b40b..bd4ca84 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip diff --git a/scripts/publish-mavencentral.gradle b/scripts/publish-mavencentral.gradle new file mode 100644 index 0000000..fae9b85 --- /dev/null +++ b/scripts/publish-mavencentral.gradle @@ -0,0 +1,121 @@ + +apply plugin: 'maven-publish' +apply plugin: 'signing' + +task publishSourcesJar(type: Jar) { + archiveClassifier.set('sources') + + // For pure Kotlin libraries, in case you have them + from sourceSets.main.java.srcDirs + //from sourceSets.main.kotlin.srcDirs +} + +task packageJavadoc(type: Jar) { + from javadoc + classifier = 'javadoc' +} + +artifacts { + archives publishSourcesJar +} + +File secretPropsFile = project.rootProject.file('local.properties') + +ext["signing.keyId"] = '' +ext["signing.password"] = '' +ext["signing.secretKeyRingFile"] = '' +ext["ossrhUsername"] = '' +ext["ossrhPassword"] = '' +ext["sonatypeStagingProfileId"] = '' + +if (secretPropsFile.exists()) { + Properties p = new Properties() + + new FileInputStream(secretPropsFile).withCloseable { is -> + p.load(is) + } + + p.each { name, value -> + ext[name] = value + } +} + +afterEvaluate { + publishing { + publications { + relase(MavenPublication) { + // The coordinates of the library, being set from variables that + // we'll set up later + groupId PUBLISH_GROUP_ID + artifactId PUBLISH_ARTIFACT_ID + version PUBLISH_VERSION + + // Two artifacts, the `aar` (or `jar`) and the sources + if (project.plugins.findPlugin("com.android.library")) { + artifact("$buildDir/outputs/aar/${project.getName()}-release.aar") + } else { + artifact("$buildDir/libs/${project.getName()}-${version}.jar") + } + artifact publishSourcesJar + artifact packageJavadoc + + // Mostly self-explanatory metadata + pom { + name = PUBLISH_ARTIFACT_ID + description = 'Simple JDBC wrapper for query statistics' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics' + licenses { + license { + name = 'MIT License' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics/blob/master/LICENCE.txt' + } + } + developers { + developer { + id = 'rnentjes' + name = 'Rien Nentjes' + email = 'info@nentjes.com' + } + // Add all other devs here... + } + // Version control info - if you're using GitHub, follow the format as seen here + scm { + connection = 'scm:git:github.com/rnentjes/Simple-jdbc-statistics.git' + developerConnection = 'scm:git:ssh://github.com/rnentjes/Simple-jdbc-statistics.git' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics.git/tree/main' + } + // A slightly hacky fix so that your POM will include any transitive dependencies + // that your library builds upon + /* + witXml { + def dependenciesNode = asNode().appendNode('dependencies') + + project.configurations.implementation.allDependencies.each { + def dependencyNode = dependenciesNode.appendNode('dependency') + dependencyNode.appendNode('groupId', it.group) + dependencyNode.appendNode('artifactId', it.name) + dependencyNode.appendNode('version', it.version) + } + }*/ + } + } + } + // The repository to publish to, Sonatype/MavenCentral + repositories { + maven { + // This is an arbitrary name, you may also use "mavencentral" or + // any other name that's descriptive for you + name = "sonatype" + url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" + credentials { + username ossrhUsername + password ossrhPassword + } + } + } + } +} + +signing { + sign publishing.publications +} diff --git a/src/nl/astraeus/jdbc/CallableStatementLogger.java b/src/nl/astraeus/jdbc/CallableStatementLogger.java index 2e9f173..39be81c 100644 --- a/src/nl/astraeus/jdbc/CallableStatementLogger.java +++ b/src/nl/astraeus/jdbc/CallableStatementLogger.java @@ -1,8 +1,5 @@ package nl.astraeus.jdbc; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; @@ -17,8 +14,6 @@ * Time: 9:48 PM */ public class CallableStatementLogger implements CallableStatement { - private final static Logger log = LoggerFactory.getLogger(PreparedStatementLogger.class); - private JdbcLogger logger; private CallableStatement statement; diff --git a/src/nl/astraeus/jdbc/Driver.java b/src/nl/astraeus/jdbc/Driver.java index 046d756..e230a06 100644 --- a/src/nl/astraeus/jdbc/Driver.java +++ b/src/nl/astraeus/jdbc/Driver.java @@ -11,44 +11,38 @@ import java.util.concurrent.ConcurrentHashMap; import nl.astraeus.jdbc.web.JdbcStatsMappingProvider; +import nl.astraeus.jdbc.web.NanoHttpdSimpleWeb; import nl.astraeus.jdbc.web.model.Settings; -import nl.astraeus.web.NanoHttpdSimpleWeb; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * User: riennentjes * Date: Jul 10, 2008 * Time: 8:54:37 PM - * + *

* Test a little change - * */ public class Driver implements java.sql.Driver { - private final static Logger log = LoggerFactory.getLogger(Driver.class); - - final private static String URL_PREFIX = "jdbc:stat:"; - final private static String URL_SECURE_PREFIX = "jdbc:secstat:"; + final private static String URL_PREFIX = "jdbc:stat:"; + final private static String URL_SECURE_PREFIX = "jdbc:secstat:"; public static class StatsLogger { - private volatile boolean started = false; - private NanoHttpdSimpleWeb server = null; - private java.sql.Driver driver = null; - private Settings settings = new Settings(); - private String targetUrl = null; + private volatile boolean started = false; + private NanoHttpdSimpleWeb server = null; + private java.sql.Driver driver = null; + private Settings settings = new Settings(); + private String targetUrl = null; public Settings getSettings() { return settings; } } - private static Map loggers = new ConcurrentHashMap(); - private static Map portMapping = new ConcurrentHashMap(); + private static Map loggers = new ConcurrentHashMap(); + private static Map portMapping = new ConcurrentHashMap(); public static StatsLogger get(String url) { if (!loggers.containsKey(url)) { - throw new IllegalArgumentException("No jdbc statistics logger found for url: "+url); + throw new IllegalArgumentException("No jdbc statistics logger found for url: " + url); } return loggers.get(url); @@ -56,7 +50,7 @@ public static StatsLogger get(int port) { if (!portMapping.containsKey(port)) { - throw new IllegalArgumentException("No jdbc statistics logger found on port: "+port); + throw new IllegalArgumentException("No jdbc statistics logger found on port: " + port); } return portMapping.get(port); @@ -75,7 +69,8 @@ "org.apache.derby.jdbc.EmbeddedDriver", "com.mysql.jdbc.Driver", "org.hsqldb.jdbcDriver", - "org.h2.Driver" }; + "org.h2.Driver" + }; static { log.debug("Loading driver class " + Driver.class.getName()); @@ -123,8 +118,8 @@ logger.settings.setSecure(true); } - String [] parts = url.split("\\:"); - String settingsString = "webServerConnections=5;numberOfQueries=2500;logStacktraces=true;formattedQueries=true"; + String[] parts = url.split("\\:"); + String settingsString = "webServerConnections=5;numberOfQueries=2500;logStacktraces=true;formattedQueries=true"; if (parts.length > 3) { settingsString = parts[2]; @@ -146,7 +141,7 @@ } if (logger.settings.isSecure()) { - String user = info.getProperty("user"); + String user = info.getProperty("user"); String password = info.getProperty("password"); if (user == null || password == null) { @@ -161,15 +156,21 @@ synchronized (this) { if (!logger.started) { try { - NanoHttpdSimpleWeb server = new NanoHttpdSimpleWeb(logger.settings.getWebServerPort(), new JdbcStatsMappingProvider()); + NanoHttpdSimpleWeb server = new NanoHttpdSimpleWeb( + logger.settings.getWebServerPort(), + new JdbcStatsMappingProvider() + ); server.start(); - System.out.println("Started Simple JDBC Statistics\n\turl: "+url+"\n\tport: "+logger.settings.getWebServerPort()); + System.out.println("Started Simple JDBC Statistics\n\turl: " + + url + + "\n\tport: " + + logger.settings.getWebServerPort()); logger.started = true; } catch (Exception e) { - log.error(e.getMessage(),e); + log.error(e.getMessage(), e); } } } diff --git a/src/nl/astraeus/jdbc/JdbcLogger.java b/src/nl/astraeus/jdbc/JdbcLogger.java index 44d09e6..ac7188a 100644 --- a/src/nl/astraeus/jdbc/JdbcLogger.java +++ b/src/nl/astraeus/jdbc/JdbcLogger.java @@ -1,15 +1,10 @@ package nl.astraeus.jdbc; import nl.astraeus.jdbc.util.Util; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import java.util.HashMap; -import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; @@ -19,8 +14,6 @@ * Time: 9:15:21 AM */ public class JdbcLogger { - private final static Logger logger = LoggerFactory.getLogger(JdbcLogger.class); - private final static Map instances = new ConcurrentHashMap(); public static JdbcLogger get(int port) { diff --git a/src/nl/astraeus/jdbc/PreparedStatementLogger.java b/src/nl/astraeus/jdbc/PreparedStatementLogger.java index f97959a..648fea0 100644 --- a/src/nl/astraeus/jdbc/PreparedStatementLogger.java +++ b/src/nl/astraeus/jdbc/PreparedStatementLogger.java @@ -1,8 +1,5 @@ package nl.astraeus.jdbc; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; @@ -25,12 +22,8 @@ import java.sql.Time; import java.sql.Timestamp; import java.util.Calendar; -import java.util.Comparator; -import java.util.HashSet; import java.util.Map; -import java.util.Set; import java.util.TreeMap; -import java.util.TreeSet; /** * User: riennentjes @@ -38,8 +31,6 @@ * Time: 7:47:57 PM */ public class PreparedStatementLogger implements PreparedStatement { - private final static Logger log = LoggerFactory.getLogger(PreparedStatementLogger.class); - private JdbcLogger logger; private PreparedStatement statement; diff --git a/src/nl/astraeus/jdbc/SqlFormatter.java b/src/nl/astraeus/jdbc/SqlFormatter.java index e28810b..8129dfc 100644 --- a/src/nl/astraeus/jdbc/SqlFormatter.java +++ b/src/nl/astraeus/jdbc/SqlFormatter.java @@ -4,17 +4,12 @@ import java.util.List; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/18/12 * Time: 10:10 PM */ public class SqlFormatter { - private final static Logger logger = LoggerFactory.getLogger(SqlFormatter.class); - private static SqlTokenizer tokenizer = new SqlTokenizer(); private static enum Newline { diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 41cd493..f9ae410 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -17,7 +17,7 @@ - + diff --git a/.idea/libraries-with-intellij-classes.xml b/.idea/libraries-with-intellij-classes.xml new file mode 100644 index 0000000..9fa3156 --- /dev/null +++ b/.idea/libraries-with-intellij-classes.xml @@ -0,0 +1,65 @@ + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml new file mode 100644 index 0000000..c108f80 --- /dev/null +++ b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml b/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml deleted file mode 100644 index 9a00155..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml b/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml deleted file mode 100644 index 873c2c0..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml new file mode 100644 index 0000000..7d1fc19 --- /dev/null +++ b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index be926a3..6d93540 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,7 +8,7 @@ http://www.w3.org/1999/xhtml - + diff --git a/.idea/modules/simple-jdbc-stats.main.iml b/.idea/modules/simple-jdbc-stats.main.iml index 578407e..50faa2e 100644 --- a/.idea/modules/simple-jdbc-stats.main.iml +++ b/.idea/modules/simple-jdbc-stats.main.iml @@ -1,15 +1,15 @@ - + - - + + \ No newline at end of file diff --git a/.idea/modules/simple-jdbc-stats.test.iml b/.idea/modules/simple-jdbc-stats.test.iml index 62ffcca..f5baeeb 100644 --- a/.idea/modules/simple-jdbc-stats.test.iml +++ b/.idea/modules/simple-jdbc-stats.test.iml @@ -1,7 +1,7 @@ - + @@ -10,8 +10,8 @@ - - + + diff --git a/build.gradle b/build.gradle index 8791f4a..559db71 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,6 @@ apply plugin: 'java' apply plugin: 'idea' apply plugin: 'maven' -apply plugin: 'findbugs' apply plugin: 'maven-publish' sourceSets { @@ -15,8 +14,8 @@ test.resources.srcDirs += 'test' } -sourceCompatibility = 1.5 -targetCompatibility = 1.5 +sourceCompatibility = 1.6 +targetCompatibility = 1.6 repositories { maven { @@ -24,18 +23,23 @@ } } +ext { + PUBLISH_GROUP_ID = group + PUBLISH_VERSION = version + PUBLISH_ARTIFACT_ID = name +} + +apply from: "${rootProject.projectDir}/scripts/publish-mavencentral.gradle" + dependencies { testCompile group: 'junit', name: 'junit', version: '4.12' - testCompile "org.slf4j:slf4j-simple:1.7.21" testCompile "com.h2database:h2:1.4.+" - compile "nl.astraeus.template:very-simple-templates:1.3" - compile "nl.astraeus.web:simple-web:0.3" - compile "org.slf4j:slf4j-api:1.7.21" + compile "com.samskivert:jmustache:1.15" + compile "org.nanohttpd:nanohttpd:2.2.0" configurations.compile.exclude module: 'javax.servlet-api' - configurations.compile.exclude module: 'slf4j-simple' } uploadArchives { @@ -51,10 +55,6 @@ } } -findbugs { - ignoreFailures = true -} - javadoc { failOnError = false } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 088b40b..bd4ca84 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip diff --git a/scripts/publish-mavencentral.gradle b/scripts/publish-mavencentral.gradle new file mode 100644 index 0000000..fae9b85 --- /dev/null +++ b/scripts/publish-mavencentral.gradle @@ -0,0 +1,121 @@ + +apply plugin: 'maven-publish' +apply plugin: 'signing' + +task publishSourcesJar(type: Jar) { + archiveClassifier.set('sources') + + // For pure Kotlin libraries, in case you have them + from sourceSets.main.java.srcDirs + //from sourceSets.main.kotlin.srcDirs +} + +task packageJavadoc(type: Jar) { + from javadoc + classifier = 'javadoc' +} + +artifacts { + archives publishSourcesJar +} + +File secretPropsFile = project.rootProject.file('local.properties') + +ext["signing.keyId"] = '' +ext["signing.password"] = '' +ext["signing.secretKeyRingFile"] = '' +ext["ossrhUsername"] = '' +ext["ossrhPassword"] = '' +ext["sonatypeStagingProfileId"] = '' + +if (secretPropsFile.exists()) { + Properties p = new Properties() + + new FileInputStream(secretPropsFile).withCloseable { is -> + p.load(is) + } + + p.each { name, value -> + ext[name] = value + } +} + +afterEvaluate { + publishing { + publications { + relase(MavenPublication) { + // The coordinates of the library, being set from variables that + // we'll set up later + groupId PUBLISH_GROUP_ID + artifactId PUBLISH_ARTIFACT_ID + version PUBLISH_VERSION + + // Two artifacts, the `aar` (or `jar`) and the sources + if (project.plugins.findPlugin("com.android.library")) { + artifact("$buildDir/outputs/aar/${project.getName()}-release.aar") + } else { + artifact("$buildDir/libs/${project.getName()}-${version}.jar") + } + artifact publishSourcesJar + artifact packageJavadoc + + // Mostly self-explanatory metadata + pom { + name = PUBLISH_ARTIFACT_ID + description = 'Simple JDBC wrapper for query statistics' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics' + licenses { + license { + name = 'MIT License' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics/blob/master/LICENCE.txt' + } + } + developers { + developer { + id = 'rnentjes' + name = 'Rien Nentjes' + email = 'info@nentjes.com' + } + // Add all other devs here... + } + // Version control info - if you're using GitHub, follow the format as seen here + scm { + connection = 'scm:git:github.com/rnentjes/Simple-jdbc-statistics.git' + developerConnection = 'scm:git:ssh://github.com/rnentjes/Simple-jdbc-statistics.git' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics.git/tree/main' + } + // A slightly hacky fix so that your POM will include any transitive dependencies + // that your library builds upon + /* + witXml { + def dependenciesNode = asNode().appendNode('dependencies') + + project.configurations.implementation.allDependencies.each { + def dependencyNode = dependenciesNode.appendNode('dependency') + dependencyNode.appendNode('groupId', it.group) + dependencyNode.appendNode('artifactId', it.name) + dependencyNode.appendNode('version', it.version) + } + }*/ + } + } + } + // The repository to publish to, Sonatype/MavenCentral + repositories { + maven { + // This is an arbitrary name, you may also use "mavencentral" or + // any other name that's descriptive for you + name = "sonatype" + url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" + credentials { + username ossrhUsername + password ossrhPassword + } + } + } + } +} + +signing { + sign publishing.publications +} diff --git a/src/nl/astraeus/jdbc/CallableStatementLogger.java b/src/nl/astraeus/jdbc/CallableStatementLogger.java index 2e9f173..39be81c 100644 --- a/src/nl/astraeus/jdbc/CallableStatementLogger.java +++ b/src/nl/astraeus/jdbc/CallableStatementLogger.java @@ -1,8 +1,5 @@ package nl.astraeus.jdbc; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; @@ -17,8 +14,6 @@ * Time: 9:48 PM */ public class CallableStatementLogger implements CallableStatement { - private final static Logger log = LoggerFactory.getLogger(PreparedStatementLogger.class); - private JdbcLogger logger; private CallableStatement statement; diff --git a/src/nl/astraeus/jdbc/Driver.java b/src/nl/astraeus/jdbc/Driver.java index 046d756..e230a06 100644 --- a/src/nl/astraeus/jdbc/Driver.java +++ b/src/nl/astraeus/jdbc/Driver.java @@ -11,44 +11,38 @@ import java.util.concurrent.ConcurrentHashMap; import nl.astraeus.jdbc.web.JdbcStatsMappingProvider; +import nl.astraeus.jdbc.web.NanoHttpdSimpleWeb; import nl.astraeus.jdbc.web.model.Settings; -import nl.astraeus.web.NanoHttpdSimpleWeb; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * User: riennentjes * Date: Jul 10, 2008 * Time: 8:54:37 PM - * + *

* Test a little change - * */ public class Driver implements java.sql.Driver { - private final static Logger log = LoggerFactory.getLogger(Driver.class); - - final private static String URL_PREFIX = "jdbc:stat:"; - final private static String URL_SECURE_PREFIX = "jdbc:secstat:"; + final private static String URL_PREFIX = "jdbc:stat:"; + final private static String URL_SECURE_PREFIX = "jdbc:secstat:"; public static class StatsLogger { - private volatile boolean started = false; - private NanoHttpdSimpleWeb server = null; - private java.sql.Driver driver = null; - private Settings settings = new Settings(); - private String targetUrl = null; + private volatile boolean started = false; + private NanoHttpdSimpleWeb server = null; + private java.sql.Driver driver = null; + private Settings settings = new Settings(); + private String targetUrl = null; public Settings getSettings() { return settings; } } - private static Map loggers = new ConcurrentHashMap(); - private static Map portMapping = new ConcurrentHashMap(); + private static Map loggers = new ConcurrentHashMap(); + private static Map portMapping = new ConcurrentHashMap(); public static StatsLogger get(String url) { if (!loggers.containsKey(url)) { - throw new IllegalArgumentException("No jdbc statistics logger found for url: "+url); + throw new IllegalArgumentException("No jdbc statistics logger found for url: " + url); } return loggers.get(url); @@ -56,7 +50,7 @@ public static StatsLogger get(int port) { if (!portMapping.containsKey(port)) { - throw new IllegalArgumentException("No jdbc statistics logger found on port: "+port); + throw new IllegalArgumentException("No jdbc statistics logger found on port: " + port); } return portMapping.get(port); @@ -75,7 +69,8 @@ "org.apache.derby.jdbc.EmbeddedDriver", "com.mysql.jdbc.Driver", "org.hsqldb.jdbcDriver", - "org.h2.Driver" }; + "org.h2.Driver" + }; static { log.debug("Loading driver class " + Driver.class.getName()); @@ -123,8 +118,8 @@ logger.settings.setSecure(true); } - String [] parts = url.split("\\:"); - String settingsString = "webServerConnections=5;numberOfQueries=2500;logStacktraces=true;formattedQueries=true"; + String[] parts = url.split("\\:"); + String settingsString = "webServerConnections=5;numberOfQueries=2500;logStacktraces=true;formattedQueries=true"; if (parts.length > 3) { settingsString = parts[2]; @@ -146,7 +141,7 @@ } if (logger.settings.isSecure()) { - String user = info.getProperty("user"); + String user = info.getProperty("user"); String password = info.getProperty("password"); if (user == null || password == null) { @@ -161,15 +156,21 @@ synchronized (this) { if (!logger.started) { try { - NanoHttpdSimpleWeb server = new NanoHttpdSimpleWeb(logger.settings.getWebServerPort(), new JdbcStatsMappingProvider()); + NanoHttpdSimpleWeb server = new NanoHttpdSimpleWeb( + logger.settings.getWebServerPort(), + new JdbcStatsMappingProvider() + ); server.start(); - System.out.println("Started Simple JDBC Statistics\n\turl: "+url+"\n\tport: "+logger.settings.getWebServerPort()); + System.out.println("Started Simple JDBC Statistics\n\turl: " + + url + + "\n\tport: " + + logger.settings.getWebServerPort()); logger.started = true; } catch (Exception e) { - log.error(e.getMessage(),e); + log.error(e.getMessage(), e); } } } diff --git a/src/nl/astraeus/jdbc/JdbcLogger.java b/src/nl/astraeus/jdbc/JdbcLogger.java index 44d09e6..ac7188a 100644 --- a/src/nl/astraeus/jdbc/JdbcLogger.java +++ b/src/nl/astraeus/jdbc/JdbcLogger.java @@ -1,15 +1,10 @@ package nl.astraeus.jdbc; import nl.astraeus.jdbc.util.Util; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import java.util.HashMap; -import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; @@ -19,8 +14,6 @@ * Time: 9:15:21 AM */ public class JdbcLogger { - private final static Logger logger = LoggerFactory.getLogger(JdbcLogger.class); - private final static Map instances = new ConcurrentHashMap(); public static JdbcLogger get(int port) { diff --git a/src/nl/astraeus/jdbc/PreparedStatementLogger.java b/src/nl/astraeus/jdbc/PreparedStatementLogger.java index f97959a..648fea0 100644 --- a/src/nl/astraeus/jdbc/PreparedStatementLogger.java +++ b/src/nl/astraeus/jdbc/PreparedStatementLogger.java @@ -1,8 +1,5 @@ package nl.astraeus.jdbc; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; @@ -25,12 +22,8 @@ import java.sql.Time; import java.sql.Timestamp; import java.util.Calendar; -import java.util.Comparator; -import java.util.HashSet; import java.util.Map; -import java.util.Set; import java.util.TreeMap; -import java.util.TreeSet; /** * User: riennentjes @@ -38,8 +31,6 @@ * Time: 7:47:57 PM */ public class PreparedStatementLogger implements PreparedStatement { - private final static Logger log = LoggerFactory.getLogger(PreparedStatementLogger.class); - private JdbcLogger logger; private PreparedStatement statement; diff --git a/src/nl/astraeus/jdbc/SqlFormatter.java b/src/nl/astraeus/jdbc/SqlFormatter.java index e28810b..8129dfc 100644 --- a/src/nl/astraeus/jdbc/SqlFormatter.java +++ b/src/nl/astraeus/jdbc/SqlFormatter.java @@ -4,17 +4,12 @@ import java.util.List; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/18/12 * Time: 10:10 PM */ public class SqlFormatter { - private final static Logger logger = LoggerFactory.getLogger(SqlFormatter.class); - private static SqlTokenizer tokenizer = new SqlTokenizer(); private static enum Newline { diff --git a/src/nl/astraeus/jdbc/thread/JvmSampler.java b/src/nl/astraeus/jdbc/thread/JvmSampler.java index f1b98d6..155c4ee 100644 --- a/src/nl/astraeus/jdbc/thread/JvmSampler.java +++ b/src/nl/astraeus/jdbc/thread/JvmSampler.java @@ -5,17 +5,12 @@ import java.util.Set; import java.util.TreeSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/22/13 * Time: 8:52 PM */ public class JvmSampler extends Thread { - private final static Logger logger = LoggerFactory.getLogger(JvmSampler.class); - private boolean stopped; private boolean running; diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 41cd493..f9ae410 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -17,7 +17,7 @@ - + diff --git a/.idea/libraries-with-intellij-classes.xml b/.idea/libraries-with-intellij-classes.xml new file mode 100644 index 0000000..9fa3156 --- /dev/null +++ b/.idea/libraries-with-intellij-classes.xml @@ -0,0 +1,65 @@ + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml new file mode 100644 index 0000000..c108f80 --- /dev/null +++ b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml b/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml deleted file mode 100644 index 9a00155..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml b/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml deleted file mode 100644 index 873c2c0..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml new file mode 100644 index 0000000..7d1fc19 --- /dev/null +++ b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index be926a3..6d93540 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,7 +8,7 @@ http://www.w3.org/1999/xhtml - + diff --git a/.idea/modules/simple-jdbc-stats.main.iml b/.idea/modules/simple-jdbc-stats.main.iml index 578407e..50faa2e 100644 --- a/.idea/modules/simple-jdbc-stats.main.iml +++ b/.idea/modules/simple-jdbc-stats.main.iml @@ -1,15 +1,15 @@ - + - - + + \ No newline at end of file diff --git a/.idea/modules/simple-jdbc-stats.test.iml b/.idea/modules/simple-jdbc-stats.test.iml index 62ffcca..f5baeeb 100644 --- a/.idea/modules/simple-jdbc-stats.test.iml +++ b/.idea/modules/simple-jdbc-stats.test.iml @@ -1,7 +1,7 @@ - + @@ -10,8 +10,8 @@ - - + + diff --git a/build.gradle b/build.gradle index 8791f4a..559db71 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,6 @@ apply plugin: 'java' apply plugin: 'idea' apply plugin: 'maven' -apply plugin: 'findbugs' apply plugin: 'maven-publish' sourceSets { @@ -15,8 +14,8 @@ test.resources.srcDirs += 'test' } -sourceCompatibility = 1.5 -targetCompatibility = 1.5 +sourceCompatibility = 1.6 +targetCompatibility = 1.6 repositories { maven { @@ -24,18 +23,23 @@ } } +ext { + PUBLISH_GROUP_ID = group + PUBLISH_VERSION = version + PUBLISH_ARTIFACT_ID = name +} + +apply from: "${rootProject.projectDir}/scripts/publish-mavencentral.gradle" + dependencies { testCompile group: 'junit', name: 'junit', version: '4.12' - testCompile "org.slf4j:slf4j-simple:1.7.21" testCompile "com.h2database:h2:1.4.+" - compile "nl.astraeus.template:very-simple-templates:1.3" - compile "nl.astraeus.web:simple-web:0.3" - compile "org.slf4j:slf4j-api:1.7.21" + compile "com.samskivert:jmustache:1.15" + compile "org.nanohttpd:nanohttpd:2.2.0" configurations.compile.exclude module: 'javax.servlet-api' - configurations.compile.exclude module: 'slf4j-simple' } uploadArchives { @@ -51,10 +55,6 @@ } } -findbugs { - ignoreFailures = true -} - javadoc { failOnError = false } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 088b40b..bd4ca84 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip diff --git a/scripts/publish-mavencentral.gradle b/scripts/publish-mavencentral.gradle new file mode 100644 index 0000000..fae9b85 --- /dev/null +++ b/scripts/publish-mavencentral.gradle @@ -0,0 +1,121 @@ + +apply plugin: 'maven-publish' +apply plugin: 'signing' + +task publishSourcesJar(type: Jar) { + archiveClassifier.set('sources') + + // For pure Kotlin libraries, in case you have them + from sourceSets.main.java.srcDirs + //from sourceSets.main.kotlin.srcDirs +} + +task packageJavadoc(type: Jar) { + from javadoc + classifier = 'javadoc' +} + +artifacts { + archives publishSourcesJar +} + +File secretPropsFile = project.rootProject.file('local.properties') + +ext["signing.keyId"] = '' +ext["signing.password"] = '' +ext["signing.secretKeyRingFile"] = '' +ext["ossrhUsername"] = '' +ext["ossrhPassword"] = '' +ext["sonatypeStagingProfileId"] = '' + +if (secretPropsFile.exists()) { + Properties p = new Properties() + + new FileInputStream(secretPropsFile).withCloseable { is -> + p.load(is) + } + + p.each { name, value -> + ext[name] = value + } +} + +afterEvaluate { + publishing { + publications { + relase(MavenPublication) { + // The coordinates of the library, being set from variables that + // we'll set up later + groupId PUBLISH_GROUP_ID + artifactId PUBLISH_ARTIFACT_ID + version PUBLISH_VERSION + + // Two artifacts, the `aar` (or `jar`) and the sources + if (project.plugins.findPlugin("com.android.library")) { + artifact("$buildDir/outputs/aar/${project.getName()}-release.aar") + } else { + artifact("$buildDir/libs/${project.getName()}-${version}.jar") + } + artifact publishSourcesJar + artifact packageJavadoc + + // Mostly self-explanatory metadata + pom { + name = PUBLISH_ARTIFACT_ID + description = 'Simple JDBC wrapper for query statistics' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics' + licenses { + license { + name = 'MIT License' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics/blob/master/LICENCE.txt' + } + } + developers { + developer { + id = 'rnentjes' + name = 'Rien Nentjes' + email = 'info@nentjes.com' + } + // Add all other devs here... + } + // Version control info - if you're using GitHub, follow the format as seen here + scm { + connection = 'scm:git:github.com/rnentjes/Simple-jdbc-statistics.git' + developerConnection = 'scm:git:ssh://github.com/rnentjes/Simple-jdbc-statistics.git' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics.git/tree/main' + } + // A slightly hacky fix so that your POM will include any transitive dependencies + // that your library builds upon + /* + witXml { + def dependenciesNode = asNode().appendNode('dependencies') + + project.configurations.implementation.allDependencies.each { + def dependencyNode = dependenciesNode.appendNode('dependency') + dependencyNode.appendNode('groupId', it.group) + dependencyNode.appendNode('artifactId', it.name) + dependencyNode.appendNode('version', it.version) + } + }*/ + } + } + } + // The repository to publish to, Sonatype/MavenCentral + repositories { + maven { + // This is an arbitrary name, you may also use "mavencentral" or + // any other name that's descriptive for you + name = "sonatype" + url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" + credentials { + username ossrhUsername + password ossrhPassword + } + } + } + } +} + +signing { + sign publishing.publications +} diff --git a/src/nl/astraeus/jdbc/CallableStatementLogger.java b/src/nl/astraeus/jdbc/CallableStatementLogger.java index 2e9f173..39be81c 100644 --- a/src/nl/astraeus/jdbc/CallableStatementLogger.java +++ b/src/nl/astraeus/jdbc/CallableStatementLogger.java @@ -1,8 +1,5 @@ package nl.astraeus.jdbc; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; @@ -17,8 +14,6 @@ * Time: 9:48 PM */ public class CallableStatementLogger implements CallableStatement { - private final static Logger log = LoggerFactory.getLogger(PreparedStatementLogger.class); - private JdbcLogger logger; private CallableStatement statement; diff --git a/src/nl/astraeus/jdbc/Driver.java b/src/nl/astraeus/jdbc/Driver.java index 046d756..e230a06 100644 --- a/src/nl/astraeus/jdbc/Driver.java +++ b/src/nl/astraeus/jdbc/Driver.java @@ -11,44 +11,38 @@ import java.util.concurrent.ConcurrentHashMap; import nl.astraeus.jdbc.web.JdbcStatsMappingProvider; +import nl.astraeus.jdbc.web.NanoHttpdSimpleWeb; import nl.astraeus.jdbc.web.model.Settings; -import nl.astraeus.web.NanoHttpdSimpleWeb; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * User: riennentjes * Date: Jul 10, 2008 * Time: 8:54:37 PM - * + *

* Test a little change - * */ public class Driver implements java.sql.Driver { - private final static Logger log = LoggerFactory.getLogger(Driver.class); - - final private static String URL_PREFIX = "jdbc:stat:"; - final private static String URL_SECURE_PREFIX = "jdbc:secstat:"; + final private static String URL_PREFIX = "jdbc:stat:"; + final private static String URL_SECURE_PREFIX = "jdbc:secstat:"; public static class StatsLogger { - private volatile boolean started = false; - private NanoHttpdSimpleWeb server = null; - private java.sql.Driver driver = null; - private Settings settings = new Settings(); - private String targetUrl = null; + private volatile boolean started = false; + private NanoHttpdSimpleWeb server = null; + private java.sql.Driver driver = null; + private Settings settings = new Settings(); + private String targetUrl = null; public Settings getSettings() { return settings; } } - private static Map loggers = new ConcurrentHashMap(); - private static Map portMapping = new ConcurrentHashMap(); + private static Map loggers = new ConcurrentHashMap(); + private static Map portMapping = new ConcurrentHashMap(); public static StatsLogger get(String url) { if (!loggers.containsKey(url)) { - throw new IllegalArgumentException("No jdbc statistics logger found for url: "+url); + throw new IllegalArgumentException("No jdbc statistics logger found for url: " + url); } return loggers.get(url); @@ -56,7 +50,7 @@ public static StatsLogger get(int port) { if (!portMapping.containsKey(port)) { - throw new IllegalArgumentException("No jdbc statistics logger found on port: "+port); + throw new IllegalArgumentException("No jdbc statistics logger found on port: " + port); } return portMapping.get(port); @@ -75,7 +69,8 @@ "org.apache.derby.jdbc.EmbeddedDriver", "com.mysql.jdbc.Driver", "org.hsqldb.jdbcDriver", - "org.h2.Driver" }; + "org.h2.Driver" + }; static { log.debug("Loading driver class " + Driver.class.getName()); @@ -123,8 +118,8 @@ logger.settings.setSecure(true); } - String [] parts = url.split("\\:"); - String settingsString = "webServerConnections=5;numberOfQueries=2500;logStacktraces=true;formattedQueries=true"; + String[] parts = url.split("\\:"); + String settingsString = "webServerConnections=5;numberOfQueries=2500;logStacktraces=true;formattedQueries=true"; if (parts.length > 3) { settingsString = parts[2]; @@ -146,7 +141,7 @@ } if (logger.settings.isSecure()) { - String user = info.getProperty("user"); + String user = info.getProperty("user"); String password = info.getProperty("password"); if (user == null || password == null) { @@ -161,15 +156,21 @@ synchronized (this) { if (!logger.started) { try { - NanoHttpdSimpleWeb server = new NanoHttpdSimpleWeb(logger.settings.getWebServerPort(), new JdbcStatsMappingProvider()); + NanoHttpdSimpleWeb server = new NanoHttpdSimpleWeb( + logger.settings.getWebServerPort(), + new JdbcStatsMappingProvider() + ); server.start(); - System.out.println("Started Simple JDBC Statistics\n\turl: "+url+"\n\tport: "+logger.settings.getWebServerPort()); + System.out.println("Started Simple JDBC Statistics\n\turl: " + + url + + "\n\tport: " + + logger.settings.getWebServerPort()); logger.started = true; } catch (Exception e) { - log.error(e.getMessage(),e); + log.error(e.getMessage(), e); } } } diff --git a/src/nl/astraeus/jdbc/JdbcLogger.java b/src/nl/astraeus/jdbc/JdbcLogger.java index 44d09e6..ac7188a 100644 --- a/src/nl/astraeus/jdbc/JdbcLogger.java +++ b/src/nl/astraeus/jdbc/JdbcLogger.java @@ -1,15 +1,10 @@ package nl.astraeus.jdbc; import nl.astraeus.jdbc.util.Util; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import java.util.HashMap; -import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; @@ -19,8 +14,6 @@ * Time: 9:15:21 AM */ public class JdbcLogger { - private final static Logger logger = LoggerFactory.getLogger(JdbcLogger.class); - private final static Map instances = new ConcurrentHashMap(); public static JdbcLogger get(int port) { diff --git a/src/nl/astraeus/jdbc/PreparedStatementLogger.java b/src/nl/astraeus/jdbc/PreparedStatementLogger.java index f97959a..648fea0 100644 --- a/src/nl/astraeus/jdbc/PreparedStatementLogger.java +++ b/src/nl/astraeus/jdbc/PreparedStatementLogger.java @@ -1,8 +1,5 @@ package nl.astraeus.jdbc; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; @@ -25,12 +22,8 @@ import java.sql.Time; import java.sql.Timestamp; import java.util.Calendar; -import java.util.Comparator; -import java.util.HashSet; import java.util.Map; -import java.util.Set; import java.util.TreeMap; -import java.util.TreeSet; /** * User: riennentjes @@ -38,8 +31,6 @@ * Time: 7:47:57 PM */ public class PreparedStatementLogger implements PreparedStatement { - private final static Logger log = LoggerFactory.getLogger(PreparedStatementLogger.class); - private JdbcLogger logger; private PreparedStatement statement; diff --git a/src/nl/astraeus/jdbc/SqlFormatter.java b/src/nl/astraeus/jdbc/SqlFormatter.java index e28810b..8129dfc 100644 --- a/src/nl/astraeus/jdbc/SqlFormatter.java +++ b/src/nl/astraeus/jdbc/SqlFormatter.java @@ -4,17 +4,12 @@ import java.util.List; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/18/12 * Time: 10:10 PM */ public class SqlFormatter { - private final static Logger logger = LoggerFactory.getLogger(SqlFormatter.class); - private static SqlTokenizer tokenizer = new SqlTokenizer(); private static enum Newline { diff --git a/src/nl/astraeus/jdbc/thread/JvmSampler.java b/src/nl/astraeus/jdbc/thread/JvmSampler.java index f1b98d6..155c4ee 100644 --- a/src/nl/astraeus/jdbc/thread/JvmSampler.java +++ b/src/nl/astraeus/jdbc/thread/JvmSampler.java @@ -5,17 +5,12 @@ import java.util.Set; import java.util.TreeSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/22/13 * Time: 8:52 PM */ public class JvmSampler extends Thread { - private final static Logger logger = LoggerFactory.getLogger(JvmSampler.class); - private boolean stopped; private boolean running; diff --git a/src/nl/astraeus/jdbc/util/ReflectHelper.java b/src/nl/astraeus/jdbc/util/ReflectHelper.java index eac090f..7582e04 100644 --- a/src/nl/astraeus/jdbc/util/ReflectHelper.java +++ b/src/nl/astraeus/jdbc/util/ReflectHelper.java @@ -9,17 +9,12 @@ import java.util.List; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 10/16/13 * Time: 4:49 PM */ public class ReflectHelper { - private final static Logger logger = LoggerFactory.getLogger(ReflectHelper.class); - private final static ReflectHelper instance = new ReflectHelper(); public static ReflectHelper get() { diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 41cd493..f9ae410 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -17,7 +17,7 @@ - + diff --git a/.idea/libraries-with-intellij-classes.xml b/.idea/libraries-with-intellij-classes.xml new file mode 100644 index 0000000..9fa3156 --- /dev/null +++ b/.idea/libraries-with-intellij-classes.xml @@ -0,0 +1,65 @@ + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml new file mode 100644 index 0000000..c108f80 --- /dev/null +++ b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml b/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml deleted file mode 100644 index 9a00155..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml b/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml deleted file mode 100644 index 873c2c0..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml new file mode 100644 index 0000000..7d1fc19 --- /dev/null +++ b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index be926a3..6d93540 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,7 +8,7 @@ http://www.w3.org/1999/xhtml - + diff --git a/.idea/modules/simple-jdbc-stats.main.iml b/.idea/modules/simple-jdbc-stats.main.iml index 578407e..50faa2e 100644 --- a/.idea/modules/simple-jdbc-stats.main.iml +++ b/.idea/modules/simple-jdbc-stats.main.iml @@ -1,15 +1,15 @@ - + - - + + \ No newline at end of file diff --git a/.idea/modules/simple-jdbc-stats.test.iml b/.idea/modules/simple-jdbc-stats.test.iml index 62ffcca..f5baeeb 100644 --- a/.idea/modules/simple-jdbc-stats.test.iml +++ b/.idea/modules/simple-jdbc-stats.test.iml @@ -1,7 +1,7 @@ - + @@ -10,8 +10,8 @@ - - + + diff --git a/build.gradle b/build.gradle index 8791f4a..559db71 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,6 @@ apply plugin: 'java' apply plugin: 'idea' apply plugin: 'maven' -apply plugin: 'findbugs' apply plugin: 'maven-publish' sourceSets { @@ -15,8 +14,8 @@ test.resources.srcDirs += 'test' } -sourceCompatibility = 1.5 -targetCompatibility = 1.5 +sourceCompatibility = 1.6 +targetCompatibility = 1.6 repositories { maven { @@ -24,18 +23,23 @@ } } +ext { + PUBLISH_GROUP_ID = group + PUBLISH_VERSION = version + PUBLISH_ARTIFACT_ID = name +} + +apply from: "${rootProject.projectDir}/scripts/publish-mavencentral.gradle" + dependencies { testCompile group: 'junit', name: 'junit', version: '4.12' - testCompile "org.slf4j:slf4j-simple:1.7.21" testCompile "com.h2database:h2:1.4.+" - compile "nl.astraeus.template:very-simple-templates:1.3" - compile "nl.astraeus.web:simple-web:0.3" - compile "org.slf4j:slf4j-api:1.7.21" + compile "com.samskivert:jmustache:1.15" + compile "org.nanohttpd:nanohttpd:2.2.0" configurations.compile.exclude module: 'javax.servlet-api' - configurations.compile.exclude module: 'slf4j-simple' } uploadArchives { @@ -51,10 +55,6 @@ } } -findbugs { - ignoreFailures = true -} - javadoc { failOnError = false } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 088b40b..bd4ca84 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip diff --git a/scripts/publish-mavencentral.gradle b/scripts/publish-mavencentral.gradle new file mode 100644 index 0000000..fae9b85 --- /dev/null +++ b/scripts/publish-mavencentral.gradle @@ -0,0 +1,121 @@ + +apply plugin: 'maven-publish' +apply plugin: 'signing' + +task publishSourcesJar(type: Jar) { + archiveClassifier.set('sources') + + // For pure Kotlin libraries, in case you have them + from sourceSets.main.java.srcDirs + //from sourceSets.main.kotlin.srcDirs +} + +task packageJavadoc(type: Jar) { + from javadoc + classifier = 'javadoc' +} + +artifacts { + archives publishSourcesJar +} + +File secretPropsFile = project.rootProject.file('local.properties') + +ext["signing.keyId"] = '' +ext["signing.password"] = '' +ext["signing.secretKeyRingFile"] = '' +ext["ossrhUsername"] = '' +ext["ossrhPassword"] = '' +ext["sonatypeStagingProfileId"] = '' + +if (secretPropsFile.exists()) { + Properties p = new Properties() + + new FileInputStream(secretPropsFile).withCloseable { is -> + p.load(is) + } + + p.each { name, value -> + ext[name] = value + } +} + +afterEvaluate { + publishing { + publications { + relase(MavenPublication) { + // The coordinates of the library, being set from variables that + // we'll set up later + groupId PUBLISH_GROUP_ID + artifactId PUBLISH_ARTIFACT_ID + version PUBLISH_VERSION + + // Two artifacts, the `aar` (or `jar`) and the sources + if (project.plugins.findPlugin("com.android.library")) { + artifact("$buildDir/outputs/aar/${project.getName()}-release.aar") + } else { + artifact("$buildDir/libs/${project.getName()}-${version}.jar") + } + artifact publishSourcesJar + artifact packageJavadoc + + // Mostly self-explanatory metadata + pom { + name = PUBLISH_ARTIFACT_ID + description = 'Simple JDBC wrapper for query statistics' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics' + licenses { + license { + name = 'MIT License' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics/blob/master/LICENCE.txt' + } + } + developers { + developer { + id = 'rnentjes' + name = 'Rien Nentjes' + email = 'info@nentjes.com' + } + // Add all other devs here... + } + // Version control info - if you're using GitHub, follow the format as seen here + scm { + connection = 'scm:git:github.com/rnentjes/Simple-jdbc-statistics.git' + developerConnection = 'scm:git:ssh://github.com/rnentjes/Simple-jdbc-statistics.git' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics.git/tree/main' + } + // A slightly hacky fix so that your POM will include any transitive dependencies + // that your library builds upon + /* + witXml { + def dependenciesNode = asNode().appendNode('dependencies') + + project.configurations.implementation.allDependencies.each { + def dependencyNode = dependenciesNode.appendNode('dependency') + dependencyNode.appendNode('groupId', it.group) + dependencyNode.appendNode('artifactId', it.name) + dependencyNode.appendNode('version', it.version) + } + }*/ + } + } + } + // The repository to publish to, Sonatype/MavenCentral + repositories { + maven { + // This is an arbitrary name, you may also use "mavencentral" or + // any other name that's descriptive for you + name = "sonatype" + url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" + credentials { + username ossrhUsername + password ossrhPassword + } + } + } + } +} + +signing { + sign publishing.publications +} diff --git a/src/nl/astraeus/jdbc/CallableStatementLogger.java b/src/nl/astraeus/jdbc/CallableStatementLogger.java index 2e9f173..39be81c 100644 --- a/src/nl/astraeus/jdbc/CallableStatementLogger.java +++ b/src/nl/astraeus/jdbc/CallableStatementLogger.java @@ -1,8 +1,5 @@ package nl.astraeus.jdbc; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; @@ -17,8 +14,6 @@ * Time: 9:48 PM */ public class CallableStatementLogger implements CallableStatement { - private final static Logger log = LoggerFactory.getLogger(PreparedStatementLogger.class); - private JdbcLogger logger; private CallableStatement statement; diff --git a/src/nl/astraeus/jdbc/Driver.java b/src/nl/astraeus/jdbc/Driver.java index 046d756..e230a06 100644 --- a/src/nl/astraeus/jdbc/Driver.java +++ b/src/nl/astraeus/jdbc/Driver.java @@ -11,44 +11,38 @@ import java.util.concurrent.ConcurrentHashMap; import nl.astraeus.jdbc.web.JdbcStatsMappingProvider; +import nl.astraeus.jdbc.web.NanoHttpdSimpleWeb; import nl.astraeus.jdbc.web.model.Settings; -import nl.astraeus.web.NanoHttpdSimpleWeb; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * User: riennentjes * Date: Jul 10, 2008 * Time: 8:54:37 PM - * + *

* Test a little change - * */ public class Driver implements java.sql.Driver { - private final static Logger log = LoggerFactory.getLogger(Driver.class); - - final private static String URL_PREFIX = "jdbc:stat:"; - final private static String URL_SECURE_PREFIX = "jdbc:secstat:"; + final private static String URL_PREFIX = "jdbc:stat:"; + final private static String URL_SECURE_PREFIX = "jdbc:secstat:"; public static class StatsLogger { - private volatile boolean started = false; - private NanoHttpdSimpleWeb server = null; - private java.sql.Driver driver = null; - private Settings settings = new Settings(); - private String targetUrl = null; + private volatile boolean started = false; + private NanoHttpdSimpleWeb server = null; + private java.sql.Driver driver = null; + private Settings settings = new Settings(); + private String targetUrl = null; public Settings getSettings() { return settings; } } - private static Map loggers = new ConcurrentHashMap(); - private static Map portMapping = new ConcurrentHashMap(); + private static Map loggers = new ConcurrentHashMap(); + private static Map portMapping = new ConcurrentHashMap(); public static StatsLogger get(String url) { if (!loggers.containsKey(url)) { - throw new IllegalArgumentException("No jdbc statistics logger found for url: "+url); + throw new IllegalArgumentException("No jdbc statistics logger found for url: " + url); } return loggers.get(url); @@ -56,7 +50,7 @@ public static StatsLogger get(int port) { if (!portMapping.containsKey(port)) { - throw new IllegalArgumentException("No jdbc statistics logger found on port: "+port); + throw new IllegalArgumentException("No jdbc statistics logger found on port: " + port); } return portMapping.get(port); @@ -75,7 +69,8 @@ "org.apache.derby.jdbc.EmbeddedDriver", "com.mysql.jdbc.Driver", "org.hsqldb.jdbcDriver", - "org.h2.Driver" }; + "org.h2.Driver" + }; static { log.debug("Loading driver class " + Driver.class.getName()); @@ -123,8 +118,8 @@ logger.settings.setSecure(true); } - String [] parts = url.split("\\:"); - String settingsString = "webServerConnections=5;numberOfQueries=2500;logStacktraces=true;formattedQueries=true"; + String[] parts = url.split("\\:"); + String settingsString = "webServerConnections=5;numberOfQueries=2500;logStacktraces=true;formattedQueries=true"; if (parts.length > 3) { settingsString = parts[2]; @@ -146,7 +141,7 @@ } if (logger.settings.isSecure()) { - String user = info.getProperty("user"); + String user = info.getProperty("user"); String password = info.getProperty("password"); if (user == null || password == null) { @@ -161,15 +156,21 @@ synchronized (this) { if (!logger.started) { try { - NanoHttpdSimpleWeb server = new NanoHttpdSimpleWeb(logger.settings.getWebServerPort(), new JdbcStatsMappingProvider()); + NanoHttpdSimpleWeb server = new NanoHttpdSimpleWeb( + logger.settings.getWebServerPort(), + new JdbcStatsMappingProvider() + ); server.start(); - System.out.println("Started Simple JDBC Statistics\n\turl: "+url+"\n\tport: "+logger.settings.getWebServerPort()); + System.out.println("Started Simple JDBC Statistics\n\turl: " + + url + + "\n\tport: " + + logger.settings.getWebServerPort()); logger.started = true; } catch (Exception e) { - log.error(e.getMessage(),e); + log.error(e.getMessage(), e); } } } diff --git a/src/nl/astraeus/jdbc/JdbcLogger.java b/src/nl/astraeus/jdbc/JdbcLogger.java index 44d09e6..ac7188a 100644 --- a/src/nl/astraeus/jdbc/JdbcLogger.java +++ b/src/nl/astraeus/jdbc/JdbcLogger.java @@ -1,15 +1,10 @@ package nl.astraeus.jdbc; import nl.astraeus.jdbc.util.Util; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import java.util.HashMap; -import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; @@ -19,8 +14,6 @@ * Time: 9:15:21 AM */ public class JdbcLogger { - private final static Logger logger = LoggerFactory.getLogger(JdbcLogger.class); - private final static Map instances = new ConcurrentHashMap(); public static JdbcLogger get(int port) { diff --git a/src/nl/astraeus/jdbc/PreparedStatementLogger.java b/src/nl/astraeus/jdbc/PreparedStatementLogger.java index f97959a..648fea0 100644 --- a/src/nl/astraeus/jdbc/PreparedStatementLogger.java +++ b/src/nl/astraeus/jdbc/PreparedStatementLogger.java @@ -1,8 +1,5 @@ package nl.astraeus.jdbc; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; @@ -25,12 +22,8 @@ import java.sql.Time; import java.sql.Timestamp; import java.util.Calendar; -import java.util.Comparator; -import java.util.HashSet; import java.util.Map; -import java.util.Set; import java.util.TreeMap; -import java.util.TreeSet; /** * User: riennentjes @@ -38,8 +31,6 @@ * Time: 7:47:57 PM */ public class PreparedStatementLogger implements PreparedStatement { - private final static Logger log = LoggerFactory.getLogger(PreparedStatementLogger.class); - private JdbcLogger logger; private PreparedStatement statement; diff --git a/src/nl/astraeus/jdbc/SqlFormatter.java b/src/nl/astraeus/jdbc/SqlFormatter.java index e28810b..8129dfc 100644 --- a/src/nl/astraeus/jdbc/SqlFormatter.java +++ b/src/nl/astraeus/jdbc/SqlFormatter.java @@ -4,17 +4,12 @@ import java.util.List; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/18/12 * Time: 10:10 PM */ public class SqlFormatter { - private final static Logger logger = LoggerFactory.getLogger(SqlFormatter.class); - private static SqlTokenizer tokenizer = new SqlTokenizer(); private static enum Newline { diff --git a/src/nl/astraeus/jdbc/thread/JvmSampler.java b/src/nl/astraeus/jdbc/thread/JvmSampler.java index f1b98d6..155c4ee 100644 --- a/src/nl/astraeus/jdbc/thread/JvmSampler.java +++ b/src/nl/astraeus/jdbc/thread/JvmSampler.java @@ -5,17 +5,12 @@ import java.util.Set; import java.util.TreeSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/22/13 * Time: 8:52 PM */ public class JvmSampler extends Thread { - private final static Logger logger = LoggerFactory.getLogger(JvmSampler.class); - private boolean stopped; private boolean running; diff --git a/src/nl/astraeus/jdbc/util/ReflectHelper.java b/src/nl/astraeus/jdbc/util/ReflectHelper.java index eac090f..7582e04 100644 --- a/src/nl/astraeus/jdbc/util/ReflectHelper.java +++ b/src/nl/astraeus/jdbc/util/ReflectHelper.java @@ -9,17 +9,12 @@ import java.util.List; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 10/16/13 * Time: 4:49 PM */ public class ReflectHelper { - private final static Logger logger = LoggerFactory.getLogger(ReflectHelper.class); - private final static ReflectHelper instance = new ReflectHelper(); public static ReflectHelper get() { diff --git a/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java b/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java index 555b1d3..a70febc 100644 --- a/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java +++ b/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java @@ -9,14 +9,12 @@ import nl.astraeus.jdbc.web.page.ShowStacktrace; import nl.astraeus.jdbc.web.page.TransactionDetail; import nl.astraeus.jdbc.web.page.TransactionOverview; -import nl.astraeus.web.page.Page; -import nl.astraeus.web.page.PageMapping; /** * Date: 11/24/13 * Time: 10:27 AM */ -public enum JdbcStatsMapping implements PageMapping { +public enum JdbcStatsMapping { QUERIES("queries", QueryOverview.class), QUERY("query", QueryDetail.class), @@ -36,8 +34,8 @@ MAIN("", QueryOverview.class), ; - private String uri; - private Class cls; + private final String uri; + private final Class cls; private JdbcStatsMapping(String uri, Class cls) { this.uri = uri; @@ -48,8 +46,8 @@ return uri; } - public Class getPage() { - return (Class) cls; + public Class getPage() { + return cls; } } diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 41cd493..f9ae410 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -17,7 +17,7 @@ - + diff --git a/.idea/libraries-with-intellij-classes.xml b/.idea/libraries-with-intellij-classes.xml new file mode 100644 index 0000000..9fa3156 --- /dev/null +++ b/.idea/libraries-with-intellij-classes.xml @@ -0,0 +1,65 @@ + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml new file mode 100644 index 0000000..c108f80 --- /dev/null +++ b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml b/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml deleted file mode 100644 index 9a00155..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml b/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml deleted file mode 100644 index 873c2c0..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml new file mode 100644 index 0000000..7d1fc19 --- /dev/null +++ b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index be926a3..6d93540 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,7 +8,7 @@ http://www.w3.org/1999/xhtml - + diff --git a/.idea/modules/simple-jdbc-stats.main.iml b/.idea/modules/simple-jdbc-stats.main.iml index 578407e..50faa2e 100644 --- a/.idea/modules/simple-jdbc-stats.main.iml +++ b/.idea/modules/simple-jdbc-stats.main.iml @@ -1,15 +1,15 @@ - + - - + + \ No newline at end of file diff --git a/.idea/modules/simple-jdbc-stats.test.iml b/.idea/modules/simple-jdbc-stats.test.iml index 62ffcca..f5baeeb 100644 --- a/.idea/modules/simple-jdbc-stats.test.iml +++ b/.idea/modules/simple-jdbc-stats.test.iml @@ -1,7 +1,7 @@ - + @@ -10,8 +10,8 @@ - - + + diff --git a/build.gradle b/build.gradle index 8791f4a..559db71 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,6 @@ apply plugin: 'java' apply plugin: 'idea' apply plugin: 'maven' -apply plugin: 'findbugs' apply plugin: 'maven-publish' sourceSets { @@ -15,8 +14,8 @@ test.resources.srcDirs += 'test' } -sourceCompatibility = 1.5 -targetCompatibility = 1.5 +sourceCompatibility = 1.6 +targetCompatibility = 1.6 repositories { maven { @@ -24,18 +23,23 @@ } } +ext { + PUBLISH_GROUP_ID = group + PUBLISH_VERSION = version + PUBLISH_ARTIFACT_ID = name +} + +apply from: "${rootProject.projectDir}/scripts/publish-mavencentral.gradle" + dependencies { testCompile group: 'junit', name: 'junit', version: '4.12' - testCompile "org.slf4j:slf4j-simple:1.7.21" testCompile "com.h2database:h2:1.4.+" - compile "nl.astraeus.template:very-simple-templates:1.3" - compile "nl.astraeus.web:simple-web:0.3" - compile "org.slf4j:slf4j-api:1.7.21" + compile "com.samskivert:jmustache:1.15" + compile "org.nanohttpd:nanohttpd:2.2.0" configurations.compile.exclude module: 'javax.servlet-api' - configurations.compile.exclude module: 'slf4j-simple' } uploadArchives { @@ -51,10 +55,6 @@ } } -findbugs { - ignoreFailures = true -} - javadoc { failOnError = false } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 088b40b..bd4ca84 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip diff --git a/scripts/publish-mavencentral.gradle b/scripts/publish-mavencentral.gradle new file mode 100644 index 0000000..fae9b85 --- /dev/null +++ b/scripts/publish-mavencentral.gradle @@ -0,0 +1,121 @@ + +apply plugin: 'maven-publish' +apply plugin: 'signing' + +task publishSourcesJar(type: Jar) { + archiveClassifier.set('sources') + + // For pure Kotlin libraries, in case you have them + from sourceSets.main.java.srcDirs + //from sourceSets.main.kotlin.srcDirs +} + +task packageJavadoc(type: Jar) { + from javadoc + classifier = 'javadoc' +} + +artifacts { + archives publishSourcesJar +} + +File secretPropsFile = project.rootProject.file('local.properties') + +ext["signing.keyId"] = '' +ext["signing.password"] = '' +ext["signing.secretKeyRingFile"] = '' +ext["ossrhUsername"] = '' +ext["ossrhPassword"] = '' +ext["sonatypeStagingProfileId"] = '' + +if (secretPropsFile.exists()) { + Properties p = new Properties() + + new FileInputStream(secretPropsFile).withCloseable { is -> + p.load(is) + } + + p.each { name, value -> + ext[name] = value + } +} + +afterEvaluate { + publishing { + publications { + relase(MavenPublication) { + // The coordinates of the library, being set from variables that + // we'll set up later + groupId PUBLISH_GROUP_ID + artifactId PUBLISH_ARTIFACT_ID + version PUBLISH_VERSION + + // Two artifacts, the `aar` (or `jar`) and the sources + if (project.plugins.findPlugin("com.android.library")) { + artifact("$buildDir/outputs/aar/${project.getName()}-release.aar") + } else { + artifact("$buildDir/libs/${project.getName()}-${version}.jar") + } + artifact publishSourcesJar + artifact packageJavadoc + + // Mostly self-explanatory metadata + pom { + name = PUBLISH_ARTIFACT_ID + description = 'Simple JDBC wrapper for query statistics' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics' + licenses { + license { + name = 'MIT License' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics/blob/master/LICENCE.txt' + } + } + developers { + developer { + id = 'rnentjes' + name = 'Rien Nentjes' + email = 'info@nentjes.com' + } + // Add all other devs here... + } + // Version control info - if you're using GitHub, follow the format as seen here + scm { + connection = 'scm:git:github.com/rnentjes/Simple-jdbc-statistics.git' + developerConnection = 'scm:git:ssh://github.com/rnentjes/Simple-jdbc-statistics.git' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics.git/tree/main' + } + // A slightly hacky fix so that your POM will include any transitive dependencies + // that your library builds upon + /* + witXml { + def dependenciesNode = asNode().appendNode('dependencies') + + project.configurations.implementation.allDependencies.each { + def dependencyNode = dependenciesNode.appendNode('dependency') + dependencyNode.appendNode('groupId', it.group) + dependencyNode.appendNode('artifactId', it.name) + dependencyNode.appendNode('version', it.version) + } + }*/ + } + } + } + // The repository to publish to, Sonatype/MavenCentral + repositories { + maven { + // This is an arbitrary name, you may also use "mavencentral" or + // any other name that's descriptive for you + name = "sonatype" + url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" + credentials { + username ossrhUsername + password ossrhPassword + } + } + } + } +} + +signing { + sign publishing.publications +} diff --git a/src/nl/astraeus/jdbc/CallableStatementLogger.java b/src/nl/astraeus/jdbc/CallableStatementLogger.java index 2e9f173..39be81c 100644 --- a/src/nl/astraeus/jdbc/CallableStatementLogger.java +++ b/src/nl/astraeus/jdbc/CallableStatementLogger.java @@ -1,8 +1,5 @@ package nl.astraeus.jdbc; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; @@ -17,8 +14,6 @@ * Time: 9:48 PM */ public class CallableStatementLogger implements CallableStatement { - private final static Logger log = LoggerFactory.getLogger(PreparedStatementLogger.class); - private JdbcLogger logger; private CallableStatement statement; diff --git a/src/nl/astraeus/jdbc/Driver.java b/src/nl/astraeus/jdbc/Driver.java index 046d756..e230a06 100644 --- a/src/nl/astraeus/jdbc/Driver.java +++ b/src/nl/astraeus/jdbc/Driver.java @@ -11,44 +11,38 @@ import java.util.concurrent.ConcurrentHashMap; import nl.astraeus.jdbc.web.JdbcStatsMappingProvider; +import nl.astraeus.jdbc.web.NanoHttpdSimpleWeb; import nl.astraeus.jdbc.web.model.Settings; -import nl.astraeus.web.NanoHttpdSimpleWeb; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * User: riennentjes * Date: Jul 10, 2008 * Time: 8:54:37 PM - * + *

* Test a little change - * */ public class Driver implements java.sql.Driver { - private final static Logger log = LoggerFactory.getLogger(Driver.class); - - final private static String URL_PREFIX = "jdbc:stat:"; - final private static String URL_SECURE_PREFIX = "jdbc:secstat:"; + final private static String URL_PREFIX = "jdbc:stat:"; + final private static String URL_SECURE_PREFIX = "jdbc:secstat:"; public static class StatsLogger { - private volatile boolean started = false; - private NanoHttpdSimpleWeb server = null; - private java.sql.Driver driver = null; - private Settings settings = new Settings(); - private String targetUrl = null; + private volatile boolean started = false; + private NanoHttpdSimpleWeb server = null; + private java.sql.Driver driver = null; + private Settings settings = new Settings(); + private String targetUrl = null; public Settings getSettings() { return settings; } } - private static Map loggers = new ConcurrentHashMap(); - private static Map portMapping = new ConcurrentHashMap(); + private static Map loggers = new ConcurrentHashMap(); + private static Map portMapping = new ConcurrentHashMap(); public static StatsLogger get(String url) { if (!loggers.containsKey(url)) { - throw new IllegalArgumentException("No jdbc statistics logger found for url: "+url); + throw new IllegalArgumentException("No jdbc statistics logger found for url: " + url); } return loggers.get(url); @@ -56,7 +50,7 @@ public static StatsLogger get(int port) { if (!portMapping.containsKey(port)) { - throw new IllegalArgumentException("No jdbc statistics logger found on port: "+port); + throw new IllegalArgumentException("No jdbc statistics logger found on port: " + port); } return portMapping.get(port); @@ -75,7 +69,8 @@ "org.apache.derby.jdbc.EmbeddedDriver", "com.mysql.jdbc.Driver", "org.hsqldb.jdbcDriver", - "org.h2.Driver" }; + "org.h2.Driver" + }; static { log.debug("Loading driver class " + Driver.class.getName()); @@ -123,8 +118,8 @@ logger.settings.setSecure(true); } - String [] parts = url.split("\\:"); - String settingsString = "webServerConnections=5;numberOfQueries=2500;logStacktraces=true;formattedQueries=true"; + String[] parts = url.split("\\:"); + String settingsString = "webServerConnections=5;numberOfQueries=2500;logStacktraces=true;formattedQueries=true"; if (parts.length > 3) { settingsString = parts[2]; @@ -146,7 +141,7 @@ } if (logger.settings.isSecure()) { - String user = info.getProperty("user"); + String user = info.getProperty("user"); String password = info.getProperty("password"); if (user == null || password == null) { @@ -161,15 +156,21 @@ synchronized (this) { if (!logger.started) { try { - NanoHttpdSimpleWeb server = new NanoHttpdSimpleWeb(logger.settings.getWebServerPort(), new JdbcStatsMappingProvider()); + NanoHttpdSimpleWeb server = new NanoHttpdSimpleWeb( + logger.settings.getWebServerPort(), + new JdbcStatsMappingProvider() + ); server.start(); - System.out.println("Started Simple JDBC Statistics\n\turl: "+url+"\n\tport: "+logger.settings.getWebServerPort()); + System.out.println("Started Simple JDBC Statistics\n\turl: " + + url + + "\n\tport: " + + logger.settings.getWebServerPort()); logger.started = true; } catch (Exception e) { - log.error(e.getMessage(),e); + log.error(e.getMessage(), e); } } } diff --git a/src/nl/astraeus/jdbc/JdbcLogger.java b/src/nl/astraeus/jdbc/JdbcLogger.java index 44d09e6..ac7188a 100644 --- a/src/nl/astraeus/jdbc/JdbcLogger.java +++ b/src/nl/astraeus/jdbc/JdbcLogger.java @@ -1,15 +1,10 @@ package nl.astraeus.jdbc; import nl.astraeus.jdbc.util.Util; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import java.util.HashMap; -import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; @@ -19,8 +14,6 @@ * Time: 9:15:21 AM */ public class JdbcLogger { - private final static Logger logger = LoggerFactory.getLogger(JdbcLogger.class); - private final static Map instances = new ConcurrentHashMap(); public static JdbcLogger get(int port) { diff --git a/src/nl/astraeus/jdbc/PreparedStatementLogger.java b/src/nl/astraeus/jdbc/PreparedStatementLogger.java index f97959a..648fea0 100644 --- a/src/nl/astraeus/jdbc/PreparedStatementLogger.java +++ b/src/nl/astraeus/jdbc/PreparedStatementLogger.java @@ -1,8 +1,5 @@ package nl.astraeus.jdbc; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; @@ -25,12 +22,8 @@ import java.sql.Time; import java.sql.Timestamp; import java.util.Calendar; -import java.util.Comparator; -import java.util.HashSet; import java.util.Map; -import java.util.Set; import java.util.TreeMap; -import java.util.TreeSet; /** * User: riennentjes @@ -38,8 +31,6 @@ * Time: 7:47:57 PM */ public class PreparedStatementLogger implements PreparedStatement { - private final static Logger log = LoggerFactory.getLogger(PreparedStatementLogger.class); - private JdbcLogger logger; private PreparedStatement statement; diff --git a/src/nl/astraeus/jdbc/SqlFormatter.java b/src/nl/astraeus/jdbc/SqlFormatter.java index e28810b..8129dfc 100644 --- a/src/nl/astraeus/jdbc/SqlFormatter.java +++ b/src/nl/astraeus/jdbc/SqlFormatter.java @@ -4,17 +4,12 @@ import java.util.List; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/18/12 * Time: 10:10 PM */ public class SqlFormatter { - private final static Logger logger = LoggerFactory.getLogger(SqlFormatter.class); - private static SqlTokenizer tokenizer = new SqlTokenizer(); private static enum Newline { diff --git a/src/nl/astraeus/jdbc/thread/JvmSampler.java b/src/nl/astraeus/jdbc/thread/JvmSampler.java index f1b98d6..155c4ee 100644 --- a/src/nl/astraeus/jdbc/thread/JvmSampler.java +++ b/src/nl/astraeus/jdbc/thread/JvmSampler.java @@ -5,17 +5,12 @@ import java.util.Set; import java.util.TreeSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/22/13 * Time: 8:52 PM */ public class JvmSampler extends Thread { - private final static Logger logger = LoggerFactory.getLogger(JvmSampler.class); - private boolean stopped; private boolean running; diff --git a/src/nl/astraeus/jdbc/util/ReflectHelper.java b/src/nl/astraeus/jdbc/util/ReflectHelper.java index eac090f..7582e04 100644 --- a/src/nl/astraeus/jdbc/util/ReflectHelper.java +++ b/src/nl/astraeus/jdbc/util/ReflectHelper.java @@ -9,17 +9,12 @@ import java.util.List; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 10/16/13 * Time: 4:49 PM */ public class ReflectHelper { - private final static Logger logger = LoggerFactory.getLogger(ReflectHelper.class); - private final static ReflectHelper instance = new ReflectHelper(); public static ReflectHelper get() { diff --git a/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java b/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java index 555b1d3..a70febc 100644 --- a/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java +++ b/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java @@ -9,14 +9,12 @@ import nl.astraeus.jdbc.web.page.ShowStacktrace; import nl.astraeus.jdbc.web.page.TransactionDetail; import nl.astraeus.jdbc.web.page.TransactionOverview; -import nl.astraeus.web.page.Page; -import nl.astraeus.web.page.PageMapping; /** * Date: 11/24/13 * Time: 10:27 AM */ -public enum JdbcStatsMapping implements PageMapping { +public enum JdbcStatsMapping { QUERIES("queries", QueryOverview.class), QUERY("query", QueryDetail.class), @@ -36,8 +34,8 @@ MAIN("", QueryOverview.class), ; - private String uri; - private Class cls; + private final String uri; + private final Class cls; private JdbcStatsMapping(String uri, Class cls) { this.uri = uri; @@ -48,8 +46,8 @@ return uri; } - public Class getPage() { - return (Class) cls; + public Class getPage() { + return cls; } } diff --git a/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java b/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java index b05e76a..36b1819 100644 --- a/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java +++ b/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java @@ -1,15 +1,12 @@ package nl.astraeus.jdbc.web; -import nl.astraeus.web.page.MappingProvider; -import nl.astraeus.web.page.PageMapping; - /** * Date: 11/24/13 * Time: 10:24 AM */ -public class JdbcStatsMappingProvider implements MappingProvider { +public class JdbcStatsMappingProvider { - public PageMapping getMapping(String uri) { + public JdbcStatsMapping getMapping(String uri) { for (JdbcStatsMapping mapping : JdbcStatsMapping.values()) { if (uri.startsWith(mapping.getUri())) { return mapping; @@ -19,11 +16,12 @@ return null; } - public PageMapping getLoginPage() { + public JdbcStatsMapping getLoginPage() { return JdbcStatsMapping.LOGIN; } - public PageMapping get404Page() { + public JdbcStatsMapping get404Page() { return JdbcStatsMapping.NOTFOUND; } + } diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 41cd493..f9ae410 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -17,7 +17,7 @@ - + diff --git a/.idea/libraries-with-intellij-classes.xml b/.idea/libraries-with-intellij-classes.xml new file mode 100644 index 0000000..9fa3156 --- /dev/null +++ b/.idea/libraries-with-intellij-classes.xml @@ -0,0 +1,65 @@ + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml new file mode 100644 index 0000000..c108f80 --- /dev/null +++ b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml b/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml deleted file mode 100644 index 9a00155..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml b/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml deleted file mode 100644 index 873c2c0..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml new file mode 100644 index 0000000..7d1fc19 --- /dev/null +++ b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index be926a3..6d93540 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,7 +8,7 @@ http://www.w3.org/1999/xhtml - + diff --git a/.idea/modules/simple-jdbc-stats.main.iml b/.idea/modules/simple-jdbc-stats.main.iml index 578407e..50faa2e 100644 --- a/.idea/modules/simple-jdbc-stats.main.iml +++ b/.idea/modules/simple-jdbc-stats.main.iml @@ -1,15 +1,15 @@ - + - - + + \ No newline at end of file diff --git a/.idea/modules/simple-jdbc-stats.test.iml b/.idea/modules/simple-jdbc-stats.test.iml index 62ffcca..f5baeeb 100644 --- a/.idea/modules/simple-jdbc-stats.test.iml +++ b/.idea/modules/simple-jdbc-stats.test.iml @@ -1,7 +1,7 @@ - + @@ -10,8 +10,8 @@ - - + + diff --git a/build.gradle b/build.gradle index 8791f4a..559db71 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,6 @@ apply plugin: 'java' apply plugin: 'idea' apply plugin: 'maven' -apply plugin: 'findbugs' apply plugin: 'maven-publish' sourceSets { @@ -15,8 +14,8 @@ test.resources.srcDirs += 'test' } -sourceCompatibility = 1.5 -targetCompatibility = 1.5 +sourceCompatibility = 1.6 +targetCompatibility = 1.6 repositories { maven { @@ -24,18 +23,23 @@ } } +ext { + PUBLISH_GROUP_ID = group + PUBLISH_VERSION = version + PUBLISH_ARTIFACT_ID = name +} + +apply from: "${rootProject.projectDir}/scripts/publish-mavencentral.gradle" + dependencies { testCompile group: 'junit', name: 'junit', version: '4.12' - testCompile "org.slf4j:slf4j-simple:1.7.21" testCompile "com.h2database:h2:1.4.+" - compile "nl.astraeus.template:very-simple-templates:1.3" - compile "nl.astraeus.web:simple-web:0.3" - compile "org.slf4j:slf4j-api:1.7.21" + compile "com.samskivert:jmustache:1.15" + compile "org.nanohttpd:nanohttpd:2.2.0" configurations.compile.exclude module: 'javax.servlet-api' - configurations.compile.exclude module: 'slf4j-simple' } uploadArchives { @@ -51,10 +55,6 @@ } } -findbugs { - ignoreFailures = true -} - javadoc { failOnError = false } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 088b40b..bd4ca84 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip diff --git a/scripts/publish-mavencentral.gradle b/scripts/publish-mavencentral.gradle new file mode 100644 index 0000000..fae9b85 --- /dev/null +++ b/scripts/publish-mavencentral.gradle @@ -0,0 +1,121 @@ + +apply plugin: 'maven-publish' +apply plugin: 'signing' + +task publishSourcesJar(type: Jar) { + archiveClassifier.set('sources') + + // For pure Kotlin libraries, in case you have them + from sourceSets.main.java.srcDirs + //from sourceSets.main.kotlin.srcDirs +} + +task packageJavadoc(type: Jar) { + from javadoc + classifier = 'javadoc' +} + +artifacts { + archives publishSourcesJar +} + +File secretPropsFile = project.rootProject.file('local.properties') + +ext["signing.keyId"] = '' +ext["signing.password"] = '' +ext["signing.secretKeyRingFile"] = '' +ext["ossrhUsername"] = '' +ext["ossrhPassword"] = '' +ext["sonatypeStagingProfileId"] = '' + +if (secretPropsFile.exists()) { + Properties p = new Properties() + + new FileInputStream(secretPropsFile).withCloseable { is -> + p.load(is) + } + + p.each { name, value -> + ext[name] = value + } +} + +afterEvaluate { + publishing { + publications { + relase(MavenPublication) { + // The coordinates of the library, being set from variables that + // we'll set up later + groupId PUBLISH_GROUP_ID + artifactId PUBLISH_ARTIFACT_ID + version PUBLISH_VERSION + + // Two artifacts, the `aar` (or `jar`) and the sources + if (project.plugins.findPlugin("com.android.library")) { + artifact("$buildDir/outputs/aar/${project.getName()}-release.aar") + } else { + artifact("$buildDir/libs/${project.getName()}-${version}.jar") + } + artifact publishSourcesJar + artifact packageJavadoc + + // Mostly self-explanatory metadata + pom { + name = PUBLISH_ARTIFACT_ID + description = 'Simple JDBC wrapper for query statistics' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics' + licenses { + license { + name = 'MIT License' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics/blob/master/LICENCE.txt' + } + } + developers { + developer { + id = 'rnentjes' + name = 'Rien Nentjes' + email = 'info@nentjes.com' + } + // Add all other devs here... + } + // Version control info - if you're using GitHub, follow the format as seen here + scm { + connection = 'scm:git:github.com/rnentjes/Simple-jdbc-statistics.git' + developerConnection = 'scm:git:ssh://github.com/rnentjes/Simple-jdbc-statistics.git' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics.git/tree/main' + } + // A slightly hacky fix so that your POM will include any transitive dependencies + // that your library builds upon + /* + witXml { + def dependenciesNode = asNode().appendNode('dependencies') + + project.configurations.implementation.allDependencies.each { + def dependencyNode = dependenciesNode.appendNode('dependency') + dependencyNode.appendNode('groupId', it.group) + dependencyNode.appendNode('artifactId', it.name) + dependencyNode.appendNode('version', it.version) + } + }*/ + } + } + } + // The repository to publish to, Sonatype/MavenCentral + repositories { + maven { + // This is an arbitrary name, you may also use "mavencentral" or + // any other name that's descriptive for you + name = "sonatype" + url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" + credentials { + username ossrhUsername + password ossrhPassword + } + } + } + } +} + +signing { + sign publishing.publications +} diff --git a/src/nl/astraeus/jdbc/CallableStatementLogger.java b/src/nl/astraeus/jdbc/CallableStatementLogger.java index 2e9f173..39be81c 100644 --- a/src/nl/astraeus/jdbc/CallableStatementLogger.java +++ b/src/nl/astraeus/jdbc/CallableStatementLogger.java @@ -1,8 +1,5 @@ package nl.astraeus.jdbc; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; @@ -17,8 +14,6 @@ * Time: 9:48 PM */ public class CallableStatementLogger implements CallableStatement { - private final static Logger log = LoggerFactory.getLogger(PreparedStatementLogger.class); - private JdbcLogger logger; private CallableStatement statement; diff --git a/src/nl/astraeus/jdbc/Driver.java b/src/nl/astraeus/jdbc/Driver.java index 046d756..e230a06 100644 --- a/src/nl/astraeus/jdbc/Driver.java +++ b/src/nl/astraeus/jdbc/Driver.java @@ -11,44 +11,38 @@ import java.util.concurrent.ConcurrentHashMap; import nl.astraeus.jdbc.web.JdbcStatsMappingProvider; +import nl.astraeus.jdbc.web.NanoHttpdSimpleWeb; import nl.astraeus.jdbc.web.model.Settings; -import nl.astraeus.web.NanoHttpdSimpleWeb; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * User: riennentjes * Date: Jul 10, 2008 * Time: 8:54:37 PM - * + *

* Test a little change - * */ public class Driver implements java.sql.Driver { - private final static Logger log = LoggerFactory.getLogger(Driver.class); - - final private static String URL_PREFIX = "jdbc:stat:"; - final private static String URL_SECURE_PREFIX = "jdbc:secstat:"; + final private static String URL_PREFIX = "jdbc:stat:"; + final private static String URL_SECURE_PREFIX = "jdbc:secstat:"; public static class StatsLogger { - private volatile boolean started = false; - private NanoHttpdSimpleWeb server = null; - private java.sql.Driver driver = null; - private Settings settings = new Settings(); - private String targetUrl = null; + private volatile boolean started = false; + private NanoHttpdSimpleWeb server = null; + private java.sql.Driver driver = null; + private Settings settings = new Settings(); + private String targetUrl = null; public Settings getSettings() { return settings; } } - private static Map loggers = new ConcurrentHashMap(); - private static Map portMapping = new ConcurrentHashMap(); + private static Map loggers = new ConcurrentHashMap(); + private static Map portMapping = new ConcurrentHashMap(); public static StatsLogger get(String url) { if (!loggers.containsKey(url)) { - throw new IllegalArgumentException("No jdbc statistics logger found for url: "+url); + throw new IllegalArgumentException("No jdbc statistics logger found for url: " + url); } return loggers.get(url); @@ -56,7 +50,7 @@ public static StatsLogger get(int port) { if (!portMapping.containsKey(port)) { - throw new IllegalArgumentException("No jdbc statistics logger found on port: "+port); + throw new IllegalArgumentException("No jdbc statistics logger found on port: " + port); } return portMapping.get(port); @@ -75,7 +69,8 @@ "org.apache.derby.jdbc.EmbeddedDriver", "com.mysql.jdbc.Driver", "org.hsqldb.jdbcDriver", - "org.h2.Driver" }; + "org.h2.Driver" + }; static { log.debug("Loading driver class " + Driver.class.getName()); @@ -123,8 +118,8 @@ logger.settings.setSecure(true); } - String [] parts = url.split("\\:"); - String settingsString = "webServerConnections=5;numberOfQueries=2500;logStacktraces=true;formattedQueries=true"; + String[] parts = url.split("\\:"); + String settingsString = "webServerConnections=5;numberOfQueries=2500;logStacktraces=true;formattedQueries=true"; if (parts.length > 3) { settingsString = parts[2]; @@ -146,7 +141,7 @@ } if (logger.settings.isSecure()) { - String user = info.getProperty("user"); + String user = info.getProperty("user"); String password = info.getProperty("password"); if (user == null || password == null) { @@ -161,15 +156,21 @@ synchronized (this) { if (!logger.started) { try { - NanoHttpdSimpleWeb server = new NanoHttpdSimpleWeb(logger.settings.getWebServerPort(), new JdbcStatsMappingProvider()); + NanoHttpdSimpleWeb server = new NanoHttpdSimpleWeb( + logger.settings.getWebServerPort(), + new JdbcStatsMappingProvider() + ); server.start(); - System.out.println("Started Simple JDBC Statistics\n\turl: "+url+"\n\tport: "+logger.settings.getWebServerPort()); + System.out.println("Started Simple JDBC Statistics\n\turl: " + + url + + "\n\tport: " + + logger.settings.getWebServerPort()); logger.started = true; } catch (Exception e) { - log.error(e.getMessage(),e); + log.error(e.getMessage(), e); } } } diff --git a/src/nl/astraeus/jdbc/JdbcLogger.java b/src/nl/astraeus/jdbc/JdbcLogger.java index 44d09e6..ac7188a 100644 --- a/src/nl/astraeus/jdbc/JdbcLogger.java +++ b/src/nl/astraeus/jdbc/JdbcLogger.java @@ -1,15 +1,10 @@ package nl.astraeus.jdbc; import nl.astraeus.jdbc.util.Util; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import java.util.HashMap; -import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; @@ -19,8 +14,6 @@ * Time: 9:15:21 AM */ public class JdbcLogger { - private final static Logger logger = LoggerFactory.getLogger(JdbcLogger.class); - private final static Map instances = new ConcurrentHashMap(); public static JdbcLogger get(int port) { diff --git a/src/nl/astraeus/jdbc/PreparedStatementLogger.java b/src/nl/astraeus/jdbc/PreparedStatementLogger.java index f97959a..648fea0 100644 --- a/src/nl/astraeus/jdbc/PreparedStatementLogger.java +++ b/src/nl/astraeus/jdbc/PreparedStatementLogger.java @@ -1,8 +1,5 @@ package nl.astraeus.jdbc; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; @@ -25,12 +22,8 @@ import java.sql.Time; import java.sql.Timestamp; import java.util.Calendar; -import java.util.Comparator; -import java.util.HashSet; import java.util.Map; -import java.util.Set; import java.util.TreeMap; -import java.util.TreeSet; /** * User: riennentjes @@ -38,8 +31,6 @@ * Time: 7:47:57 PM */ public class PreparedStatementLogger implements PreparedStatement { - private final static Logger log = LoggerFactory.getLogger(PreparedStatementLogger.class); - private JdbcLogger logger; private PreparedStatement statement; diff --git a/src/nl/astraeus/jdbc/SqlFormatter.java b/src/nl/astraeus/jdbc/SqlFormatter.java index e28810b..8129dfc 100644 --- a/src/nl/astraeus/jdbc/SqlFormatter.java +++ b/src/nl/astraeus/jdbc/SqlFormatter.java @@ -4,17 +4,12 @@ import java.util.List; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/18/12 * Time: 10:10 PM */ public class SqlFormatter { - private final static Logger logger = LoggerFactory.getLogger(SqlFormatter.class); - private static SqlTokenizer tokenizer = new SqlTokenizer(); private static enum Newline { diff --git a/src/nl/astraeus/jdbc/thread/JvmSampler.java b/src/nl/astraeus/jdbc/thread/JvmSampler.java index f1b98d6..155c4ee 100644 --- a/src/nl/astraeus/jdbc/thread/JvmSampler.java +++ b/src/nl/astraeus/jdbc/thread/JvmSampler.java @@ -5,17 +5,12 @@ import java.util.Set; import java.util.TreeSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/22/13 * Time: 8:52 PM */ public class JvmSampler extends Thread { - private final static Logger logger = LoggerFactory.getLogger(JvmSampler.class); - private boolean stopped; private boolean running; diff --git a/src/nl/astraeus/jdbc/util/ReflectHelper.java b/src/nl/astraeus/jdbc/util/ReflectHelper.java index eac090f..7582e04 100644 --- a/src/nl/astraeus/jdbc/util/ReflectHelper.java +++ b/src/nl/astraeus/jdbc/util/ReflectHelper.java @@ -9,17 +9,12 @@ import java.util.List; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 10/16/13 * Time: 4:49 PM */ public class ReflectHelper { - private final static Logger logger = LoggerFactory.getLogger(ReflectHelper.class); - private final static ReflectHelper instance = new ReflectHelper(); public static ReflectHelper get() { diff --git a/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java b/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java index 555b1d3..a70febc 100644 --- a/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java +++ b/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java @@ -9,14 +9,12 @@ import nl.astraeus.jdbc.web.page.ShowStacktrace; import nl.astraeus.jdbc.web.page.TransactionDetail; import nl.astraeus.jdbc.web.page.TransactionOverview; -import nl.astraeus.web.page.Page; -import nl.astraeus.web.page.PageMapping; /** * Date: 11/24/13 * Time: 10:27 AM */ -public enum JdbcStatsMapping implements PageMapping { +public enum JdbcStatsMapping { QUERIES("queries", QueryOverview.class), QUERY("query", QueryDetail.class), @@ -36,8 +34,8 @@ MAIN("", QueryOverview.class), ; - private String uri; - private Class cls; + private final String uri; + private final Class cls; private JdbcStatsMapping(String uri, Class cls) { this.uri = uri; @@ -48,8 +46,8 @@ return uri; } - public Class getPage() { - return (Class) cls; + public Class getPage() { + return cls; } } diff --git a/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java b/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java index b05e76a..36b1819 100644 --- a/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java +++ b/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java @@ -1,15 +1,12 @@ package nl.astraeus.jdbc.web; -import nl.astraeus.web.page.MappingProvider; -import nl.astraeus.web.page.PageMapping; - /** * Date: 11/24/13 * Time: 10:24 AM */ -public class JdbcStatsMappingProvider implements MappingProvider { +public class JdbcStatsMappingProvider { - public PageMapping getMapping(String uri) { + public JdbcStatsMapping getMapping(String uri) { for (JdbcStatsMapping mapping : JdbcStatsMapping.values()) { if (uri.startsWith(mapping.getUri())) { return mapping; @@ -19,11 +16,12 @@ return null; } - public PageMapping getLoginPage() { + public JdbcStatsMapping getLoginPage() { return JdbcStatsMapping.LOGIN; } - public PageMapping get404Page() { + public JdbcStatsMapping get404Page() { return JdbcStatsMapping.NOTFOUND; } + } diff --git a/src/nl/astraeus/jdbc/web/NanoHttpdSimpleWeb.java b/src/nl/astraeus/jdbc/web/NanoHttpdSimpleWeb.java new file mode 100644 index 0000000..393445e --- /dev/null +++ b/src/nl/astraeus/jdbc/web/NanoHttpdSimpleWeb.java @@ -0,0 +1,56 @@ +package nl.astraeus.jdbc.web; + +import fi.iki.elonen.NanoHTTPD; + +public class NanoHttpdSimpleWeb extends NanoHTTPD { + private JdbcStatsMappingProvider mappingProvider; + + public NanoHttpdSimpleWeb(int port, JdbcStatsMappingProvider mappingProvider) { + super(port); + + this.mappingProvider = mappingProvider; + } + + @Override + public Response serve(IHTTPSession session) { + String uri = session.getUri(); + +/* try { + PageFinder finder = new PageFinder(uri, mappingProvider); + + Map files = new HashMap(); + session.parseBody(files); + + NanoHttpdRequestWrapper wrapper = new NanoHttpdRequestWrapper(getListeningPort(), session); + + RequestWrapperHolder.set(wrapper); + + Page page = finder.findPage(); + + ByteArrayOutputStream out = new ByteArrayOutputStream(); + + page.execute(session.getMethod(), out, mappingProvider.getLoginPage().getUri()); + + out.close(); + + byte[] buffer = out.toByteArray(); + + ByteArrayInputStream in = new ByteArrayInputStream(buffer); + // todo: mimetypes + Response response = new Response(wrapper.getStatus(), wrapper.getContentType(), in, -1); + for (Map.Entry entry : wrapper.getResponseHeaders().entrySet()) { + response.addHeader(entry.getKey(), entry.getValue()); + } + return response; + } catch (Exception e) { + logger.warn(e.getMessage(), e); + + throw new IllegalStateException(e); + } finally { + RequestWrapperHolder.remove(); + }*/ + + return newFixedLengthResponse("Ok"); + } + +} \ No newline at end of file diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 41cd493..f9ae410 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -17,7 +17,7 @@ - + diff --git a/.idea/libraries-with-intellij-classes.xml b/.idea/libraries-with-intellij-classes.xml new file mode 100644 index 0000000..9fa3156 --- /dev/null +++ b/.idea/libraries-with-intellij-classes.xml @@ -0,0 +1,65 @@ + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml new file mode 100644 index 0000000..c108f80 --- /dev/null +++ b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml b/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml deleted file mode 100644 index 9a00155..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml b/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml deleted file mode 100644 index 873c2c0..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml new file mode 100644 index 0000000..7d1fc19 --- /dev/null +++ b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index be926a3..6d93540 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,7 +8,7 @@ http://www.w3.org/1999/xhtml - + diff --git a/.idea/modules/simple-jdbc-stats.main.iml b/.idea/modules/simple-jdbc-stats.main.iml index 578407e..50faa2e 100644 --- a/.idea/modules/simple-jdbc-stats.main.iml +++ b/.idea/modules/simple-jdbc-stats.main.iml @@ -1,15 +1,15 @@ - + - - + + \ No newline at end of file diff --git a/.idea/modules/simple-jdbc-stats.test.iml b/.idea/modules/simple-jdbc-stats.test.iml index 62ffcca..f5baeeb 100644 --- a/.idea/modules/simple-jdbc-stats.test.iml +++ b/.idea/modules/simple-jdbc-stats.test.iml @@ -1,7 +1,7 @@ - + @@ -10,8 +10,8 @@ - - + + diff --git a/build.gradle b/build.gradle index 8791f4a..559db71 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,6 @@ apply plugin: 'java' apply plugin: 'idea' apply plugin: 'maven' -apply plugin: 'findbugs' apply plugin: 'maven-publish' sourceSets { @@ -15,8 +14,8 @@ test.resources.srcDirs += 'test' } -sourceCompatibility = 1.5 -targetCompatibility = 1.5 +sourceCompatibility = 1.6 +targetCompatibility = 1.6 repositories { maven { @@ -24,18 +23,23 @@ } } +ext { + PUBLISH_GROUP_ID = group + PUBLISH_VERSION = version + PUBLISH_ARTIFACT_ID = name +} + +apply from: "${rootProject.projectDir}/scripts/publish-mavencentral.gradle" + dependencies { testCompile group: 'junit', name: 'junit', version: '4.12' - testCompile "org.slf4j:slf4j-simple:1.7.21" testCompile "com.h2database:h2:1.4.+" - compile "nl.astraeus.template:very-simple-templates:1.3" - compile "nl.astraeus.web:simple-web:0.3" - compile "org.slf4j:slf4j-api:1.7.21" + compile "com.samskivert:jmustache:1.15" + compile "org.nanohttpd:nanohttpd:2.2.0" configurations.compile.exclude module: 'javax.servlet-api' - configurations.compile.exclude module: 'slf4j-simple' } uploadArchives { @@ -51,10 +55,6 @@ } } -findbugs { - ignoreFailures = true -} - javadoc { failOnError = false } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 088b40b..bd4ca84 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip diff --git a/scripts/publish-mavencentral.gradle b/scripts/publish-mavencentral.gradle new file mode 100644 index 0000000..fae9b85 --- /dev/null +++ b/scripts/publish-mavencentral.gradle @@ -0,0 +1,121 @@ + +apply plugin: 'maven-publish' +apply plugin: 'signing' + +task publishSourcesJar(type: Jar) { + archiveClassifier.set('sources') + + // For pure Kotlin libraries, in case you have them + from sourceSets.main.java.srcDirs + //from sourceSets.main.kotlin.srcDirs +} + +task packageJavadoc(type: Jar) { + from javadoc + classifier = 'javadoc' +} + +artifacts { + archives publishSourcesJar +} + +File secretPropsFile = project.rootProject.file('local.properties') + +ext["signing.keyId"] = '' +ext["signing.password"] = '' +ext["signing.secretKeyRingFile"] = '' +ext["ossrhUsername"] = '' +ext["ossrhPassword"] = '' +ext["sonatypeStagingProfileId"] = '' + +if (secretPropsFile.exists()) { + Properties p = new Properties() + + new FileInputStream(secretPropsFile).withCloseable { is -> + p.load(is) + } + + p.each { name, value -> + ext[name] = value + } +} + +afterEvaluate { + publishing { + publications { + relase(MavenPublication) { + // The coordinates of the library, being set from variables that + // we'll set up later + groupId PUBLISH_GROUP_ID + artifactId PUBLISH_ARTIFACT_ID + version PUBLISH_VERSION + + // Two artifacts, the `aar` (or `jar`) and the sources + if (project.plugins.findPlugin("com.android.library")) { + artifact("$buildDir/outputs/aar/${project.getName()}-release.aar") + } else { + artifact("$buildDir/libs/${project.getName()}-${version}.jar") + } + artifact publishSourcesJar + artifact packageJavadoc + + // Mostly self-explanatory metadata + pom { + name = PUBLISH_ARTIFACT_ID + description = 'Simple JDBC wrapper for query statistics' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics' + licenses { + license { + name = 'MIT License' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics/blob/master/LICENCE.txt' + } + } + developers { + developer { + id = 'rnentjes' + name = 'Rien Nentjes' + email = 'info@nentjes.com' + } + // Add all other devs here... + } + // Version control info - if you're using GitHub, follow the format as seen here + scm { + connection = 'scm:git:github.com/rnentjes/Simple-jdbc-statistics.git' + developerConnection = 'scm:git:ssh://github.com/rnentjes/Simple-jdbc-statistics.git' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics.git/tree/main' + } + // A slightly hacky fix so that your POM will include any transitive dependencies + // that your library builds upon + /* + witXml { + def dependenciesNode = asNode().appendNode('dependencies') + + project.configurations.implementation.allDependencies.each { + def dependencyNode = dependenciesNode.appendNode('dependency') + dependencyNode.appendNode('groupId', it.group) + dependencyNode.appendNode('artifactId', it.name) + dependencyNode.appendNode('version', it.version) + } + }*/ + } + } + } + // The repository to publish to, Sonatype/MavenCentral + repositories { + maven { + // This is an arbitrary name, you may also use "mavencentral" or + // any other name that's descriptive for you + name = "sonatype" + url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" + credentials { + username ossrhUsername + password ossrhPassword + } + } + } + } +} + +signing { + sign publishing.publications +} diff --git a/src/nl/astraeus/jdbc/CallableStatementLogger.java b/src/nl/astraeus/jdbc/CallableStatementLogger.java index 2e9f173..39be81c 100644 --- a/src/nl/astraeus/jdbc/CallableStatementLogger.java +++ b/src/nl/astraeus/jdbc/CallableStatementLogger.java @@ -1,8 +1,5 @@ package nl.astraeus.jdbc; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; @@ -17,8 +14,6 @@ * Time: 9:48 PM */ public class CallableStatementLogger implements CallableStatement { - private final static Logger log = LoggerFactory.getLogger(PreparedStatementLogger.class); - private JdbcLogger logger; private CallableStatement statement; diff --git a/src/nl/astraeus/jdbc/Driver.java b/src/nl/astraeus/jdbc/Driver.java index 046d756..e230a06 100644 --- a/src/nl/astraeus/jdbc/Driver.java +++ b/src/nl/astraeus/jdbc/Driver.java @@ -11,44 +11,38 @@ import java.util.concurrent.ConcurrentHashMap; import nl.astraeus.jdbc.web.JdbcStatsMappingProvider; +import nl.astraeus.jdbc.web.NanoHttpdSimpleWeb; import nl.astraeus.jdbc.web.model.Settings; -import nl.astraeus.web.NanoHttpdSimpleWeb; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * User: riennentjes * Date: Jul 10, 2008 * Time: 8:54:37 PM - * + *

* Test a little change - * */ public class Driver implements java.sql.Driver { - private final static Logger log = LoggerFactory.getLogger(Driver.class); - - final private static String URL_PREFIX = "jdbc:stat:"; - final private static String URL_SECURE_PREFIX = "jdbc:secstat:"; + final private static String URL_PREFIX = "jdbc:stat:"; + final private static String URL_SECURE_PREFIX = "jdbc:secstat:"; public static class StatsLogger { - private volatile boolean started = false; - private NanoHttpdSimpleWeb server = null; - private java.sql.Driver driver = null; - private Settings settings = new Settings(); - private String targetUrl = null; + private volatile boolean started = false; + private NanoHttpdSimpleWeb server = null; + private java.sql.Driver driver = null; + private Settings settings = new Settings(); + private String targetUrl = null; public Settings getSettings() { return settings; } } - private static Map loggers = new ConcurrentHashMap(); - private static Map portMapping = new ConcurrentHashMap(); + private static Map loggers = new ConcurrentHashMap(); + private static Map portMapping = new ConcurrentHashMap(); public static StatsLogger get(String url) { if (!loggers.containsKey(url)) { - throw new IllegalArgumentException("No jdbc statistics logger found for url: "+url); + throw new IllegalArgumentException("No jdbc statistics logger found for url: " + url); } return loggers.get(url); @@ -56,7 +50,7 @@ public static StatsLogger get(int port) { if (!portMapping.containsKey(port)) { - throw new IllegalArgumentException("No jdbc statistics logger found on port: "+port); + throw new IllegalArgumentException("No jdbc statistics logger found on port: " + port); } return portMapping.get(port); @@ -75,7 +69,8 @@ "org.apache.derby.jdbc.EmbeddedDriver", "com.mysql.jdbc.Driver", "org.hsqldb.jdbcDriver", - "org.h2.Driver" }; + "org.h2.Driver" + }; static { log.debug("Loading driver class " + Driver.class.getName()); @@ -123,8 +118,8 @@ logger.settings.setSecure(true); } - String [] parts = url.split("\\:"); - String settingsString = "webServerConnections=5;numberOfQueries=2500;logStacktraces=true;formattedQueries=true"; + String[] parts = url.split("\\:"); + String settingsString = "webServerConnections=5;numberOfQueries=2500;logStacktraces=true;formattedQueries=true"; if (parts.length > 3) { settingsString = parts[2]; @@ -146,7 +141,7 @@ } if (logger.settings.isSecure()) { - String user = info.getProperty("user"); + String user = info.getProperty("user"); String password = info.getProperty("password"); if (user == null || password == null) { @@ -161,15 +156,21 @@ synchronized (this) { if (!logger.started) { try { - NanoHttpdSimpleWeb server = new NanoHttpdSimpleWeb(logger.settings.getWebServerPort(), new JdbcStatsMappingProvider()); + NanoHttpdSimpleWeb server = new NanoHttpdSimpleWeb( + logger.settings.getWebServerPort(), + new JdbcStatsMappingProvider() + ); server.start(); - System.out.println("Started Simple JDBC Statistics\n\turl: "+url+"\n\tport: "+logger.settings.getWebServerPort()); + System.out.println("Started Simple JDBC Statistics\n\turl: " + + url + + "\n\tport: " + + logger.settings.getWebServerPort()); logger.started = true; } catch (Exception e) { - log.error(e.getMessage(),e); + log.error(e.getMessage(), e); } } } diff --git a/src/nl/astraeus/jdbc/JdbcLogger.java b/src/nl/astraeus/jdbc/JdbcLogger.java index 44d09e6..ac7188a 100644 --- a/src/nl/astraeus/jdbc/JdbcLogger.java +++ b/src/nl/astraeus/jdbc/JdbcLogger.java @@ -1,15 +1,10 @@ package nl.astraeus.jdbc; import nl.astraeus.jdbc.util.Util; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import java.util.HashMap; -import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; @@ -19,8 +14,6 @@ * Time: 9:15:21 AM */ public class JdbcLogger { - private final static Logger logger = LoggerFactory.getLogger(JdbcLogger.class); - private final static Map instances = new ConcurrentHashMap(); public static JdbcLogger get(int port) { diff --git a/src/nl/astraeus/jdbc/PreparedStatementLogger.java b/src/nl/astraeus/jdbc/PreparedStatementLogger.java index f97959a..648fea0 100644 --- a/src/nl/astraeus/jdbc/PreparedStatementLogger.java +++ b/src/nl/astraeus/jdbc/PreparedStatementLogger.java @@ -1,8 +1,5 @@ package nl.astraeus.jdbc; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; @@ -25,12 +22,8 @@ import java.sql.Time; import java.sql.Timestamp; import java.util.Calendar; -import java.util.Comparator; -import java.util.HashSet; import java.util.Map; -import java.util.Set; import java.util.TreeMap; -import java.util.TreeSet; /** * User: riennentjes @@ -38,8 +31,6 @@ * Time: 7:47:57 PM */ public class PreparedStatementLogger implements PreparedStatement { - private final static Logger log = LoggerFactory.getLogger(PreparedStatementLogger.class); - private JdbcLogger logger; private PreparedStatement statement; diff --git a/src/nl/astraeus/jdbc/SqlFormatter.java b/src/nl/astraeus/jdbc/SqlFormatter.java index e28810b..8129dfc 100644 --- a/src/nl/astraeus/jdbc/SqlFormatter.java +++ b/src/nl/astraeus/jdbc/SqlFormatter.java @@ -4,17 +4,12 @@ import java.util.List; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/18/12 * Time: 10:10 PM */ public class SqlFormatter { - private final static Logger logger = LoggerFactory.getLogger(SqlFormatter.class); - private static SqlTokenizer tokenizer = new SqlTokenizer(); private static enum Newline { diff --git a/src/nl/astraeus/jdbc/thread/JvmSampler.java b/src/nl/astraeus/jdbc/thread/JvmSampler.java index f1b98d6..155c4ee 100644 --- a/src/nl/astraeus/jdbc/thread/JvmSampler.java +++ b/src/nl/astraeus/jdbc/thread/JvmSampler.java @@ -5,17 +5,12 @@ import java.util.Set; import java.util.TreeSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/22/13 * Time: 8:52 PM */ public class JvmSampler extends Thread { - private final static Logger logger = LoggerFactory.getLogger(JvmSampler.class); - private boolean stopped; private boolean running; diff --git a/src/nl/astraeus/jdbc/util/ReflectHelper.java b/src/nl/astraeus/jdbc/util/ReflectHelper.java index eac090f..7582e04 100644 --- a/src/nl/astraeus/jdbc/util/ReflectHelper.java +++ b/src/nl/astraeus/jdbc/util/ReflectHelper.java @@ -9,17 +9,12 @@ import java.util.List; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 10/16/13 * Time: 4:49 PM */ public class ReflectHelper { - private final static Logger logger = LoggerFactory.getLogger(ReflectHelper.class); - private final static ReflectHelper instance = new ReflectHelper(); public static ReflectHelper get() { diff --git a/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java b/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java index 555b1d3..a70febc 100644 --- a/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java +++ b/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java @@ -9,14 +9,12 @@ import nl.astraeus.jdbc.web.page.ShowStacktrace; import nl.astraeus.jdbc.web.page.TransactionDetail; import nl.astraeus.jdbc.web.page.TransactionOverview; -import nl.astraeus.web.page.Page; -import nl.astraeus.web.page.PageMapping; /** * Date: 11/24/13 * Time: 10:27 AM */ -public enum JdbcStatsMapping implements PageMapping { +public enum JdbcStatsMapping { QUERIES("queries", QueryOverview.class), QUERY("query", QueryDetail.class), @@ -36,8 +34,8 @@ MAIN("", QueryOverview.class), ; - private String uri; - private Class cls; + private final String uri; + private final Class cls; private JdbcStatsMapping(String uri, Class cls) { this.uri = uri; @@ -48,8 +46,8 @@ return uri; } - public Class getPage() { - return (Class) cls; + public Class getPage() { + return cls; } } diff --git a/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java b/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java index b05e76a..36b1819 100644 --- a/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java +++ b/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java @@ -1,15 +1,12 @@ package nl.astraeus.jdbc.web; -import nl.astraeus.web.page.MappingProvider; -import nl.astraeus.web.page.PageMapping; - /** * Date: 11/24/13 * Time: 10:24 AM */ -public class JdbcStatsMappingProvider implements MappingProvider { +public class JdbcStatsMappingProvider { - public PageMapping getMapping(String uri) { + public JdbcStatsMapping getMapping(String uri) { for (JdbcStatsMapping mapping : JdbcStatsMapping.values()) { if (uri.startsWith(mapping.getUri())) { return mapping; @@ -19,11 +16,12 @@ return null; } - public PageMapping getLoginPage() { + public JdbcStatsMapping getLoginPage() { return JdbcStatsMapping.LOGIN; } - public PageMapping get404Page() { + public JdbcStatsMapping get404Page() { return JdbcStatsMapping.NOTFOUND; } + } diff --git a/src/nl/astraeus/jdbc/web/NanoHttpdSimpleWeb.java b/src/nl/astraeus/jdbc/web/NanoHttpdSimpleWeb.java new file mode 100644 index 0000000..393445e --- /dev/null +++ b/src/nl/astraeus/jdbc/web/NanoHttpdSimpleWeb.java @@ -0,0 +1,56 @@ +package nl.astraeus.jdbc.web; + +import fi.iki.elonen.NanoHTTPD; + +public class NanoHttpdSimpleWeb extends NanoHTTPD { + private JdbcStatsMappingProvider mappingProvider; + + public NanoHttpdSimpleWeb(int port, JdbcStatsMappingProvider mappingProvider) { + super(port); + + this.mappingProvider = mappingProvider; + } + + @Override + public Response serve(IHTTPSession session) { + String uri = session.getUri(); + +/* try { + PageFinder finder = new PageFinder(uri, mappingProvider); + + Map files = new HashMap(); + session.parseBody(files); + + NanoHttpdRequestWrapper wrapper = new NanoHttpdRequestWrapper(getListeningPort(), session); + + RequestWrapperHolder.set(wrapper); + + Page page = finder.findPage(); + + ByteArrayOutputStream out = new ByteArrayOutputStream(); + + page.execute(session.getMethod(), out, mappingProvider.getLoginPage().getUri()); + + out.close(); + + byte[] buffer = out.toByteArray(); + + ByteArrayInputStream in = new ByteArrayInputStream(buffer); + // todo: mimetypes + Response response = new Response(wrapper.getStatus(), wrapper.getContentType(), in, -1); + for (Map.Entry entry : wrapper.getResponseHeaders().entrySet()) { + response.addHeader(entry.getKey(), entry.getValue()); + } + return response; + } catch (Exception e) { + logger.warn(e.getMessage(), e); + + throw new IllegalStateException(e); + } finally { + RequestWrapperHolder.remove(); + }*/ + + return newFixedLengthResponse("Ok"); + } + +} \ No newline at end of file diff --git a/src/nl/astraeus/jdbc/web/model/Settings.java b/src/nl/astraeus/jdbc/web/model/Settings.java index 043ca8a..7750833 100644 --- a/src/nl/astraeus/jdbc/web/model/Settings.java +++ b/src/nl/astraeus/jdbc/web/model/Settings.java @@ -1,16 +1,11 @@ package nl.astraeus.jdbc.web.model; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/22/12 * Time: 1:53 PM */ public class Settings { - private final static Logger logger = LoggerFactory.getLogger(Settings.class); - private final static String NUMBER_OF_QUERIES = "numberOfQueries"; private final static String LOG_STACKTRACES = "logStacktraces"; private final static String FORMATTED_QUERIES = "formattedQueries"; diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 41cd493..f9ae410 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -17,7 +17,7 @@ - + diff --git a/.idea/libraries-with-intellij-classes.xml b/.idea/libraries-with-intellij-classes.xml new file mode 100644 index 0000000..9fa3156 --- /dev/null +++ b/.idea/libraries-with-intellij-classes.xml @@ -0,0 +1,65 @@ + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml new file mode 100644 index 0000000..c108f80 --- /dev/null +++ b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml b/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml deleted file mode 100644 index 9a00155..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml b/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml deleted file mode 100644 index 873c2c0..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml new file mode 100644 index 0000000..7d1fc19 --- /dev/null +++ b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index be926a3..6d93540 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,7 +8,7 @@ http://www.w3.org/1999/xhtml - + diff --git a/.idea/modules/simple-jdbc-stats.main.iml b/.idea/modules/simple-jdbc-stats.main.iml index 578407e..50faa2e 100644 --- a/.idea/modules/simple-jdbc-stats.main.iml +++ b/.idea/modules/simple-jdbc-stats.main.iml @@ -1,15 +1,15 @@ - + - - + + \ No newline at end of file diff --git a/.idea/modules/simple-jdbc-stats.test.iml b/.idea/modules/simple-jdbc-stats.test.iml index 62ffcca..f5baeeb 100644 --- a/.idea/modules/simple-jdbc-stats.test.iml +++ b/.idea/modules/simple-jdbc-stats.test.iml @@ -1,7 +1,7 @@ - + @@ -10,8 +10,8 @@ - - + + diff --git a/build.gradle b/build.gradle index 8791f4a..559db71 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,6 @@ apply plugin: 'java' apply plugin: 'idea' apply plugin: 'maven' -apply plugin: 'findbugs' apply plugin: 'maven-publish' sourceSets { @@ -15,8 +14,8 @@ test.resources.srcDirs += 'test' } -sourceCompatibility = 1.5 -targetCompatibility = 1.5 +sourceCompatibility = 1.6 +targetCompatibility = 1.6 repositories { maven { @@ -24,18 +23,23 @@ } } +ext { + PUBLISH_GROUP_ID = group + PUBLISH_VERSION = version + PUBLISH_ARTIFACT_ID = name +} + +apply from: "${rootProject.projectDir}/scripts/publish-mavencentral.gradle" + dependencies { testCompile group: 'junit', name: 'junit', version: '4.12' - testCompile "org.slf4j:slf4j-simple:1.7.21" testCompile "com.h2database:h2:1.4.+" - compile "nl.astraeus.template:very-simple-templates:1.3" - compile "nl.astraeus.web:simple-web:0.3" - compile "org.slf4j:slf4j-api:1.7.21" + compile "com.samskivert:jmustache:1.15" + compile "org.nanohttpd:nanohttpd:2.2.0" configurations.compile.exclude module: 'javax.servlet-api' - configurations.compile.exclude module: 'slf4j-simple' } uploadArchives { @@ -51,10 +55,6 @@ } } -findbugs { - ignoreFailures = true -} - javadoc { failOnError = false } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 088b40b..bd4ca84 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip diff --git a/scripts/publish-mavencentral.gradle b/scripts/publish-mavencentral.gradle new file mode 100644 index 0000000..fae9b85 --- /dev/null +++ b/scripts/publish-mavencentral.gradle @@ -0,0 +1,121 @@ + +apply plugin: 'maven-publish' +apply plugin: 'signing' + +task publishSourcesJar(type: Jar) { + archiveClassifier.set('sources') + + // For pure Kotlin libraries, in case you have them + from sourceSets.main.java.srcDirs + //from sourceSets.main.kotlin.srcDirs +} + +task packageJavadoc(type: Jar) { + from javadoc + classifier = 'javadoc' +} + +artifacts { + archives publishSourcesJar +} + +File secretPropsFile = project.rootProject.file('local.properties') + +ext["signing.keyId"] = '' +ext["signing.password"] = '' +ext["signing.secretKeyRingFile"] = '' +ext["ossrhUsername"] = '' +ext["ossrhPassword"] = '' +ext["sonatypeStagingProfileId"] = '' + +if (secretPropsFile.exists()) { + Properties p = new Properties() + + new FileInputStream(secretPropsFile).withCloseable { is -> + p.load(is) + } + + p.each { name, value -> + ext[name] = value + } +} + +afterEvaluate { + publishing { + publications { + relase(MavenPublication) { + // The coordinates of the library, being set from variables that + // we'll set up later + groupId PUBLISH_GROUP_ID + artifactId PUBLISH_ARTIFACT_ID + version PUBLISH_VERSION + + // Two artifacts, the `aar` (or `jar`) and the sources + if (project.plugins.findPlugin("com.android.library")) { + artifact("$buildDir/outputs/aar/${project.getName()}-release.aar") + } else { + artifact("$buildDir/libs/${project.getName()}-${version}.jar") + } + artifact publishSourcesJar + artifact packageJavadoc + + // Mostly self-explanatory metadata + pom { + name = PUBLISH_ARTIFACT_ID + description = 'Simple JDBC wrapper for query statistics' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics' + licenses { + license { + name = 'MIT License' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics/blob/master/LICENCE.txt' + } + } + developers { + developer { + id = 'rnentjes' + name = 'Rien Nentjes' + email = 'info@nentjes.com' + } + // Add all other devs here... + } + // Version control info - if you're using GitHub, follow the format as seen here + scm { + connection = 'scm:git:github.com/rnentjes/Simple-jdbc-statistics.git' + developerConnection = 'scm:git:ssh://github.com/rnentjes/Simple-jdbc-statistics.git' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics.git/tree/main' + } + // A slightly hacky fix so that your POM will include any transitive dependencies + // that your library builds upon + /* + witXml { + def dependenciesNode = asNode().appendNode('dependencies') + + project.configurations.implementation.allDependencies.each { + def dependencyNode = dependenciesNode.appendNode('dependency') + dependencyNode.appendNode('groupId', it.group) + dependencyNode.appendNode('artifactId', it.name) + dependencyNode.appendNode('version', it.version) + } + }*/ + } + } + } + // The repository to publish to, Sonatype/MavenCentral + repositories { + maven { + // This is an arbitrary name, you may also use "mavencentral" or + // any other name that's descriptive for you + name = "sonatype" + url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" + credentials { + username ossrhUsername + password ossrhPassword + } + } + } + } +} + +signing { + sign publishing.publications +} diff --git a/src/nl/astraeus/jdbc/CallableStatementLogger.java b/src/nl/astraeus/jdbc/CallableStatementLogger.java index 2e9f173..39be81c 100644 --- a/src/nl/astraeus/jdbc/CallableStatementLogger.java +++ b/src/nl/astraeus/jdbc/CallableStatementLogger.java @@ -1,8 +1,5 @@ package nl.astraeus.jdbc; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; @@ -17,8 +14,6 @@ * Time: 9:48 PM */ public class CallableStatementLogger implements CallableStatement { - private final static Logger log = LoggerFactory.getLogger(PreparedStatementLogger.class); - private JdbcLogger logger; private CallableStatement statement; diff --git a/src/nl/astraeus/jdbc/Driver.java b/src/nl/astraeus/jdbc/Driver.java index 046d756..e230a06 100644 --- a/src/nl/astraeus/jdbc/Driver.java +++ b/src/nl/astraeus/jdbc/Driver.java @@ -11,44 +11,38 @@ import java.util.concurrent.ConcurrentHashMap; import nl.astraeus.jdbc.web.JdbcStatsMappingProvider; +import nl.astraeus.jdbc.web.NanoHttpdSimpleWeb; import nl.astraeus.jdbc.web.model.Settings; -import nl.astraeus.web.NanoHttpdSimpleWeb; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * User: riennentjes * Date: Jul 10, 2008 * Time: 8:54:37 PM - * + *

* Test a little change - * */ public class Driver implements java.sql.Driver { - private final static Logger log = LoggerFactory.getLogger(Driver.class); - - final private static String URL_PREFIX = "jdbc:stat:"; - final private static String URL_SECURE_PREFIX = "jdbc:secstat:"; + final private static String URL_PREFIX = "jdbc:stat:"; + final private static String URL_SECURE_PREFIX = "jdbc:secstat:"; public static class StatsLogger { - private volatile boolean started = false; - private NanoHttpdSimpleWeb server = null; - private java.sql.Driver driver = null; - private Settings settings = new Settings(); - private String targetUrl = null; + private volatile boolean started = false; + private NanoHttpdSimpleWeb server = null; + private java.sql.Driver driver = null; + private Settings settings = new Settings(); + private String targetUrl = null; public Settings getSettings() { return settings; } } - private static Map loggers = new ConcurrentHashMap(); - private static Map portMapping = new ConcurrentHashMap(); + private static Map loggers = new ConcurrentHashMap(); + private static Map portMapping = new ConcurrentHashMap(); public static StatsLogger get(String url) { if (!loggers.containsKey(url)) { - throw new IllegalArgumentException("No jdbc statistics logger found for url: "+url); + throw new IllegalArgumentException("No jdbc statistics logger found for url: " + url); } return loggers.get(url); @@ -56,7 +50,7 @@ public static StatsLogger get(int port) { if (!portMapping.containsKey(port)) { - throw new IllegalArgumentException("No jdbc statistics logger found on port: "+port); + throw new IllegalArgumentException("No jdbc statistics logger found on port: " + port); } return portMapping.get(port); @@ -75,7 +69,8 @@ "org.apache.derby.jdbc.EmbeddedDriver", "com.mysql.jdbc.Driver", "org.hsqldb.jdbcDriver", - "org.h2.Driver" }; + "org.h2.Driver" + }; static { log.debug("Loading driver class " + Driver.class.getName()); @@ -123,8 +118,8 @@ logger.settings.setSecure(true); } - String [] parts = url.split("\\:"); - String settingsString = "webServerConnections=5;numberOfQueries=2500;logStacktraces=true;formattedQueries=true"; + String[] parts = url.split("\\:"); + String settingsString = "webServerConnections=5;numberOfQueries=2500;logStacktraces=true;formattedQueries=true"; if (parts.length > 3) { settingsString = parts[2]; @@ -146,7 +141,7 @@ } if (logger.settings.isSecure()) { - String user = info.getProperty("user"); + String user = info.getProperty("user"); String password = info.getProperty("password"); if (user == null || password == null) { @@ -161,15 +156,21 @@ synchronized (this) { if (!logger.started) { try { - NanoHttpdSimpleWeb server = new NanoHttpdSimpleWeb(logger.settings.getWebServerPort(), new JdbcStatsMappingProvider()); + NanoHttpdSimpleWeb server = new NanoHttpdSimpleWeb( + logger.settings.getWebServerPort(), + new JdbcStatsMappingProvider() + ); server.start(); - System.out.println("Started Simple JDBC Statistics\n\turl: "+url+"\n\tport: "+logger.settings.getWebServerPort()); + System.out.println("Started Simple JDBC Statistics\n\turl: " + + url + + "\n\tport: " + + logger.settings.getWebServerPort()); logger.started = true; } catch (Exception e) { - log.error(e.getMessage(),e); + log.error(e.getMessage(), e); } } } diff --git a/src/nl/astraeus/jdbc/JdbcLogger.java b/src/nl/astraeus/jdbc/JdbcLogger.java index 44d09e6..ac7188a 100644 --- a/src/nl/astraeus/jdbc/JdbcLogger.java +++ b/src/nl/astraeus/jdbc/JdbcLogger.java @@ -1,15 +1,10 @@ package nl.astraeus.jdbc; import nl.astraeus.jdbc.util.Util; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import java.util.HashMap; -import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; @@ -19,8 +14,6 @@ * Time: 9:15:21 AM */ public class JdbcLogger { - private final static Logger logger = LoggerFactory.getLogger(JdbcLogger.class); - private final static Map instances = new ConcurrentHashMap(); public static JdbcLogger get(int port) { diff --git a/src/nl/astraeus/jdbc/PreparedStatementLogger.java b/src/nl/astraeus/jdbc/PreparedStatementLogger.java index f97959a..648fea0 100644 --- a/src/nl/astraeus/jdbc/PreparedStatementLogger.java +++ b/src/nl/astraeus/jdbc/PreparedStatementLogger.java @@ -1,8 +1,5 @@ package nl.astraeus.jdbc; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; @@ -25,12 +22,8 @@ import java.sql.Time; import java.sql.Timestamp; import java.util.Calendar; -import java.util.Comparator; -import java.util.HashSet; import java.util.Map; -import java.util.Set; import java.util.TreeMap; -import java.util.TreeSet; /** * User: riennentjes @@ -38,8 +31,6 @@ * Time: 7:47:57 PM */ public class PreparedStatementLogger implements PreparedStatement { - private final static Logger log = LoggerFactory.getLogger(PreparedStatementLogger.class); - private JdbcLogger logger; private PreparedStatement statement; diff --git a/src/nl/astraeus/jdbc/SqlFormatter.java b/src/nl/astraeus/jdbc/SqlFormatter.java index e28810b..8129dfc 100644 --- a/src/nl/astraeus/jdbc/SqlFormatter.java +++ b/src/nl/astraeus/jdbc/SqlFormatter.java @@ -4,17 +4,12 @@ import java.util.List; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/18/12 * Time: 10:10 PM */ public class SqlFormatter { - private final static Logger logger = LoggerFactory.getLogger(SqlFormatter.class); - private static SqlTokenizer tokenizer = new SqlTokenizer(); private static enum Newline { diff --git a/src/nl/astraeus/jdbc/thread/JvmSampler.java b/src/nl/astraeus/jdbc/thread/JvmSampler.java index f1b98d6..155c4ee 100644 --- a/src/nl/astraeus/jdbc/thread/JvmSampler.java +++ b/src/nl/astraeus/jdbc/thread/JvmSampler.java @@ -5,17 +5,12 @@ import java.util.Set; import java.util.TreeSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/22/13 * Time: 8:52 PM */ public class JvmSampler extends Thread { - private final static Logger logger = LoggerFactory.getLogger(JvmSampler.class); - private boolean stopped; private boolean running; diff --git a/src/nl/astraeus/jdbc/util/ReflectHelper.java b/src/nl/astraeus/jdbc/util/ReflectHelper.java index eac090f..7582e04 100644 --- a/src/nl/astraeus/jdbc/util/ReflectHelper.java +++ b/src/nl/astraeus/jdbc/util/ReflectHelper.java @@ -9,17 +9,12 @@ import java.util.List; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 10/16/13 * Time: 4:49 PM */ public class ReflectHelper { - private final static Logger logger = LoggerFactory.getLogger(ReflectHelper.class); - private final static ReflectHelper instance = new ReflectHelper(); public static ReflectHelper get() { diff --git a/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java b/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java index 555b1d3..a70febc 100644 --- a/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java +++ b/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java @@ -9,14 +9,12 @@ import nl.astraeus.jdbc.web.page.ShowStacktrace; import nl.astraeus.jdbc.web.page.TransactionDetail; import nl.astraeus.jdbc.web.page.TransactionOverview; -import nl.astraeus.web.page.Page; -import nl.astraeus.web.page.PageMapping; /** * Date: 11/24/13 * Time: 10:27 AM */ -public enum JdbcStatsMapping implements PageMapping { +public enum JdbcStatsMapping { QUERIES("queries", QueryOverview.class), QUERY("query", QueryDetail.class), @@ -36,8 +34,8 @@ MAIN("", QueryOverview.class), ; - private String uri; - private Class cls; + private final String uri; + private final Class cls; private JdbcStatsMapping(String uri, Class cls) { this.uri = uri; @@ -48,8 +46,8 @@ return uri; } - public Class getPage() { - return (Class) cls; + public Class getPage() { + return cls; } } diff --git a/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java b/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java index b05e76a..36b1819 100644 --- a/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java +++ b/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java @@ -1,15 +1,12 @@ package nl.astraeus.jdbc.web; -import nl.astraeus.web.page.MappingProvider; -import nl.astraeus.web.page.PageMapping; - /** * Date: 11/24/13 * Time: 10:24 AM */ -public class JdbcStatsMappingProvider implements MappingProvider { +public class JdbcStatsMappingProvider { - public PageMapping getMapping(String uri) { + public JdbcStatsMapping getMapping(String uri) { for (JdbcStatsMapping mapping : JdbcStatsMapping.values()) { if (uri.startsWith(mapping.getUri())) { return mapping; @@ -19,11 +16,12 @@ return null; } - public PageMapping getLoginPage() { + public JdbcStatsMapping getLoginPage() { return JdbcStatsMapping.LOGIN; } - public PageMapping get404Page() { + public JdbcStatsMapping get404Page() { return JdbcStatsMapping.NOTFOUND; } + } diff --git a/src/nl/astraeus/jdbc/web/NanoHttpdSimpleWeb.java b/src/nl/astraeus/jdbc/web/NanoHttpdSimpleWeb.java new file mode 100644 index 0000000..393445e --- /dev/null +++ b/src/nl/astraeus/jdbc/web/NanoHttpdSimpleWeb.java @@ -0,0 +1,56 @@ +package nl.astraeus.jdbc.web; + +import fi.iki.elonen.NanoHTTPD; + +public class NanoHttpdSimpleWeb extends NanoHTTPD { + private JdbcStatsMappingProvider mappingProvider; + + public NanoHttpdSimpleWeb(int port, JdbcStatsMappingProvider mappingProvider) { + super(port); + + this.mappingProvider = mappingProvider; + } + + @Override + public Response serve(IHTTPSession session) { + String uri = session.getUri(); + +/* try { + PageFinder finder = new PageFinder(uri, mappingProvider); + + Map files = new HashMap(); + session.parseBody(files); + + NanoHttpdRequestWrapper wrapper = new NanoHttpdRequestWrapper(getListeningPort(), session); + + RequestWrapperHolder.set(wrapper); + + Page page = finder.findPage(); + + ByteArrayOutputStream out = new ByteArrayOutputStream(); + + page.execute(session.getMethod(), out, mappingProvider.getLoginPage().getUri()); + + out.close(); + + byte[] buffer = out.toByteArray(); + + ByteArrayInputStream in = new ByteArrayInputStream(buffer); + // todo: mimetypes + Response response = new Response(wrapper.getStatus(), wrapper.getContentType(), in, -1); + for (Map.Entry entry : wrapper.getResponseHeaders().entrySet()) { + response.addHeader(entry.getKey(), entry.getValue()); + } + return response; + } catch (Exception e) { + logger.warn(e.getMessage(), e); + + throw new IllegalStateException(e); + } finally { + RequestWrapperHolder.remove(); + }*/ + + return newFixedLengthResponse("Ok"); + } + +} \ No newline at end of file diff --git a/src/nl/astraeus/jdbc/web/model/Settings.java b/src/nl/astraeus/jdbc/web/model/Settings.java index 043ca8a..7750833 100644 --- a/src/nl/astraeus/jdbc/web/model/Settings.java +++ b/src/nl/astraeus/jdbc/web/model/Settings.java @@ -1,16 +1,11 @@ package nl.astraeus.jdbc.web.model; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/22/12 * Time: 1:53 PM */ public class Settings { - private final static Logger logger = LoggerFactory.getLogger(Settings.class); - private final static String NUMBER_OF_QUERIES = "numberOfQueries"; private final static String LOG_STACKTRACES = "logStacktraces"; private final static String FORMATTED_QUERIES = "formattedQueries"; diff --git a/src/nl/astraeus/jdbc/web/page/FooterPage.java b/src/nl/astraeus/jdbc/web/page/FooterPage.java index fcf9931..c09b12c 100644 --- a/src/nl/astraeus/jdbc/web/page/FooterPage.java +++ b/src/nl/astraeus/jdbc/web/page/FooterPage.java @@ -1,7 +1,5 @@ package nl.astraeus.jdbc.web.page; -import nl.astraeus.web.page.TemplatePage; - /** * Date: 11/17/13 * Time: 2:31 PM diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 41cd493..f9ae410 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -17,7 +17,7 @@ - + diff --git a/.idea/libraries-with-intellij-classes.xml b/.idea/libraries-with-intellij-classes.xml new file mode 100644 index 0000000..9fa3156 --- /dev/null +++ b/.idea/libraries-with-intellij-classes.xml @@ -0,0 +1,65 @@ + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml new file mode 100644 index 0000000..c108f80 --- /dev/null +++ b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml b/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml deleted file mode 100644 index 9a00155..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml b/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml deleted file mode 100644 index 873c2c0..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml new file mode 100644 index 0000000..7d1fc19 --- /dev/null +++ b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index be926a3..6d93540 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,7 +8,7 @@ http://www.w3.org/1999/xhtml - + diff --git a/.idea/modules/simple-jdbc-stats.main.iml b/.idea/modules/simple-jdbc-stats.main.iml index 578407e..50faa2e 100644 --- a/.idea/modules/simple-jdbc-stats.main.iml +++ b/.idea/modules/simple-jdbc-stats.main.iml @@ -1,15 +1,15 @@ - + - - + + \ No newline at end of file diff --git a/.idea/modules/simple-jdbc-stats.test.iml b/.idea/modules/simple-jdbc-stats.test.iml index 62ffcca..f5baeeb 100644 --- a/.idea/modules/simple-jdbc-stats.test.iml +++ b/.idea/modules/simple-jdbc-stats.test.iml @@ -1,7 +1,7 @@ - + @@ -10,8 +10,8 @@ - - + + diff --git a/build.gradle b/build.gradle index 8791f4a..559db71 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,6 @@ apply plugin: 'java' apply plugin: 'idea' apply plugin: 'maven' -apply plugin: 'findbugs' apply plugin: 'maven-publish' sourceSets { @@ -15,8 +14,8 @@ test.resources.srcDirs += 'test' } -sourceCompatibility = 1.5 -targetCompatibility = 1.5 +sourceCompatibility = 1.6 +targetCompatibility = 1.6 repositories { maven { @@ -24,18 +23,23 @@ } } +ext { + PUBLISH_GROUP_ID = group + PUBLISH_VERSION = version + PUBLISH_ARTIFACT_ID = name +} + +apply from: "${rootProject.projectDir}/scripts/publish-mavencentral.gradle" + dependencies { testCompile group: 'junit', name: 'junit', version: '4.12' - testCompile "org.slf4j:slf4j-simple:1.7.21" testCompile "com.h2database:h2:1.4.+" - compile "nl.astraeus.template:very-simple-templates:1.3" - compile "nl.astraeus.web:simple-web:0.3" - compile "org.slf4j:slf4j-api:1.7.21" + compile "com.samskivert:jmustache:1.15" + compile "org.nanohttpd:nanohttpd:2.2.0" configurations.compile.exclude module: 'javax.servlet-api' - configurations.compile.exclude module: 'slf4j-simple' } uploadArchives { @@ -51,10 +55,6 @@ } } -findbugs { - ignoreFailures = true -} - javadoc { failOnError = false } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 088b40b..bd4ca84 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip diff --git a/scripts/publish-mavencentral.gradle b/scripts/publish-mavencentral.gradle new file mode 100644 index 0000000..fae9b85 --- /dev/null +++ b/scripts/publish-mavencentral.gradle @@ -0,0 +1,121 @@ + +apply plugin: 'maven-publish' +apply plugin: 'signing' + +task publishSourcesJar(type: Jar) { + archiveClassifier.set('sources') + + // For pure Kotlin libraries, in case you have them + from sourceSets.main.java.srcDirs + //from sourceSets.main.kotlin.srcDirs +} + +task packageJavadoc(type: Jar) { + from javadoc + classifier = 'javadoc' +} + +artifacts { + archives publishSourcesJar +} + +File secretPropsFile = project.rootProject.file('local.properties') + +ext["signing.keyId"] = '' +ext["signing.password"] = '' +ext["signing.secretKeyRingFile"] = '' +ext["ossrhUsername"] = '' +ext["ossrhPassword"] = '' +ext["sonatypeStagingProfileId"] = '' + +if (secretPropsFile.exists()) { + Properties p = new Properties() + + new FileInputStream(secretPropsFile).withCloseable { is -> + p.load(is) + } + + p.each { name, value -> + ext[name] = value + } +} + +afterEvaluate { + publishing { + publications { + relase(MavenPublication) { + // The coordinates of the library, being set from variables that + // we'll set up later + groupId PUBLISH_GROUP_ID + artifactId PUBLISH_ARTIFACT_ID + version PUBLISH_VERSION + + // Two artifacts, the `aar` (or `jar`) and the sources + if (project.plugins.findPlugin("com.android.library")) { + artifact("$buildDir/outputs/aar/${project.getName()}-release.aar") + } else { + artifact("$buildDir/libs/${project.getName()}-${version}.jar") + } + artifact publishSourcesJar + artifact packageJavadoc + + // Mostly self-explanatory metadata + pom { + name = PUBLISH_ARTIFACT_ID + description = 'Simple JDBC wrapper for query statistics' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics' + licenses { + license { + name = 'MIT License' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics/blob/master/LICENCE.txt' + } + } + developers { + developer { + id = 'rnentjes' + name = 'Rien Nentjes' + email = 'info@nentjes.com' + } + // Add all other devs here... + } + // Version control info - if you're using GitHub, follow the format as seen here + scm { + connection = 'scm:git:github.com/rnentjes/Simple-jdbc-statistics.git' + developerConnection = 'scm:git:ssh://github.com/rnentjes/Simple-jdbc-statistics.git' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics.git/tree/main' + } + // A slightly hacky fix so that your POM will include any transitive dependencies + // that your library builds upon + /* + witXml { + def dependenciesNode = asNode().appendNode('dependencies') + + project.configurations.implementation.allDependencies.each { + def dependencyNode = dependenciesNode.appendNode('dependency') + dependencyNode.appendNode('groupId', it.group) + dependencyNode.appendNode('artifactId', it.name) + dependencyNode.appendNode('version', it.version) + } + }*/ + } + } + } + // The repository to publish to, Sonatype/MavenCentral + repositories { + maven { + // This is an arbitrary name, you may also use "mavencentral" or + // any other name that's descriptive for you + name = "sonatype" + url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" + credentials { + username ossrhUsername + password ossrhPassword + } + } + } + } +} + +signing { + sign publishing.publications +} diff --git a/src/nl/astraeus/jdbc/CallableStatementLogger.java b/src/nl/astraeus/jdbc/CallableStatementLogger.java index 2e9f173..39be81c 100644 --- a/src/nl/astraeus/jdbc/CallableStatementLogger.java +++ b/src/nl/astraeus/jdbc/CallableStatementLogger.java @@ -1,8 +1,5 @@ package nl.astraeus.jdbc; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; @@ -17,8 +14,6 @@ * Time: 9:48 PM */ public class CallableStatementLogger implements CallableStatement { - private final static Logger log = LoggerFactory.getLogger(PreparedStatementLogger.class); - private JdbcLogger logger; private CallableStatement statement; diff --git a/src/nl/astraeus/jdbc/Driver.java b/src/nl/astraeus/jdbc/Driver.java index 046d756..e230a06 100644 --- a/src/nl/astraeus/jdbc/Driver.java +++ b/src/nl/astraeus/jdbc/Driver.java @@ -11,44 +11,38 @@ import java.util.concurrent.ConcurrentHashMap; import nl.astraeus.jdbc.web.JdbcStatsMappingProvider; +import nl.astraeus.jdbc.web.NanoHttpdSimpleWeb; import nl.astraeus.jdbc.web.model.Settings; -import nl.astraeus.web.NanoHttpdSimpleWeb; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * User: riennentjes * Date: Jul 10, 2008 * Time: 8:54:37 PM - * + *

* Test a little change - * */ public class Driver implements java.sql.Driver { - private final static Logger log = LoggerFactory.getLogger(Driver.class); - - final private static String URL_PREFIX = "jdbc:stat:"; - final private static String URL_SECURE_PREFIX = "jdbc:secstat:"; + final private static String URL_PREFIX = "jdbc:stat:"; + final private static String URL_SECURE_PREFIX = "jdbc:secstat:"; public static class StatsLogger { - private volatile boolean started = false; - private NanoHttpdSimpleWeb server = null; - private java.sql.Driver driver = null; - private Settings settings = new Settings(); - private String targetUrl = null; + private volatile boolean started = false; + private NanoHttpdSimpleWeb server = null; + private java.sql.Driver driver = null; + private Settings settings = new Settings(); + private String targetUrl = null; public Settings getSettings() { return settings; } } - private static Map loggers = new ConcurrentHashMap(); - private static Map portMapping = new ConcurrentHashMap(); + private static Map loggers = new ConcurrentHashMap(); + private static Map portMapping = new ConcurrentHashMap(); public static StatsLogger get(String url) { if (!loggers.containsKey(url)) { - throw new IllegalArgumentException("No jdbc statistics logger found for url: "+url); + throw new IllegalArgumentException("No jdbc statistics logger found for url: " + url); } return loggers.get(url); @@ -56,7 +50,7 @@ public static StatsLogger get(int port) { if (!portMapping.containsKey(port)) { - throw new IllegalArgumentException("No jdbc statistics logger found on port: "+port); + throw new IllegalArgumentException("No jdbc statistics logger found on port: " + port); } return portMapping.get(port); @@ -75,7 +69,8 @@ "org.apache.derby.jdbc.EmbeddedDriver", "com.mysql.jdbc.Driver", "org.hsqldb.jdbcDriver", - "org.h2.Driver" }; + "org.h2.Driver" + }; static { log.debug("Loading driver class " + Driver.class.getName()); @@ -123,8 +118,8 @@ logger.settings.setSecure(true); } - String [] parts = url.split("\\:"); - String settingsString = "webServerConnections=5;numberOfQueries=2500;logStacktraces=true;formattedQueries=true"; + String[] parts = url.split("\\:"); + String settingsString = "webServerConnections=5;numberOfQueries=2500;logStacktraces=true;formattedQueries=true"; if (parts.length > 3) { settingsString = parts[2]; @@ -146,7 +141,7 @@ } if (logger.settings.isSecure()) { - String user = info.getProperty("user"); + String user = info.getProperty("user"); String password = info.getProperty("password"); if (user == null || password == null) { @@ -161,15 +156,21 @@ synchronized (this) { if (!logger.started) { try { - NanoHttpdSimpleWeb server = new NanoHttpdSimpleWeb(logger.settings.getWebServerPort(), new JdbcStatsMappingProvider()); + NanoHttpdSimpleWeb server = new NanoHttpdSimpleWeb( + logger.settings.getWebServerPort(), + new JdbcStatsMappingProvider() + ); server.start(); - System.out.println("Started Simple JDBC Statistics\n\turl: "+url+"\n\tport: "+logger.settings.getWebServerPort()); + System.out.println("Started Simple JDBC Statistics\n\turl: " + + url + + "\n\tport: " + + logger.settings.getWebServerPort()); logger.started = true; } catch (Exception e) { - log.error(e.getMessage(),e); + log.error(e.getMessage(), e); } } } diff --git a/src/nl/astraeus/jdbc/JdbcLogger.java b/src/nl/astraeus/jdbc/JdbcLogger.java index 44d09e6..ac7188a 100644 --- a/src/nl/astraeus/jdbc/JdbcLogger.java +++ b/src/nl/astraeus/jdbc/JdbcLogger.java @@ -1,15 +1,10 @@ package nl.astraeus.jdbc; import nl.astraeus.jdbc.util.Util; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import java.util.HashMap; -import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; @@ -19,8 +14,6 @@ * Time: 9:15:21 AM */ public class JdbcLogger { - private final static Logger logger = LoggerFactory.getLogger(JdbcLogger.class); - private final static Map instances = new ConcurrentHashMap(); public static JdbcLogger get(int port) { diff --git a/src/nl/astraeus/jdbc/PreparedStatementLogger.java b/src/nl/astraeus/jdbc/PreparedStatementLogger.java index f97959a..648fea0 100644 --- a/src/nl/astraeus/jdbc/PreparedStatementLogger.java +++ b/src/nl/astraeus/jdbc/PreparedStatementLogger.java @@ -1,8 +1,5 @@ package nl.astraeus.jdbc; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; @@ -25,12 +22,8 @@ import java.sql.Time; import java.sql.Timestamp; import java.util.Calendar; -import java.util.Comparator; -import java.util.HashSet; import java.util.Map; -import java.util.Set; import java.util.TreeMap; -import java.util.TreeSet; /** * User: riennentjes @@ -38,8 +31,6 @@ * Time: 7:47:57 PM */ public class PreparedStatementLogger implements PreparedStatement { - private final static Logger log = LoggerFactory.getLogger(PreparedStatementLogger.class); - private JdbcLogger logger; private PreparedStatement statement; diff --git a/src/nl/astraeus/jdbc/SqlFormatter.java b/src/nl/astraeus/jdbc/SqlFormatter.java index e28810b..8129dfc 100644 --- a/src/nl/astraeus/jdbc/SqlFormatter.java +++ b/src/nl/astraeus/jdbc/SqlFormatter.java @@ -4,17 +4,12 @@ import java.util.List; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/18/12 * Time: 10:10 PM */ public class SqlFormatter { - private final static Logger logger = LoggerFactory.getLogger(SqlFormatter.class); - private static SqlTokenizer tokenizer = new SqlTokenizer(); private static enum Newline { diff --git a/src/nl/astraeus/jdbc/thread/JvmSampler.java b/src/nl/astraeus/jdbc/thread/JvmSampler.java index f1b98d6..155c4ee 100644 --- a/src/nl/astraeus/jdbc/thread/JvmSampler.java +++ b/src/nl/astraeus/jdbc/thread/JvmSampler.java @@ -5,17 +5,12 @@ import java.util.Set; import java.util.TreeSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/22/13 * Time: 8:52 PM */ public class JvmSampler extends Thread { - private final static Logger logger = LoggerFactory.getLogger(JvmSampler.class); - private boolean stopped; private boolean running; diff --git a/src/nl/astraeus/jdbc/util/ReflectHelper.java b/src/nl/astraeus/jdbc/util/ReflectHelper.java index eac090f..7582e04 100644 --- a/src/nl/astraeus/jdbc/util/ReflectHelper.java +++ b/src/nl/astraeus/jdbc/util/ReflectHelper.java @@ -9,17 +9,12 @@ import java.util.List; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 10/16/13 * Time: 4:49 PM */ public class ReflectHelper { - private final static Logger logger = LoggerFactory.getLogger(ReflectHelper.class); - private final static ReflectHelper instance = new ReflectHelper(); public static ReflectHelper get() { diff --git a/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java b/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java index 555b1d3..a70febc 100644 --- a/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java +++ b/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java @@ -9,14 +9,12 @@ import nl.astraeus.jdbc.web.page.ShowStacktrace; import nl.astraeus.jdbc.web.page.TransactionDetail; import nl.astraeus.jdbc.web.page.TransactionOverview; -import nl.astraeus.web.page.Page; -import nl.astraeus.web.page.PageMapping; /** * Date: 11/24/13 * Time: 10:27 AM */ -public enum JdbcStatsMapping implements PageMapping { +public enum JdbcStatsMapping { QUERIES("queries", QueryOverview.class), QUERY("query", QueryDetail.class), @@ -36,8 +34,8 @@ MAIN("", QueryOverview.class), ; - private String uri; - private Class cls; + private final String uri; + private final Class cls; private JdbcStatsMapping(String uri, Class cls) { this.uri = uri; @@ -48,8 +46,8 @@ return uri; } - public Class getPage() { - return (Class) cls; + public Class getPage() { + return cls; } } diff --git a/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java b/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java index b05e76a..36b1819 100644 --- a/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java +++ b/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java @@ -1,15 +1,12 @@ package nl.astraeus.jdbc.web; -import nl.astraeus.web.page.MappingProvider; -import nl.astraeus.web.page.PageMapping; - /** * Date: 11/24/13 * Time: 10:24 AM */ -public class JdbcStatsMappingProvider implements MappingProvider { +public class JdbcStatsMappingProvider { - public PageMapping getMapping(String uri) { + public JdbcStatsMapping getMapping(String uri) { for (JdbcStatsMapping mapping : JdbcStatsMapping.values()) { if (uri.startsWith(mapping.getUri())) { return mapping; @@ -19,11 +16,12 @@ return null; } - public PageMapping getLoginPage() { + public JdbcStatsMapping getLoginPage() { return JdbcStatsMapping.LOGIN; } - public PageMapping get404Page() { + public JdbcStatsMapping get404Page() { return JdbcStatsMapping.NOTFOUND; } + } diff --git a/src/nl/astraeus/jdbc/web/NanoHttpdSimpleWeb.java b/src/nl/astraeus/jdbc/web/NanoHttpdSimpleWeb.java new file mode 100644 index 0000000..393445e --- /dev/null +++ b/src/nl/astraeus/jdbc/web/NanoHttpdSimpleWeb.java @@ -0,0 +1,56 @@ +package nl.astraeus.jdbc.web; + +import fi.iki.elonen.NanoHTTPD; + +public class NanoHttpdSimpleWeb extends NanoHTTPD { + private JdbcStatsMappingProvider mappingProvider; + + public NanoHttpdSimpleWeb(int port, JdbcStatsMappingProvider mappingProvider) { + super(port); + + this.mappingProvider = mappingProvider; + } + + @Override + public Response serve(IHTTPSession session) { + String uri = session.getUri(); + +/* try { + PageFinder finder = new PageFinder(uri, mappingProvider); + + Map files = new HashMap(); + session.parseBody(files); + + NanoHttpdRequestWrapper wrapper = new NanoHttpdRequestWrapper(getListeningPort(), session); + + RequestWrapperHolder.set(wrapper); + + Page page = finder.findPage(); + + ByteArrayOutputStream out = new ByteArrayOutputStream(); + + page.execute(session.getMethod(), out, mappingProvider.getLoginPage().getUri()); + + out.close(); + + byte[] buffer = out.toByteArray(); + + ByteArrayInputStream in = new ByteArrayInputStream(buffer); + // todo: mimetypes + Response response = new Response(wrapper.getStatus(), wrapper.getContentType(), in, -1); + for (Map.Entry entry : wrapper.getResponseHeaders().entrySet()) { + response.addHeader(entry.getKey(), entry.getValue()); + } + return response; + } catch (Exception e) { + logger.warn(e.getMessage(), e); + + throw new IllegalStateException(e); + } finally { + RequestWrapperHolder.remove(); + }*/ + + return newFixedLengthResponse("Ok"); + } + +} \ No newline at end of file diff --git a/src/nl/astraeus/jdbc/web/model/Settings.java b/src/nl/astraeus/jdbc/web/model/Settings.java index 043ca8a..7750833 100644 --- a/src/nl/astraeus/jdbc/web/model/Settings.java +++ b/src/nl/astraeus/jdbc/web/model/Settings.java @@ -1,16 +1,11 @@ package nl.astraeus.jdbc.web.model; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/22/12 * Time: 1:53 PM */ public class Settings { - private final static Logger logger = LoggerFactory.getLogger(Settings.class); - private final static String NUMBER_OF_QUERIES = "numberOfQueries"; private final static String LOG_STACKTRACES = "logStacktraces"; private final static String FORMATTED_QUERIES = "formattedQueries"; diff --git a/src/nl/astraeus/jdbc/web/page/FooterPage.java b/src/nl/astraeus/jdbc/web/page/FooterPage.java index fcf9931..c09b12c 100644 --- a/src/nl/astraeus/jdbc/web/page/FooterPage.java +++ b/src/nl/astraeus/jdbc/web/page/FooterPage.java @@ -1,7 +1,5 @@ package nl.astraeus.jdbc.web.page; -import nl.astraeus.web.page.TemplatePage; - /** * Date: 11/17/13 * Time: 2:31 PM diff --git a/src/nl/astraeus/jdbc/web/page/HeaderPage.java b/src/nl/astraeus/jdbc/web/page/HeaderPage.java index 2868ecc..0dceb73 100644 --- a/src/nl/astraeus/jdbc/web/page/HeaderPage.java +++ b/src/nl/astraeus/jdbc/web/page/HeaderPage.java @@ -1,7 +1,5 @@ package nl.astraeus.jdbc.web.page; -import nl.astraeus.web.page.TemplatePage; - /** * Date: 11/17/13 * Time: 2:31 PM diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 41cd493..f9ae410 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -17,7 +17,7 @@ - + diff --git a/.idea/libraries-with-intellij-classes.xml b/.idea/libraries-with-intellij-classes.xml new file mode 100644 index 0000000..9fa3156 --- /dev/null +++ b/.idea/libraries-with-intellij-classes.xml @@ -0,0 +1,65 @@ + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml new file mode 100644 index 0000000..c108f80 --- /dev/null +++ b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml b/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml deleted file mode 100644 index 9a00155..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml b/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml deleted file mode 100644 index 873c2c0..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml new file mode 100644 index 0000000..7d1fc19 --- /dev/null +++ b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index be926a3..6d93540 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,7 +8,7 @@ http://www.w3.org/1999/xhtml - + diff --git a/.idea/modules/simple-jdbc-stats.main.iml b/.idea/modules/simple-jdbc-stats.main.iml index 578407e..50faa2e 100644 --- a/.idea/modules/simple-jdbc-stats.main.iml +++ b/.idea/modules/simple-jdbc-stats.main.iml @@ -1,15 +1,15 @@ - + - - + + \ No newline at end of file diff --git a/.idea/modules/simple-jdbc-stats.test.iml b/.idea/modules/simple-jdbc-stats.test.iml index 62ffcca..f5baeeb 100644 --- a/.idea/modules/simple-jdbc-stats.test.iml +++ b/.idea/modules/simple-jdbc-stats.test.iml @@ -1,7 +1,7 @@ - + @@ -10,8 +10,8 @@ - - + + diff --git a/build.gradle b/build.gradle index 8791f4a..559db71 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,6 @@ apply plugin: 'java' apply plugin: 'idea' apply plugin: 'maven' -apply plugin: 'findbugs' apply plugin: 'maven-publish' sourceSets { @@ -15,8 +14,8 @@ test.resources.srcDirs += 'test' } -sourceCompatibility = 1.5 -targetCompatibility = 1.5 +sourceCompatibility = 1.6 +targetCompatibility = 1.6 repositories { maven { @@ -24,18 +23,23 @@ } } +ext { + PUBLISH_GROUP_ID = group + PUBLISH_VERSION = version + PUBLISH_ARTIFACT_ID = name +} + +apply from: "${rootProject.projectDir}/scripts/publish-mavencentral.gradle" + dependencies { testCompile group: 'junit', name: 'junit', version: '4.12' - testCompile "org.slf4j:slf4j-simple:1.7.21" testCompile "com.h2database:h2:1.4.+" - compile "nl.astraeus.template:very-simple-templates:1.3" - compile "nl.astraeus.web:simple-web:0.3" - compile "org.slf4j:slf4j-api:1.7.21" + compile "com.samskivert:jmustache:1.15" + compile "org.nanohttpd:nanohttpd:2.2.0" configurations.compile.exclude module: 'javax.servlet-api' - configurations.compile.exclude module: 'slf4j-simple' } uploadArchives { @@ -51,10 +55,6 @@ } } -findbugs { - ignoreFailures = true -} - javadoc { failOnError = false } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 088b40b..bd4ca84 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip diff --git a/scripts/publish-mavencentral.gradle b/scripts/publish-mavencentral.gradle new file mode 100644 index 0000000..fae9b85 --- /dev/null +++ b/scripts/publish-mavencentral.gradle @@ -0,0 +1,121 @@ + +apply plugin: 'maven-publish' +apply plugin: 'signing' + +task publishSourcesJar(type: Jar) { + archiveClassifier.set('sources') + + // For pure Kotlin libraries, in case you have them + from sourceSets.main.java.srcDirs + //from sourceSets.main.kotlin.srcDirs +} + +task packageJavadoc(type: Jar) { + from javadoc + classifier = 'javadoc' +} + +artifacts { + archives publishSourcesJar +} + +File secretPropsFile = project.rootProject.file('local.properties') + +ext["signing.keyId"] = '' +ext["signing.password"] = '' +ext["signing.secretKeyRingFile"] = '' +ext["ossrhUsername"] = '' +ext["ossrhPassword"] = '' +ext["sonatypeStagingProfileId"] = '' + +if (secretPropsFile.exists()) { + Properties p = new Properties() + + new FileInputStream(secretPropsFile).withCloseable { is -> + p.load(is) + } + + p.each { name, value -> + ext[name] = value + } +} + +afterEvaluate { + publishing { + publications { + relase(MavenPublication) { + // The coordinates of the library, being set from variables that + // we'll set up later + groupId PUBLISH_GROUP_ID + artifactId PUBLISH_ARTIFACT_ID + version PUBLISH_VERSION + + // Two artifacts, the `aar` (or `jar`) and the sources + if (project.plugins.findPlugin("com.android.library")) { + artifact("$buildDir/outputs/aar/${project.getName()}-release.aar") + } else { + artifact("$buildDir/libs/${project.getName()}-${version}.jar") + } + artifact publishSourcesJar + artifact packageJavadoc + + // Mostly self-explanatory metadata + pom { + name = PUBLISH_ARTIFACT_ID + description = 'Simple JDBC wrapper for query statistics' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics' + licenses { + license { + name = 'MIT License' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics/blob/master/LICENCE.txt' + } + } + developers { + developer { + id = 'rnentjes' + name = 'Rien Nentjes' + email = 'info@nentjes.com' + } + // Add all other devs here... + } + // Version control info - if you're using GitHub, follow the format as seen here + scm { + connection = 'scm:git:github.com/rnentjes/Simple-jdbc-statistics.git' + developerConnection = 'scm:git:ssh://github.com/rnentjes/Simple-jdbc-statistics.git' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics.git/tree/main' + } + // A slightly hacky fix so that your POM will include any transitive dependencies + // that your library builds upon + /* + witXml { + def dependenciesNode = asNode().appendNode('dependencies') + + project.configurations.implementation.allDependencies.each { + def dependencyNode = dependenciesNode.appendNode('dependency') + dependencyNode.appendNode('groupId', it.group) + dependencyNode.appendNode('artifactId', it.name) + dependencyNode.appendNode('version', it.version) + } + }*/ + } + } + } + // The repository to publish to, Sonatype/MavenCentral + repositories { + maven { + // This is an arbitrary name, you may also use "mavencentral" or + // any other name that's descriptive for you + name = "sonatype" + url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" + credentials { + username ossrhUsername + password ossrhPassword + } + } + } + } +} + +signing { + sign publishing.publications +} diff --git a/src/nl/astraeus/jdbc/CallableStatementLogger.java b/src/nl/astraeus/jdbc/CallableStatementLogger.java index 2e9f173..39be81c 100644 --- a/src/nl/astraeus/jdbc/CallableStatementLogger.java +++ b/src/nl/astraeus/jdbc/CallableStatementLogger.java @@ -1,8 +1,5 @@ package nl.astraeus.jdbc; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; @@ -17,8 +14,6 @@ * Time: 9:48 PM */ public class CallableStatementLogger implements CallableStatement { - private final static Logger log = LoggerFactory.getLogger(PreparedStatementLogger.class); - private JdbcLogger logger; private CallableStatement statement; diff --git a/src/nl/astraeus/jdbc/Driver.java b/src/nl/astraeus/jdbc/Driver.java index 046d756..e230a06 100644 --- a/src/nl/astraeus/jdbc/Driver.java +++ b/src/nl/astraeus/jdbc/Driver.java @@ -11,44 +11,38 @@ import java.util.concurrent.ConcurrentHashMap; import nl.astraeus.jdbc.web.JdbcStatsMappingProvider; +import nl.astraeus.jdbc.web.NanoHttpdSimpleWeb; import nl.astraeus.jdbc.web.model.Settings; -import nl.astraeus.web.NanoHttpdSimpleWeb; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * User: riennentjes * Date: Jul 10, 2008 * Time: 8:54:37 PM - * + *

* Test a little change - * */ public class Driver implements java.sql.Driver { - private final static Logger log = LoggerFactory.getLogger(Driver.class); - - final private static String URL_PREFIX = "jdbc:stat:"; - final private static String URL_SECURE_PREFIX = "jdbc:secstat:"; + final private static String URL_PREFIX = "jdbc:stat:"; + final private static String URL_SECURE_PREFIX = "jdbc:secstat:"; public static class StatsLogger { - private volatile boolean started = false; - private NanoHttpdSimpleWeb server = null; - private java.sql.Driver driver = null; - private Settings settings = new Settings(); - private String targetUrl = null; + private volatile boolean started = false; + private NanoHttpdSimpleWeb server = null; + private java.sql.Driver driver = null; + private Settings settings = new Settings(); + private String targetUrl = null; public Settings getSettings() { return settings; } } - private static Map loggers = new ConcurrentHashMap(); - private static Map portMapping = new ConcurrentHashMap(); + private static Map loggers = new ConcurrentHashMap(); + private static Map portMapping = new ConcurrentHashMap(); public static StatsLogger get(String url) { if (!loggers.containsKey(url)) { - throw new IllegalArgumentException("No jdbc statistics logger found for url: "+url); + throw new IllegalArgumentException("No jdbc statistics logger found for url: " + url); } return loggers.get(url); @@ -56,7 +50,7 @@ public static StatsLogger get(int port) { if (!portMapping.containsKey(port)) { - throw new IllegalArgumentException("No jdbc statistics logger found on port: "+port); + throw new IllegalArgumentException("No jdbc statistics logger found on port: " + port); } return portMapping.get(port); @@ -75,7 +69,8 @@ "org.apache.derby.jdbc.EmbeddedDriver", "com.mysql.jdbc.Driver", "org.hsqldb.jdbcDriver", - "org.h2.Driver" }; + "org.h2.Driver" + }; static { log.debug("Loading driver class " + Driver.class.getName()); @@ -123,8 +118,8 @@ logger.settings.setSecure(true); } - String [] parts = url.split("\\:"); - String settingsString = "webServerConnections=5;numberOfQueries=2500;logStacktraces=true;formattedQueries=true"; + String[] parts = url.split("\\:"); + String settingsString = "webServerConnections=5;numberOfQueries=2500;logStacktraces=true;formattedQueries=true"; if (parts.length > 3) { settingsString = parts[2]; @@ -146,7 +141,7 @@ } if (logger.settings.isSecure()) { - String user = info.getProperty("user"); + String user = info.getProperty("user"); String password = info.getProperty("password"); if (user == null || password == null) { @@ -161,15 +156,21 @@ synchronized (this) { if (!logger.started) { try { - NanoHttpdSimpleWeb server = new NanoHttpdSimpleWeb(logger.settings.getWebServerPort(), new JdbcStatsMappingProvider()); + NanoHttpdSimpleWeb server = new NanoHttpdSimpleWeb( + logger.settings.getWebServerPort(), + new JdbcStatsMappingProvider() + ); server.start(); - System.out.println("Started Simple JDBC Statistics\n\turl: "+url+"\n\tport: "+logger.settings.getWebServerPort()); + System.out.println("Started Simple JDBC Statistics\n\turl: " + + url + + "\n\tport: " + + logger.settings.getWebServerPort()); logger.started = true; } catch (Exception e) { - log.error(e.getMessage(),e); + log.error(e.getMessage(), e); } } } diff --git a/src/nl/astraeus/jdbc/JdbcLogger.java b/src/nl/astraeus/jdbc/JdbcLogger.java index 44d09e6..ac7188a 100644 --- a/src/nl/astraeus/jdbc/JdbcLogger.java +++ b/src/nl/astraeus/jdbc/JdbcLogger.java @@ -1,15 +1,10 @@ package nl.astraeus.jdbc; import nl.astraeus.jdbc.util.Util; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import java.util.HashMap; -import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; @@ -19,8 +14,6 @@ * Time: 9:15:21 AM */ public class JdbcLogger { - private final static Logger logger = LoggerFactory.getLogger(JdbcLogger.class); - private final static Map instances = new ConcurrentHashMap(); public static JdbcLogger get(int port) { diff --git a/src/nl/astraeus/jdbc/PreparedStatementLogger.java b/src/nl/astraeus/jdbc/PreparedStatementLogger.java index f97959a..648fea0 100644 --- a/src/nl/astraeus/jdbc/PreparedStatementLogger.java +++ b/src/nl/astraeus/jdbc/PreparedStatementLogger.java @@ -1,8 +1,5 @@ package nl.astraeus.jdbc; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; @@ -25,12 +22,8 @@ import java.sql.Time; import java.sql.Timestamp; import java.util.Calendar; -import java.util.Comparator; -import java.util.HashSet; import java.util.Map; -import java.util.Set; import java.util.TreeMap; -import java.util.TreeSet; /** * User: riennentjes @@ -38,8 +31,6 @@ * Time: 7:47:57 PM */ public class PreparedStatementLogger implements PreparedStatement { - private final static Logger log = LoggerFactory.getLogger(PreparedStatementLogger.class); - private JdbcLogger logger; private PreparedStatement statement; diff --git a/src/nl/astraeus/jdbc/SqlFormatter.java b/src/nl/astraeus/jdbc/SqlFormatter.java index e28810b..8129dfc 100644 --- a/src/nl/astraeus/jdbc/SqlFormatter.java +++ b/src/nl/astraeus/jdbc/SqlFormatter.java @@ -4,17 +4,12 @@ import java.util.List; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/18/12 * Time: 10:10 PM */ public class SqlFormatter { - private final static Logger logger = LoggerFactory.getLogger(SqlFormatter.class); - private static SqlTokenizer tokenizer = new SqlTokenizer(); private static enum Newline { diff --git a/src/nl/astraeus/jdbc/thread/JvmSampler.java b/src/nl/astraeus/jdbc/thread/JvmSampler.java index f1b98d6..155c4ee 100644 --- a/src/nl/astraeus/jdbc/thread/JvmSampler.java +++ b/src/nl/astraeus/jdbc/thread/JvmSampler.java @@ -5,17 +5,12 @@ import java.util.Set; import java.util.TreeSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/22/13 * Time: 8:52 PM */ public class JvmSampler extends Thread { - private final static Logger logger = LoggerFactory.getLogger(JvmSampler.class); - private boolean stopped; private boolean running; diff --git a/src/nl/astraeus/jdbc/util/ReflectHelper.java b/src/nl/astraeus/jdbc/util/ReflectHelper.java index eac090f..7582e04 100644 --- a/src/nl/astraeus/jdbc/util/ReflectHelper.java +++ b/src/nl/astraeus/jdbc/util/ReflectHelper.java @@ -9,17 +9,12 @@ import java.util.List; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 10/16/13 * Time: 4:49 PM */ public class ReflectHelper { - private final static Logger logger = LoggerFactory.getLogger(ReflectHelper.class); - private final static ReflectHelper instance = new ReflectHelper(); public static ReflectHelper get() { diff --git a/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java b/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java index 555b1d3..a70febc 100644 --- a/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java +++ b/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java @@ -9,14 +9,12 @@ import nl.astraeus.jdbc.web.page.ShowStacktrace; import nl.astraeus.jdbc.web.page.TransactionDetail; import nl.astraeus.jdbc.web.page.TransactionOverview; -import nl.astraeus.web.page.Page; -import nl.astraeus.web.page.PageMapping; /** * Date: 11/24/13 * Time: 10:27 AM */ -public enum JdbcStatsMapping implements PageMapping { +public enum JdbcStatsMapping { QUERIES("queries", QueryOverview.class), QUERY("query", QueryDetail.class), @@ -36,8 +34,8 @@ MAIN("", QueryOverview.class), ; - private String uri; - private Class cls; + private final String uri; + private final Class cls; private JdbcStatsMapping(String uri, Class cls) { this.uri = uri; @@ -48,8 +46,8 @@ return uri; } - public Class getPage() { - return (Class) cls; + public Class getPage() { + return cls; } } diff --git a/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java b/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java index b05e76a..36b1819 100644 --- a/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java +++ b/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java @@ -1,15 +1,12 @@ package nl.astraeus.jdbc.web; -import nl.astraeus.web.page.MappingProvider; -import nl.astraeus.web.page.PageMapping; - /** * Date: 11/24/13 * Time: 10:24 AM */ -public class JdbcStatsMappingProvider implements MappingProvider { +public class JdbcStatsMappingProvider { - public PageMapping getMapping(String uri) { + public JdbcStatsMapping getMapping(String uri) { for (JdbcStatsMapping mapping : JdbcStatsMapping.values()) { if (uri.startsWith(mapping.getUri())) { return mapping; @@ -19,11 +16,12 @@ return null; } - public PageMapping getLoginPage() { + public JdbcStatsMapping getLoginPage() { return JdbcStatsMapping.LOGIN; } - public PageMapping get404Page() { + public JdbcStatsMapping get404Page() { return JdbcStatsMapping.NOTFOUND; } + } diff --git a/src/nl/astraeus/jdbc/web/NanoHttpdSimpleWeb.java b/src/nl/astraeus/jdbc/web/NanoHttpdSimpleWeb.java new file mode 100644 index 0000000..393445e --- /dev/null +++ b/src/nl/astraeus/jdbc/web/NanoHttpdSimpleWeb.java @@ -0,0 +1,56 @@ +package nl.astraeus.jdbc.web; + +import fi.iki.elonen.NanoHTTPD; + +public class NanoHttpdSimpleWeb extends NanoHTTPD { + private JdbcStatsMappingProvider mappingProvider; + + public NanoHttpdSimpleWeb(int port, JdbcStatsMappingProvider mappingProvider) { + super(port); + + this.mappingProvider = mappingProvider; + } + + @Override + public Response serve(IHTTPSession session) { + String uri = session.getUri(); + +/* try { + PageFinder finder = new PageFinder(uri, mappingProvider); + + Map files = new HashMap(); + session.parseBody(files); + + NanoHttpdRequestWrapper wrapper = new NanoHttpdRequestWrapper(getListeningPort(), session); + + RequestWrapperHolder.set(wrapper); + + Page page = finder.findPage(); + + ByteArrayOutputStream out = new ByteArrayOutputStream(); + + page.execute(session.getMethod(), out, mappingProvider.getLoginPage().getUri()); + + out.close(); + + byte[] buffer = out.toByteArray(); + + ByteArrayInputStream in = new ByteArrayInputStream(buffer); + // todo: mimetypes + Response response = new Response(wrapper.getStatus(), wrapper.getContentType(), in, -1); + for (Map.Entry entry : wrapper.getResponseHeaders().entrySet()) { + response.addHeader(entry.getKey(), entry.getValue()); + } + return response; + } catch (Exception e) { + logger.warn(e.getMessage(), e); + + throw new IllegalStateException(e); + } finally { + RequestWrapperHolder.remove(); + }*/ + + return newFixedLengthResponse("Ok"); + } + +} \ No newline at end of file diff --git a/src/nl/astraeus/jdbc/web/model/Settings.java b/src/nl/astraeus/jdbc/web/model/Settings.java index 043ca8a..7750833 100644 --- a/src/nl/astraeus/jdbc/web/model/Settings.java +++ b/src/nl/astraeus/jdbc/web/model/Settings.java @@ -1,16 +1,11 @@ package nl.astraeus.jdbc.web.model; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/22/12 * Time: 1:53 PM */ public class Settings { - private final static Logger logger = LoggerFactory.getLogger(Settings.class); - private final static String NUMBER_OF_QUERIES = "numberOfQueries"; private final static String LOG_STACKTRACES = "logStacktraces"; private final static String FORMATTED_QUERIES = "formattedQueries"; diff --git a/src/nl/astraeus/jdbc/web/page/FooterPage.java b/src/nl/astraeus/jdbc/web/page/FooterPage.java index fcf9931..c09b12c 100644 --- a/src/nl/astraeus/jdbc/web/page/FooterPage.java +++ b/src/nl/astraeus/jdbc/web/page/FooterPage.java @@ -1,7 +1,5 @@ package nl.astraeus.jdbc.web.page; -import nl.astraeus.web.page.TemplatePage; - /** * Date: 11/17/13 * Time: 2:31 PM diff --git a/src/nl/astraeus/jdbc/web/page/HeaderPage.java b/src/nl/astraeus/jdbc/web/page/HeaderPage.java index 2868ecc..0dceb73 100644 --- a/src/nl/astraeus/jdbc/web/page/HeaderPage.java +++ b/src/nl/astraeus/jdbc/web/page/HeaderPage.java @@ -1,7 +1,5 @@ package nl.astraeus.jdbc.web.page; -import nl.astraeus.web.page.TemplatePage; - /** * Date: 11/17/13 * Time: 2:31 PM diff --git a/src/nl/astraeus/jdbc/web/page/JvmStats.html b/src/nl/astraeus/jdbc/web/page/JvmStats.html index d38f031..98537e0 100644 --- a/src/nl/astraeus/jdbc/web/page/JvmStats.html +++ b/src/nl/astraeus/jdbc/web/page/JvmStats.html @@ -52,8 +52,6 @@ ${sample.location} ${sample.count} ${/if} - - ${/each} diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 41cd493..f9ae410 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -17,7 +17,7 @@ - + diff --git a/.idea/libraries-with-intellij-classes.xml b/.idea/libraries-with-intellij-classes.xml new file mode 100644 index 0000000..9fa3156 --- /dev/null +++ b/.idea/libraries-with-intellij-classes.xml @@ -0,0 +1,65 @@ + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml new file mode 100644 index 0000000..c108f80 --- /dev/null +++ b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml b/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml deleted file mode 100644 index 9a00155..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml b/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml deleted file mode 100644 index 873c2c0..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml new file mode 100644 index 0000000..7d1fc19 --- /dev/null +++ b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index be926a3..6d93540 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,7 +8,7 @@ http://www.w3.org/1999/xhtml - + diff --git a/.idea/modules/simple-jdbc-stats.main.iml b/.idea/modules/simple-jdbc-stats.main.iml index 578407e..50faa2e 100644 --- a/.idea/modules/simple-jdbc-stats.main.iml +++ b/.idea/modules/simple-jdbc-stats.main.iml @@ -1,15 +1,15 @@ - + - - + + \ No newline at end of file diff --git a/.idea/modules/simple-jdbc-stats.test.iml b/.idea/modules/simple-jdbc-stats.test.iml index 62ffcca..f5baeeb 100644 --- a/.idea/modules/simple-jdbc-stats.test.iml +++ b/.idea/modules/simple-jdbc-stats.test.iml @@ -1,7 +1,7 @@ - + @@ -10,8 +10,8 @@ - - + + diff --git a/build.gradle b/build.gradle index 8791f4a..559db71 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,6 @@ apply plugin: 'java' apply plugin: 'idea' apply plugin: 'maven' -apply plugin: 'findbugs' apply plugin: 'maven-publish' sourceSets { @@ -15,8 +14,8 @@ test.resources.srcDirs += 'test' } -sourceCompatibility = 1.5 -targetCompatibility = 1.5 +sourceCompatibility = 1.6 +targetCompatibility = 1.6 repositories { maven { @@ -24,18 +23,23 @@ } } +ext { + PUBLISH_GROUP_ID = group + PUBLISH_VERSION = version + PUBLISH_ARTIFACT_ID = name +} + +apply from: "${rootProject.projectDir}/scripts/publish-mavencentral.gradle" + dependencies { testCompile group: 'junit', name: 'junit', version: '4.12' - testCompile "org.slf4j:slf4j-simple:1.7.21" testCompile "com.h2database:h2:1.4.+" - compile "nl.astraeus.template:very-simple-templates:1.3" - compile "nl.astraeus.web:simple-web:0.3" - compile "org.slf4j:slf4j-api:1.7.21" + compile "com.samskivert:jmustache:1.15" + compile "org.nanohttpd:nanohttpd:2.2.0" configurations.compile.exclude module: 'javax.servlet-api' - configurations.compile.exclude module: 'slf4j-simple' } uploadArchives { @@ -51,10 +55,6 @@ } } -findbugs { - ignoreFailures = true -} - javadoc { failOnError = false } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 088b40b..bd4ca84 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip diff --git a/scripts/publish-mavencentral.gradle b/scripts/publish-mavencentral.gradle new file mode 100644 index 0000000..fae9b85 --- /dev/null +++ b/scripts/publish-mavencentral.gradle @@ -0,0 +1,121 @@ + +apply plugin: 'maven-publish' +apply plugin: 'signing' + +task publishSourcesJar(type: Jar) { + archiveClassifier.set('sources') + + // For pure Kotlin libraries, in case you have them + from sourceSets.main.java.srcDirs + //from sourceSets.main.kotlin.srcDirs +} + +task packageJavadoc(type: Jar) { + from javadoc + classifier = 'javadoc' +} + +artifacts { + archives publishSourcesJar +} + +File secretPropsFile = project.rootProject.file('local.properties') + +ext["signing.keyId"] = '' +ext["signing.password"] = '' +ext["signing.secretKeyRingFile"] = '' +ext["ossrhUsername"] = '' +ext["ossrhPassword"] = '' +ext["sonatypeStagingProfileId"] = '' + +if (secretPropsFile.exists()) { + Properties p = new Properties() + + new FileInputStream(secretPropsFile).withCloseable { is -> + p.load(is) + } + + p.each { name, value -> + ext[name] = value + } +} + +afterEvaluate { + publishing { + publications { + relase(MavenPublication) { + // The coordinates of the library, being set from variables that + // we'll set up later + groupId PUBLISH_GROUP_ID + artifactId PUBLISH_ARTIFACT_ID + version PUBLISH_VERSION + + // Two artifacts, the `aar` (or `jar`) and the sources + if (project.plugins.findPlugin("com.android.library")) { + artifact("$buildDir/outputs/aar/${project.getName()}-release.aar") + } else { + artifact("$buildDir/libs/${project.getName()}-${version}.jar") + } + artifact publishSourcesJar + artifact packageJavadoc + + // Mostly self-explanatory metadata + pom { + name = PUBLISH_ARTIFACT_ID + description = 'Simple JDBC wrapper for query statistics' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics' + licenses { + license { + name = 'MIT License' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics/blob/master/LICENCE.txt' + } + } + developers { + developer { + id = 'rnentjes' + name = 'Rien Nentjes' + email = 'info@nentjes.com' + } + // Add all other devs here... + } + // Version control info - if you're using GitHub, follow the format as seen here + scm { + connection = 'scm:git:github.com/rnentjes/Simple-jdbc-statistics.git' + developerConnection = 'scm:git:ssh://github.com/rnentjes/Simple-jdbc-statistics.git' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics.git/tree/main' + } + // A slightly hacky fix so that your POM will include any transitive dependencies + // that your library builds upon + /* + witXml { + def dependenciesNode = asNode().appendNode('dependencies') + + project.configurations.implementation.allDependencies.each { + def dependencyNode = dependenciesNode.appendNode('dependency') + dependencyNode.appendNode('groupId', it.group) + dependencyNode.appendNode('artifactId', it.name) + dependencyNode.appendNode('version', it.version) + } + }*/ + } + } + } + // The repository to publish to, Sonatype/MavenCentral + repositories { + maven { + // This is an arbitrary name, you may also use "mavencentral" or + // any other name that's descriptive for you + name = "sonatype" + url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" + credentials { + username ossrhUsername + password ossrhPassword + } + } + } + } +} + +signing { + sign publishing.publications +} diff --git a/src/nl/astraeus/jdbc/CallableStatementLogger.java b/src/nl/astraeus/jdbc/CallableStatementLogger.java index 2e9f173..39be81c 100644 --- a/src/nl/astraeus/jdbc/CallableStatementLogger.java +++ b/src/nl/astraeus/jdbc/CallableStatementLogger.java @@ -1,8 +1,5 @@ package nl.astraeus.jdbc; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; @@ -17,8 +14,6 @@ * Time: 9:48 PM */ public class CallableStatementLogger implements CallableStatement { - private final static Logger log = LoggerFactory.getLogger(PreparedStatementLogger.class); - private JdbcLogger logger; private CallableStatement statement; diff --git a/src/nl/astraeus/jdbc/Driver.java b/src/nl/astraeus/jdbc/Driver.java index 046d756..e230a06 100644 --- a/src/nl/astraeus/jdbc/Driver.java +++ b/src/nl/astraeus/jdbc/Driver.java @@ -11,44 +11,38 @@ import java.util.concurrent.ConcurrentHashMap; import nl.astraeus.jdbc.web.JdbcStatsMappingProvider; +import nl.astraeus.jdbc.web.NanoHttpdSimpleWeb; import nl.astraeus.jdbc.web.model.Settings; -import nl.astraeus.web.NanoHttpdSimpleWeb; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * User: riennentjes * Date: Jul 10, 2008 * Time: 8:54:37 PM - * + *

* Test a little change - * */ public class Driver implements java.sql.Driver { - private final static Logger log = LoggerFactory.getLogger(Driver.class); - - final private static String URL_PREFIX = "jdbc:stat:"; - final private static String URL_SECURE_PREFIX = "jdbc:secstat:"; + final private static String URL_PREFIX = "jdbc:stat:"; + final private static String URL_SECURE_PREFIX = "jdbc:secstat:"; public static class StatsLogger { - private volatile boolean started = false; - private NanoHttpdSimpleWeb server = null; - private java.sql.Driver driver = null; - private Settings settings = new Settings(); - private String targetUrl = null; + private volatile boolean started = false; + private NanoHttpdSimpleWeb server = null; + private java.sql.Driver driver = null; + private Settings settings = new Settings(); + private String targetUrl = null; public Settings getSettings() { return settings; } } - private static Map loggers = new ConcurrentHashMap(); - private static Map portMapping = new ConcurrentHashMap(); + private static Map loggers = new ConcurrentHashMap(); + private static Map portMapping = new ConcurrentHashMap(); public static StatsLogger get(String url) { if (!loggers.containsKey(url)) { - throw new IllegalArgumentException("No jdbc statistics logger found for url: "+url); + throw new IllegalArgumentException("No jdbc statistics logger found for url: " + url); } return loggers.get(url); @@ -56,7 +50,7 @@ public static StatsLogger get(int port) { if (!portMapping.containsKey(port)) { - throw new IllegalArgumentException("No jdbc statistics logger found on port: "+port); + throw new IllegalArgumentException("No jdbc statistics logger found on port: " + port); } return portMapping.get(port); @@ -75,7 +69,8 @@ "org.apache.derby.jdbc.EmbeddedDriver", "com.mysql.jdbc.Driver", "org.hsqldb.jdbcDriver", - "org.h2.Driver" }; + "org.h2.Driver" + }; static { log.debug("Loading driver class " + Driver.class.getName()); @@ -123,8 +118,8 @@ logger.settings.setSecure(true); } - String [] parts = url.split("\\:"); - String settingsString = "webServerConnections=5;numberOfQueries=2500;logStacktraces=true;formattedQueries=true"; + String[] parts = url.split("\\:"); + String settingsString = "webServerConnections=5;numberOfQueries=2500;logStacktraces=true;formattedQueries=true"; if (parts.length > 3) { settingsString = parts[2]; @@ -146,7 +141,7 @@ } if (logger.settings.isSecure()) { - String user = info.getProperty("user"); + String user = info.getProperty("user"); String password = info.getProperty("password"); if (user == null || password == null) { @@ -161,15 +156,21 @@ synchronized (this) { if (!logger.started) { try { - NanoHttpdSimpleWeb server = new NanoHttpdSimpleWeb(logger.settings.getWebServerPort(), new JdbcStatsMappingProvider()); + NanoHttpdSimpleWeb server = new NanoHttpdSimpleWeb( + logger.settings.getWebServerPort(), + new JdbcStatsMappingProvider() + ); server.start(); - System.out.println("Started Simple JDBC Statistics\n\turl: "+url+"\n\tport: "+logger.settings.getWebServerPort()); + System.out.println("Started Simple JDBC Statistics\n\turl: " + + url + + "\n\tport: " + + logger.settings.getWebServerPort()); logger.started = true; } catch (Exception e) { - log.error(e.getMessage(),e); + log.error(e.getMessage(), e); } } } diff --git a/src/nl/astraeus/jdbc/JdbcLogger.java b/src/nl/astraeus/jdbc/JdbcLogger.java index 44d09e6..ac7188a 100644 --- a/src/nl/astraeus/jdbc/JdbcLogger.java +++ b/src/nl/astraeus/jdbc/JdbcLogger.java @@ -1,15 +1,10 @@ package nl.astraeus.jdbc; import nl.astraeus.jdbc.util.Util; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import java.util.HashMap; -import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; @@ -19,8 +14,6 @@ * Time: 9:15:21 AM */ public class JdbcLogger { - private final static Logger logger = LoggerFactory.getLogger(JdbcLogger.class); - private final static Map instances = new ConcurrentHashMap(); public static JdbcLogger get(int port) { diff --git a/src/nl/astraeus/jdbc/PreparedStatementLogger.java b/src/nl/astraeus/jdbc/PreparedStatementLogger.java index f97959a..648fea0 100644 --- a/src/nl/astraeus/jdbc/PreparedStatementLogger.java +++ b/src/nl/astraeus/jdbc/PreparedStatementLogger.java @@ -1,8 +1,5 @@ package nl.astraeus.jdbc; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; @@ -25,12 +22,8 @@ import java.sql.Time; import java.sql.Timestamp; import java.util.Calendar; -import java.util.Comparator; -import java.util.HashSet; import java.util.Map; -import java.util.Set; import java.util.TreeMap; -import java.util.TreeSet; /** * User: riennentjes @@ -38,8 +31,6 @@ * Time: 7:47:57 PM */ public class PreparedStatementLogger implements PreparedStatement { - private final static Logger log = LoggerFactory.getLogger(PreparedStatementLogger.class); - private JdbcLogger logger; private PreparedStatement statement; diff --git a/src/nl/astraeus/jdbc/SqlFormatter.java b/src/nl/astraeus/jdbc/SqlFormatter.java index e28810b..8129dfc 100644 --- a/src/nl/astraeus/jdbc/SqlFormatter.java +++ b/src/nl/astraeus/jdbc/SqlFormatter.java @@ -4,17 +4,12 @@ import java.util.List; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/18/12 * Time: 10:10 PM */ public class SqlFormatter { - private final static Logger logger = LoggerFactory.getLogger(SqlFormatter.class); - private static SqlTokenizer tokenizer = new SqlTokenizer(); private static enum Newline { diff --git a/src/nl/astraeus/jdbc/thread/JvmSampler.java b/src/nl/astraeus/jdbc/thread/JvmSampler.java index f1b98d6..155c4ee 100644 --- a/src/nl/astraeus/jdbc/thread/JvmSampler.java +++ b/src/nl/astraeus/jdbc/thread/JvmSampler.java @@ -5,17 +5,12 @@ import java.util.Set; import java.util.TreeSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/22/13 * Time: 8:52 PM */ public class JvmSampler extends Thread { - private final static Logger logger = LoggerFactory.getLogger(JvmSampler.class); - private boolean stopped; private boolean running; diff --git a/src/nl/astraeus/jdbc/util/ReflectHelper.java b/src/nl/astraeus/jdbc/util/ReflectHelper.java index eac090f..7582e04 100644 --- a/src/nl/astraeus/jdbc/util/ReflectHelper.java +++ b/src/nl/astraeus/jdbc/util/ReflectHelper.java @@ -9,17 +9,12 @@ import java.util.List; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 10/16/13 * Time: 4:49 PM */ public class ReflectHelper { - private final static Logger logger = LoggerFactory.getLogger(ReflectHelper.class); - private final static ReflectHelper instance = new ReflectHelper(); public static ReflectHelper get() { diff --git a/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java b/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java index 555b1d3..a70febc 100644 --- a/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java +++ b/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java @@ -9,14 +9,12 @@ import nl.astraeus.jdbc.web.page.ShowStacktrace; import nl.astraeus.jdbc.web.page.TransactionDetail; import nl.astraeus.jdbc.web.page.TransactionOverview; -import nl.astraeus.web.page.Page; -import nl.astraeus.web.page.PageMapping; /** * Date: 11/24/13 * Time: 10:27 AM */ -public enum JdbcStatsMapping implements PageMapping { +public enum JdbcStatsMapping { QUERIES("queries", QueryOverview.class), QUERY("query", QueryDetail.class), @@ -36,8 +34,8 @@ MAIN("", QueryOverview.class), ; - private String uri; - private Class cls; + private final String uri; + private final Class cls; private JdbcStatsMapping(String uri, Class cls) { this.uri = uri; @@ -48,8 +46,8 @@ return uri; } - public Class getPage() { - return (Class) cls; + public Class getPage() { + return cls; } } diff --git a/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java b/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java index b05e76a..36b1819 100644 --- a/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java +++ b/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java @@ -1,15 +1,12 @@ package nl.astraeus.jdbc.web; -import nl.astraeus.web.page.MappingProvider; -import nl.astraeus.web.page.PageMapping; - /** * Date: 11/24/13 * Time: 10:24 AM */ -public class JdbcStatsMappingProvider implements MappingProvider { +public class JdbcStatsMappingProvider { - public PageMapping getMapping(String uri) { + public JdbcStatsMapping getMapping(String uri) { for (JdbcStatsMapping mapping : JdbcStatsMapping.values()) { if (uri.startsWith(mapping.getUri())) { return mapping; @@ -19,11 +16,12 @@ return null; } - public PageMapping getLoginPage() { + public JdbcStatsMapping getLoginPage() { return JdbcStatsMapping.LOGIN; } - public PageMapping get404Page() { + public JdbcStatsMapping get404Page() { return JdbcStatsMapping.NOTFOUND; } + } diff --git a/src/nl/astraeus/jdbc/web/NanoHttpdSimpleWeb.java b/src/nl/astraeus/jdbc/web/NanoHttpdSimpleWeb.java new file mode 100644 index 0000000..393445e --- /dev/null +++ b/src/nl/astraeus/jdbc/web/NanoHttpdSimpleWeb.java @@ -0,0 +1,56 @@ +package nl.astraeus.jdbc.web; + +import fi.iki.elonen.NanoHTTPD; + +public class NanoHttpdSimpleWeb extends NanoHTTPD { + private JdbcStatsMappingProvider mappingProvider; + + public NanoHttpdSimpleWeb(int port, JdbcStatsMappingProvider mappingProvider) { + super(port); + + this.mappingProvider = mappingProvider; + } + + @Override + public Response serve(IHTTPSession session) { + String uri = session.getUri(); + +/* try { + PageFinder finder = new PageFinder(uri, mappingProvider); + + Map files = new HashMap(); + session.parseBody(files); + + NanoHttpdRequestWrapper wrapper = new NanoHttpdRequestWrapper(getListeningPort(), session); + + RequestWrapperHolder.set(wrapper); + + Page page = finder.findPage(); + + ByteArrayOutputStream out = new ByteArrayOutputStream(); + + page.execute(session.getMethod(), out, mappingProvider.getLoginPage().getUri()); + + out.close(); + + byte[] buffer = out.toByteArray(); + + ByteArrayInputStream in = new ByteArrayInputStream(buffer); + // todo: mimetypes + Response response = new Response(wrapper.getStatus(), wrapper.getContentType(), in, -1); + for (Map.Entry entry : wrapper.getResponseHeaders().entrySet()) { + response.addHeader(entry.getKey(), entry.getValue()); + } + return response; + } catch (Exception e) { + logger.warn(e.getMessage(), e); + + throw new IllegalStateException(e); + } finally { + RequestWrapperHolder.remove(); + }*/ + + return newFixedLengthResponse("Ok"); + } + +} \ No newline at end of file diff --git a/src/nl/astraeus/jdbc/web/model/Settings.java b/src/nl/astraeus/jdbc/web/model/Settings.java index 043ca8a..7750833 100644 --- a/src/nl/astraeus/jdbc/web/model/Settings.java +++ b/src/nl/astraeus/jdbc/web/model/Settings.java @@ -1,16 +1,11 @@ package nl.astraeus.jdbc.web.model; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/22/12 * Time: 1:53 PM */ public class Settings { - private final static Logger logger = LoggerFactory.getLogger(Settings.class); - private final static String NUMBER_OF_QUERIES = "numberOfQueries"; private final static String LOG_STACKTRACES = "logStacktraces"; private final static String FORMATTED_QUERIES = "formattedQueries"; diff --git a/src/nl/astraeus/jdbc/web/page/FooterPage.java b/src/nl/astraeus/jdbc/web/page/FooterPage.java index fcf9931..c09b12c 100644 --- a/src/nl/astraeus/jdbc/web/page/FooterPage.java +++ b/src/nl/astraeus/jdbc/web/page/FooterPage.java @@ -1,7 +1,5 @@ package nl.astraeus.jdbc.web.page; -import nl.astraeus.web.page.TemplatePage; - /** * Date: 11/17/13 * Time: 2:31 PM diff --git a/src/nl/astraeus/jdbc/web/page/HeaderPage.java b/src/nl/astraeus/jdbc/web/page/HeaderPage.java index 2868ecc..0dceb73 100644 --- a/src/nl/astraeus/jdbc/web/page/HeaderPage.java +++ b/src/nl/astraeus/jdbc/web/page/HeaderPage.java @@ -1,7 +1,5 @@ package nl.astraeus.jdbc.web.page; -import nl.astraeus.web.page.TemplatePage; - /** * Date: 11/17/13 * Time: 2:31 PM diff --git a/src/nl/astraeus/jdbc/web/page/JvmStats.html b/src/nl/astraeus/jdbc/web/page/JvmStats.html index d38f031..98537e0 100644 --- a/src/nl/astraeus/jdbc/web/page/JvmStats.html +++ b/src/nl/astraeus/jdbc/web/page/JvmStats.html @@ -52,8 +52,6 @@ ${sample.location} ${sample.count} ${/if} - - ${/each} diff --git a/src/nl/astraeus/jdbc/web/page/Resources.java b/src/nl/astraeus/jdbc/web/page/Resources.java index 2065c73..70f0fd7 100644 --- a/src/nl/astraeus/jdbc/web/page/Resources.java +++ b/src/nl/astraeus/jdbc/web/page/Resources.java @@ -5,14 +5,13 @@ import java.io.OutputStream; import nl.astraeus.jdbc.util.IOUtils; -import nl.astraeus.web.page.Page; /** * User: rnentjes * Date: 3/28/12 * Time: 3:05 PM */ -public class Resources extends Page { +public class Resources extends TemplatePage { private long startup = System.currentTimeMillis(); @@ -27,7 +26,7 @@ } @Override - public void render(OutputStream out) throws IOException { + public void render(OutputStream out) { StringBuilder uriBuilder = new StringBuilder("nl/astraeus/jdbc/web/resources"); for (String part : parts) { @@ -59,8 +58,14 @@ setHeader("ETag", Long.toHexString(startup)); IOUtils.copy(in, out); + } catch(IOException e) { + throw new IllegalStateException(e); } finally { - in.close(); + try { + in.close(); + } catch(IOException e) { + throw new IllegalStateException(e); + } } } } diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 41cd493..f9ae410 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -17,7 +17,7 @@ - + diff --git a/.idea/libraries-with-intellij-classes.xml b/.idea/libraries-with-intellij-classes.xml new file mode 100644 index 0000000..9fa3156 --- /dev/null +++ b/.idea/libraries-with-intellij-classes.xml @@ -0,0 +1,65 @@ + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml new file mode 100644 index 0000000..c108f80 --- /dev/null +++ b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml b/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml deleted file mode 100644 index 9a00155..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml b/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml deleted file mode 100644 index 873c2c0..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml new file mode 100644 index 0000000..7d1fc19 --- /dev/null +++ b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index be926a3..6d93540 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,7 +8,7 @@ http://www.w3.org/1999/xhtml - + diff --git a/.idea/modules/simple-jdbc-stats.main.iml b/.idea/modules/simple-jdbc-stats.main.iml index 578407e..50faa2e 100644 --- a/.idea/modules/simple-jdbc-stats.main.iml +++ b/.idea/modules/simple-jdbc-stats.main.iml @@ -1,15 +1,15 @@ - + - - + + \ No newline at end of file diff --git a/.idea/modules/simple-jdbc-stats.test.iml b/.idea/modules/simple-jdbc-stats.test.iml index 62ffcca..f5baeeb 100644 --- a/.idea/modules/simple-jdbc-stats.test.iml +++ b/.idea/modules/simple-jdbc-stats.test.iml @@ -1,7 +1,7 @@ - + @@ -10,8 +10,8 @@ - - + + diff --git a/build.gradle b/build.gradle index 8791f4a..559db71 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,6 @@ apply plugin: 'java' apply plugin: 'idea' apply plugin: 'maven' -apply plugin: 'findbugs' apply plugin: 'maven-publish' sourceSets { @@ -15,8 +14,8 @@ test.resources.srcDirs += 'test' } -sourceCompatibility = 1.5 -targetCompatibility = 1.5 +sourceCompatibility = 1.6 +targetCompatibility = 1.6 repositories { maven { @@ -24,18 +23,23 @@ } } +ext { + PUBLISH_GROUP_ID = group + PUBLISH_VERSION = version + PUBLISH_ARTIFACT_ID = name +} + +apply from: "${rootProject.projectDir}/scripts/publish-mavencentral.gradle" + dependencies { testCompile group: 'junit', name: 'junit', version: '4.12' - testCompile "org.slf4j:slf4j-simple:1.7.21" testCompile "com.h2database:h2:1.4.+" - compile "nl.astraeus.template:very-simple-templates:1.3" - compile "nl.astraeus.web:simple-web:0.3" - compile "org.slf4j:slf4j-api:1.7.21" + compile "com.samskivert:jmustache:1.15" + compile "org.nanohttpd:nanohttpd:2.2.0" configurations.compile.exclude module: 'javax.servlet-api' - configurations.compile.exclude module: 'slf4j-simple' } uploadArchives { @@ -51,10 +55,6 @@ } } -findbugs { - ignoreFailures = true -} - javadoc { failOnError = false } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 088b40b..bd4ca84 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip diff --git a/scripts/publish-mavencentral.gradle b/scripts/publish-mavencentral.gradle new file mode 100644 index 0000000..fae9b85 --- /dev/null +++ b/scripts/publish-mavencentral.gradle @@ -0,0 +1,121 @@ + +apply plugin: 'maven-publish' +apply plugin: 'signing' + +task publishSourcesJar(type: Jar) { + archiveClassifier.set('sources') + + // For pure Kotlin libraries, in case you have them + from sourceSets.main.java.srcDirs + //from sourceSets.main.kotlin.srcDirs +} + +task packageJavadoc(type: Jar) { + from javadoc + classifier = 'javadoc' +} + +artifacts { + archives publishSourcesJar +} + +File secretPropsFile = project.rootProject.file('local.properties') + +ext["signing.keyId"] = '' +ext["signing.password"] = '' +ext["signing.secretKeyRingFile"] = '' +ext["ossrhUsername"] = '' +ext["ossrhPassword"] = '' +ext["sonatypeStagingProfileId"] = '' + +if (secretPropsFile.exists()) { + Properties p = new Properties() + + new FileInputStream(secretPropsFile).withCloseable { is -> + p.load(is) + } + + p.each { name, value -> + ext[name] = value + } +} + +afterEvaluate { + publishing { + publications { + relase(MavenPublication) { + // The coordinates of the library, being set from variables that + // we'll set up later + groupId PUBLISH_GROUP_ID + artifactId PUBLISH_ARTIFACT_ID + version PUBLISH_VERSION + + // Two artifacts, the `aar` (or `jar`) and the sources + if (project.plugins.findPlugin("com.android.library")) { + artifact("$buildDir/outputs/aar/${project.getName()}-release.aar") + } else { + artifact("$buildDir/libs/${project.getName()}-${version}.jar") + } + artifact publishSourcesJar + artifact packageJavadoc + + // Mostly self-explanatory metadata + pom { + name = PUBLISH_ARTIFACT_ID + description = 'Simple JDBC wrapper for query statistics' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics' + licenses { + license { + name = 'MIT License' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics/blob/master/LICENCE.txt' + } + } + developers { + developer { + id = 'rnentjes' + name = 'Rien Nentjes' + email = 'info@nentjes.com' + } + // Add all other devs here... + } + // Version control info - if you're using GitHub, follow the format as seen here + scm { + connection = 'scm:git:github.com/rnentjes/Simple-jdbc-statistics.git' + developerConnection = 'scm:git:ssh://github.com/rnentjes/Simple-jdbc-statistics.git' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics.git/tree/main' + } + // A slightly hacky fix so that your POM will include any transitive dependencies + // that your library builds upon + /* + witXml { + def dependenciesNode = asNode().appendNode('dependencies') + + project.configurations.implementation.allDependencies.each { + def dependencyNode = dependenciesNode.appendNode('dependency') + dependencyNode.appendNode('groupId', it.group) + dependencyNode.appendNode('artifactId', it.name) + dependencyNode.appendNode('version', it.version) + } + }*/ + } + } + } + // The repository to publish to, Sonatype/MavenCentral + repositories { + maven { + // This is an arbitrary name, you may also use "mavencentral" or + // any other name that's descriptive for you + name = "sonatype" + url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" + credentials { + username ossrhUsername + password ossrhPassword + } + } + } + } +} + +signing { + sign publishing.publications +} diff --git a/src/nl/astraeus/jdbc/CallableStatementLogger.java b/src/nl/astraeus/jdbc/CallableStatementLogger.java index 2e9f173..39be81c 100644 --- a/src/nl/astraeus/jdbc/CallableStatementLogger.java +++ b/src/nl/astraeus/jdbc/CallableStatementLogger.java @@ -1,8 +1,5 @@ package nl.astraeus.jdbc; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; @@ -17,8 +14,6 @@ * Time: 9:48 PM */ public class CallableStatementLogger implements CallableStatement { - private final static Logger log = LoggerFactory.getLogger(PreparedStatementLogger.class); - private JdbcLogger logger; private CallableStatement statement; diff --git a/src/nl/astraeus/jdbc/Driver.java b/src/nl/astraeus/jdbc/Driver.java index 046d756..e230a06 100644 --- a/src/nl/astraeus/jdbc/Driver.java +++ b/src/nl/astraeus/jdbc/Driver.java @@ -11,44 +11,38 @@ import java.util.concurrent.ConcurrentHashMap; import nl.astraeus.jdbc.web.JdbcStatsMappingProvider; +import nl.astraeus.jdbc.web.NanoHttpdSimpleWeb; import nl.astraeus.jdbc.web.model.Settings; -import nl.astraeus.web.NanoHttpdSimpleWeb; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * User: riennentjes * Date: Jul 10, 2008 * Time: 8:54:37 PM - * + *

* Test a little change - * */ public class Driver implements java.sql.Driver { - private final static Logger log = LoggerFactory.getLogger(Driver.class); - - final private static String URL_PREFIX = "jdbc:stat:"; - final private static String URL_SECURE_PREFIX = "jdbc:secstat:"; + final private static String URL_PREFIX = "jdbc:stat:"; + final private static String URL_SECURE_PREFIX = "jdbc:secstat:"; public static class StatsLogger { - private volatile boolean started = false; - private NanoHttpdSimpleWeb server = null; - private java.sql.Driver driver = null; - private Settings settings = new Settings(); - private String targetUrl = null; + private volatile boolean started = false; + private NanoHttpdSimpleWeb server = null; + private java.sql.Driver driver = null; + private Settings settings = new Settings(); + private String targetUrl = null; public Settings getSettings() { return settings; } } - private static Map loggers = new ConcurrentHashMap(); - private static Map portMapping = new ConcurrentHashMap(); + private static Map loggers = new ConcurrentHashMap(); + private static Map portMapping = new ConcurrentHashMap(); public static StatsLogger get(String url) { if (!loggers.containsKey(url)) { - throw new IllegalArgumentException("No jdbc statistics logger found for url: "+url); + throw new IllegalArgumentException("No jdbc statistics logger found for url: " + url); } return loggers.get(url); @@ -56,7 +50,7 @@ public static StatsLogger get(int port) { if (!portMapping.containsKey(port)) { - throw new IllegalArgumentException("No jdbc statistics logger found on port: "+port); + throw new IllegalArgumentException("No jdbc statistics logger found on port: " + port); } return portMapping.get(port); @@ -75,7 +69,8 @@ "org.apache.derby.jdbc.EmbeddedDriver", "com.mysql.jdbc.Driver", "org.hsqldb.jdbcDriver", - "org.h2.Driver" }; + "org.h2.Driver" + }; static { log.debug("Loading driver class " + Driver.class.getName()); @@ -123,8 +118,8 @@ logger.settings.setSecure(true); } - String [] parts = url.split("\\:"); - String settingsString = "webServerConnections=5;numberOfQueries=2500;logStacktraces=true;formattedQueries=true"; + String[] parts = url.split("\\:"); + String settingsString = "webServerConnections=5;numberOfQueries=2500;logStacktraces=true;formattedQueries=true"; if (parts.length > 3) { settingsString = parts[2]; @@ -146,7 +141,7 @@ } if (logger.settings.isSecure()) { - String user = info.getProperty("user"); + String user = info.getProperty("user"); String password = info.getProperty("password"); if (user == null || password == null) { @@ -161,15 +156,21 @@ synchronized (this) { if (!logger.started) { try { - NanoHttpdSimpleWeb server = new NanoHttpdSimpleWeb(logger.settings.getWebServerPort(), new JdbcStatsMappingProvider()); + NanoHttpdSimpleWeb server = new NanoHttpdSimpleWeb( + logger.settings.getWebServerPort(), + new JdbcStatsMappingProvider() + ); server.start(); - System.out.println("Started Simple JDBC Statistics\n\turl: "+url+"\n\tport: "+logger.settings.getWebServerPort()); + System.out.println("Started Simple JDBC Statistics\n\turl: " + + url + + "\n\tport: " + + logger.settings.getWebServerPort()); logger.started = true; } catch (Exception e) { - log.error(e.getMessage(),e); + log.error(e.getMessage(), e); } } } diff --git a/src/nl/astraeus/jdbc/JdbcLogger.java b/src/nl/astraeus/jdbc/JdbcLogger.java index 44d09e6..ac7188a 100644 --- a/src/nl/astraeus/jdbc/JdbcLogger.java +++ b/src/nl/astraeus/jdbc/JdbcLogger.java @@ -1,15 +1,10 @@ package nl.astraeus.jdbc; import nl.astraeus.jdbc.util.Util; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import java.util.HashMap; -import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; @@ -19,8 +14,6 @@ * Time: 9:15:21 AM */ public class JdbcLogger { - private final static Logger logger = LoggerFactory.getLogger(JdbcLogger.class); - private final static Map instances = new ConcurrentHashMap(); public static JdbcLogger get(int port) { diff --git a/src/nl/astraeus/jdbc/PreparedStatementLogger.java b/src/nl/astraeus/jdbc/PreparedStatementLogger.java index f97959a..648fea0 100644 --- a/src/nl/astraeus/jdbc/PreparedStatementLogger.java +++ b/src/nl/astraeus/jdbc/PreparedStatementLogger.java @@ -1,8 +1,5 @@ package nl.astraeus.jdbc; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; @@ -25,12 +22,8 @@ import java.sql.Time; import java.sql.Timestamp; import java.util.Calendar; -import java.util.Comparator; -import java.util.HashSet; import java.util.Map; -import java.util.Set; import java.util.TreeMap; -import java.util.TreeSet; /** * User: riennentjes @@ -38,8 +31,6 @@ * Time: 7:47:57 PM */ public class PreparedStatementLogger implements PreparedStatement { - private final static Logger log = LoggerFactory.getLogger(PreparedStatementLogger.class); - private JdbcLogger logger; private PreparedStatement statement; diff --git a/src/nl/astraeus/jdbc/SqlFormatter.java b/src/nl/astraeus/jdbc/SqlFormatter.java index e28810b..8129dfc 100644 --- a/src/nl/astraeus/jdbc/SqlFormatter.java +++ b/src/nl/astraeus/jdbc/SqlFormatter.java @@ -4,17 +4,12 @@ import java.util.List; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/18/12 * Time: 10:10 PM */ public class SqlFormatter { - private final static Logger logger = LoggerFactory.getLogger(SqlFormatter.class); - private static SqlTokenizer tokenizer = new SqlTokenizer(); private static enum Newline { diff --git a/src/nl/astraeus/jdbc/thread/JvmSampler.java b/src/nl/astraeus/jdbc/thread/JvmSampler.java index f1b98d6..155c4ee 100644 --- a/src/nl/astraeus/jdbc/thread/JvmSampler.java +++ b/src/nl/astraeus/jdbc/thread/JvmSampler.java @@ -5,17 +5,12 @@ import java.util.Set; import java.util.TreeSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/22/13 * Time: 8:52 PM */ public class JvmSampler extends Thread { - private final static Logger logger = LoggerFactory.getLogger(JvmSampler.class); - private boolean stopped; private boolean running; diff --git a/src/nl/astraeus/jdbc/util/ReflectHelper.java b/src/nl/astraeus/jdbc/util/ReflectHelper.java index eac090f..7582e04 100644 --- a/src/nl/astraeus/jdbc/util/ReflectHelper.java +++ b/src/nl/astraeus/jdbc/util/ReflectHelper.java @@ -9,17 +9,12 @@ import java.util.List; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 10/16/13 * Time: 4:49 PM */ public class ReflectHelper { - private final static Logger logger = LoggerFactory.getLogger(ReflectHelper.class); - private final static ReflectHelper instance = new ReflectHelper(); public static ReflectHelper get() { diff --git a/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java b/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java index 555b1d3..a70febc 100644 --- a/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java +++ b/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java @@ -9,14 +9,12 @@ import nl.astraeus.jdbc.web.page.ShowStacktrace; import nl.astraeus.jdbc.web.page.TransactionDetail; import nl.astraeus.jdbc.web.page.TransactionOverview; -import nl.astraeus.web.page.Page; -import nl.astraeus.web.page.PageMapping; /** * Date: 11/24/13 * Time: 10:27 AM */ -public enum JdbcStatsMapping implements PageMapping { +public enum JdbcStatsMapping { QUERIES("queries", QueryOverview.class), QUERY("query", QueryDetail.class), @@ -36,8 +34,8 @@ MAIN("", QueryOverview.class), ; - private String uri; - private Class cls; + private final String uri; + private final Class cls; private JdbcStatsMapping(String uri, Class cls) { this.uri = uri; @@ -48,8 +46,8 @@ return uri; } - public Class getPage() { - return (Class) cls; + public Class getPage() { + return cls; } } diff --git a/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java b/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java index b05e76a..36b1819 100644 --- a/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java +++ b/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java @@ -1,15 +1,12 @@ package nl.astraeus.jdbc.web; -import nl.astraeus.web.page.MappingProvider; -import nl.astraeus.web.page.PageMapping; - /** * Date: 11/24/13 * Time: 10:24 AM */ -public class JdbcStatsMappingProvider implements MappingProvider { +public class JdbcStatsMappingProvider { - public PageMapping getMapping(String uri) { + public JdbcStatsMapping getMapping(String uri) { for (JdbcStatsMapping mapping : JdbcStatsMapping.values()) { if (uri.startsWith(mapping.getUri())) { return mapping; @@ -19,11 +16,12 @@ return null; } - public PageMapping getLoginPage() { + public JdbcStatsMapping getLoginPage() { return JdbcStatsMapping.LOGIN; } - public PageMapping get404Page() { + public JdbcStatsMapping get404Page() { return JdbcStatsMapping.NOTFOUND; } + } diff --git a/src/nl/astraeus/jdbc/web/NanoHttpdSimpleWeb.java b/src/nl/astraeus/jdbc/web/NanoHttpdSimpleWeb.java new file mode 100644 index 0000000..393445e --- /dev/null +++ b/src/nl/astraeus/jdbc/web/NanoHttpdSimpleWeb.java @@ -0,0 +1,56 @@ +package nl.astraeus.jdbc.web; + +import fi.iki.elonen.NanoHTTPD; + +public class NanoHttpdSimpleWeb extends NanoHTTPD { + private JdbcStatsMappingProvider mappingProvider; + + public NanoHttpdSimpleWeb(int port, JdbcStatsMappingProvider mappingProvider) { + super(port); + + this.mappingProvider = mappingProvider; + } + + @Override + public Response serve(IHTTPSession session) { + String uri = session.getUri(); + +/* try { + PageFinder finder = new PageFinder(uri, mappingProvider); + + Map files = new HashMap(); + session.parseBody(files); + + NanoHttpdRequestWrapper wrapper = new NanoHttpdRequestWrapper(getListeningPort(), session); + + RequestWrapperHolder.set(wrapper); + + Page page = finder.findPage(); + + ByteArrayOutputStream out = new ByteArrayOutputStream(); + + page.execute(session.getMethod(), out, mappingProvider.getLoginPage().getUri()); + + out.close(); + + byte[] buffer = out.toByteArray(); + + ByteArrayInputStream in = new ByteArrayInputStream(buffer); + // todo: mimetypes + Response response = new Response(wrapper.getStatus(), wrapper.getContentType(), in, -1); + for (Map.Entry entry : wrapper.getResponseHeaders().entrySet()) { + response.addHeader(entry.getKey(), entry.getValue()); + } + return response; + } catch (Exception e) { + logger.warn(e.getMessage(), e); + + throw new IllegalStateException(e); + } finally { + RequestWrapperHolder.remove(); + }*/ + + return newFixedLengthResponse("Ok"); + } + +} \ No newline at end of file diff --git a/src/nl/astraeus/jdbc/web/model/Settings.java b/src/nl/astraeus/jdbc/web/model/Settings.java index 043ca8a..7750833 100644 --- a/src/nl/astraeus/jdbc/web/model/Settings.java +++ b/src/nl/astraeus/jdbc/web/model/Settings.java @@ -1,16 +1,11 @@ package nl.astraeus.jdbc.web.model; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/22/12 * Time: 1:53 PM */ public class Settings { - private final static Logger logger = LoggerFactory.getLogger(Settings.class); - private final static String NUMBER_OF_QUERIES = "numberOfQueries"; private final static String LOG_STACKTRACES = "logStacktraces"; private final static String FORMATTED_QUERIES = "formattedQueries"; diff --git a/src/nl/astraeus/jdbc/web/page/FooterPage.java b/src/nl/astraeus/jdbc/web/page/FooterPage.java index fcf9931..c09b12c 100644 --- a/src/nl/astraeus/jdbc/web/page/FooterPage.java +++ b/src/nl/astraeus/jdbc/web/page/FooterPage.java @@ -1,7 +1,5 @@ package nl.astraeus.jdbc.web.page; -import nl.astraeus.web.page.TemplatePage; - /** * Date: 11/17/13 * Time: 2:31 PM diff --git a/src/nl/astraeus/jdbc/web/page/HeaderPage.java b/src/nl/astraeus/jdbc/web/page/HeaderPage.java index 2868ecc..0dceb73 100644 --- a/src/nl/astraeus/jdbc/web/page/HeaderPage.java +++ b/src/nl/astraeus/jdbc/web/page/HeaderPage.java @@ -1,7 +1,5 @@ package nl.astraeus.jdbc.web.page; -import nl.astraeus.web.page.TemplatePage; - /** * Date: 11/17/13 * Time: 2:31 PM diff --git a/src/nl/astraeus/jdbc/web/page/JvmStats.html b/src/nl/astraeus/jdbc/web/page/JvmStats.html index d38f031..98537e0 100644 --- a/src/nl/astraeus/jdbc/web/page/JvmStats.html +++ b/src/nl/astraeus/jdbc/web/page/JvmStats.html @@ -52,8 +52,6 @@ ${sample.location} ${sample.count} ${/if} - - ${/each} diff --git a/src/nl/astraeus/jdbc/web/page/Resources.java b/src/nl/astraeus/jdbc/web/page/Resources.java index 2065c73..70f0fd7 100644 --- a/src/nl/astraeus/jdbc/web/page/Resources.java +++ b/src/nl/astraeus/jdbc/web/page/Resources.java @@ -5,14 +5,13 @@ import java.io.OutputStream; import nl.astraeus.jdbc.util.IOUtils; -import nl.astraeus.web.page.Page; /** * User: rnentjes * Date: 3/28/12 * Time: 3:05 PM */ -public class Resources extends Page { +public class Resources extends TemplatePage { private long startup = System.currentTimeMillis(); @@ -27,7 +26,7 @@ } @Override - public void render(OutputStream out) throws IOException { + public void render(OutputStream out) { StringBuilder uriBuilder = new StringBuilder("nl/astraeus/jdbc/web/resources"); for (String part : parts) { @@ -59,8 +58,14 @@ setHeader("ETag", Long.toHexString(startup)); IOUtils.copy(in, out); + } catch(IOException e) { + throw new IllegalStateException(e); } finally { - in.close(); + try { + in.close(); + } catch(IOException e) { + throw new IllegalStateException(e); + } } } } diff --git a/src/nl/astraeus/jdbc/web/page/ServerInfo.java b/src/nl/astraeus/jdbc/web/page/ServerInfo.java index 5abefc7..55f6503 100644 --- a/src/nl/astraeus/jdbc/web/page/ServerInfo.java +++ b/src/nl/astraeus/jdbc/web/page/ServerInfo.java @@ -1,16 +1,11 @@ package nl.astraeus.jdbc.web.page; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/12/12 * Time: 9:16 PM */ public class ServerInfo extends StatsPage { - private static Logger logger = LoggerFactory.getLogger(ServerInfo.class); - @Override public void get() { if ("select".equals(getParameter("action"))) { diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 41cd493..f9ae410 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -17,7 +17,7 @@ - + diff --git a/.idea/libraries-with-intellij-classes.xml b/.idea/libraries-with-intellij-classes.xml new file mode 100644 index 0000000..9fa3156 --- /dev/null +++ b/.idea/libraries-with-intellij-classes.xml @@ -0,0 +1,65 @@ + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml new file mode 100644 index 0000000..c108f80 --- /dev/null +++ b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml b/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml deleted file mode 100644 index 9a00155..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml b/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml deleted file mode 100644 index 873c2c0..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml new file mode 100644 index 0000000..7d1fc19 --- /dev/null +++ b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index be926a3..6d93540 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,7 +8,7 @@ http://www.w3.org/1999/xhtml - + diff --git a/.idea/modules/simple-jdbc-stats.main.iml b/.idea/modules/simple-jdbc-stats.main.iml index 578407e..50faa2e 100644 --- a/.idea/modules/simple-jdbc-stats.main.iml +++ b/.idea/modules/simple-jdbc-stats.main.iml @@ -1,15 +1,15 @@ - + - - + + \ No newline at end of file diff --git a/.idea/modules/simple-jdbc-stats.test.iml b/.idea/modules/simple-jdbc-stats.test.iml index 62ffcca..f5baeeb 100644 --- a/.idea/modules/simple-jdbc-stats.test.iml +++ b/.idea/modules/simple-jdbc-stats.test.iml @@ -1,7 +1,7 @@ - + @@ -10,8 +10,8 @@ - - + + diff --git a/build.gradle b/build.gradle index 8791f4a..559db71 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,6 @@ apply plugin: 'java' apply plugin: 'idea' apply plugin: 'maven' -apply plugin: 'findbugs' apply plugin: 'maven-publish' sourceSets { @@ -15,8 +14,8 @@ test.resources.srcDirs += 'test' } -sourceCompatibility = 1.5 -targetCompatibility = 1.5 +sourceCompatibility = 1.6 +targetCompatibility = 1.6 repositories { maven { @@ -24,18 +23,23 @@ } } +ext { + PUBLISH_GROUP_ID = group + PUBLISH_VERSION = version + PUBLISH_ARTIFACT_ID = name +} + +apply from: "${rootProject.projectDir}/scripts/publish-mavencentral.gradle" + dependencies { testCompile group: 'junit', name: 'junit', version: '4.12' - testCompile "org.slf4j:slf4j-simple:1.7.21" testCompile "com.h2database:h2:1.4.+" - compile "nl.astraeus.template:very-simple-templates:1.3" - compile "nl.astraeus.web:simple-web:0.3" - compile "org.slf4j:slf4j-api:1.7.21" + compile "com.samskivert:jmustache:1.15" + compile "org.nanohttpd:nanohttpd:2.2.0" configurations.compile.exclude module: 'javax.servlet-api' - configurations.compile.exclude module: 'slf4j-simple' } uploadArchives { @@ -51,10 +55,6 @@ } } -findbugs { - ignoreFailures = true -} - javadoc { failOnError = false } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 088b40b..bd4ca84 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip diff --git a/scripts/publish-mavencentral.gradle b/scripts/publish-mavencentral.gradle new file mode 100644 index 0000000..fae9b85 --- /dev/null +++ b/scripts/publish-mavencentral.gradle @@ -0,0 +1,121 @@ + +apply plugin: 'maven-publish' +apply plugin: 'signing' + +task publishSourcesJar(type: Jar) { + archiveClassifier.set('sources') + + // For pure Kotlin libraries, in case you have them + from sourceSets.main.java.srcDirs + //from sourceSets.main.kotlin.srcDirs +} + +task packageJavadoc(type: Jar) { + from javadoc + classifier = 'javadoc' +} + +artifacts { + archives publishSourcesJar +} + +File secretPropsFile = project.rootProject.file('local.properties') + +ext["signing.keyId"] = '' +ext["signing.password"] = '' +ext["signing.secretKeyRingFile"] = '' +ext["ossrhUsername"] = '' +ext["ossrhPassword"] = '' +ext["sonatypeStagingProfileId"] = '' + +if (secretPropsFile.exists()) { + Properties p = new Properties() + + new FileInputStream(secretPropsFile).withCloseable { is -> + p.load(is) + } + + p.each { name, value -> + ext[name] = value + } +} + +afterEvaluate { + publishing { + publications { + relase(MavenPublication) { + // The coordinates of the library, being set from variables that + // we'll set up later + groupId PUBLISH_GROUP_ID + artifactId PUBLISH_ARTIFACT_ID + version PUBLISH_VERSION + + // Two artifacts, the `aar` (or `jar`) and the sources + if (project.plugins.findPlugin("com.android.library")) { + artifact("$buildDir/outputs/aar/${project.getName()}-release.aar") + } else { + artifact("$buildDir/libs/${project.getName()}-${version}.jar") + } + artifact publishSourcesJar + artifact packageJavadoc + + // Mostly self-explanatory metadata + pom { + name = PUBLISH_ARTIFACT_ID + description = 'Simple JDBC wrapper for query statistics' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics' + licenses { + license { + name = 'MIT License' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics/blob/master/LICENCE.txt' + } + } + developers { + developer { + id = 'rnentjes' + name = 'Rien Nentjes' + email = 'info@nentjes.com' + } + // Add all other devs here... + } + // Version control info - if you're using GitHub, follow the format as seen here + scm { + connection = 'scm:git:github.com/rnentjes/Simple-jdbc-statistics.git' + developerConnection = 'scm:git:ssh://github.com/rnentjes/Simple-jdbc-statistics.git' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics.git/tree/main' + } + // A slightly hacky fix so that your POM will include any transitive dependencies + // that your library builds upon + /* + witXml { + def dependenciesNode = asNode().appendNode('dependencies') + + project.configurations.implementation.allDependencies.each { + def dependencyNode = dependenciesNode.appendNode('dependency') + dependencyNode.appendNode('groupId', it.group) + dependencyNode.appendNode('artifactId', it.name) + dependencyNode.appendNode('version', it.version) + } + }*/ + } + } + } + // The repository to publish to, Sonatype/MavenCentral + repositories { + maven { + // This is an arbitrary name, you may also use "mavencentral" or + // any other name that's descriptive for you + name = "sonatype" + url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" + credentials { + username ossrhUsername + password ossrhPassword + } + } + } + } +} + +signing { + sign publishing.publications +} diff --git a/src/nl/astraeus/jdbc/CallableStatementLogger.java b/src/nl/astraeus/jdbc/CallableStatementLogger.java index 2e9f173..39be81c 100644 --- a/src/nl/astraeus/jdbc/CallableStatementLogger.java +++ b/src/nl/astraeus/jdbc/CallableStatementLogger.java @@ -1,8 +1,5 @@ package nl.astraeus.jdbc; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; @@ -17,8 +14,6 @@ * Time: 9:48 PM */ public class CallableStatementLogger implements CallableStatement { - private final static Logger log = LoggerFactory.getLogger(PreparedStatementLogger.class); - private JdbcLogger logger; private CallableStatement statement; diff --git a/src/nl/astraeus/jdbc/Driver.java b/src/nl/astraeus/jdbc/Driver.java index 046d756..e230a06 100644 --- a/src/nl/astraeus/jdbc/Driver.java +++ b/src/nl/astraeus/jdbc/Driver.java @@ -11,44 +11,38 @@ import java.util.concurrent.ConcurrentHashMap; import nl.astraeus.jdbc.web.JdbcStatsMappingProvider; +import nl.astraeus.jdbc.web.NanoHttpdSimpleWeb; import nl.astraeus.jdbc.web.model.Settings; -import nl.astraeus.web.NanoHttpdSimpleWeb; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * User: riennentjes * Date: Jul 10, 2008 * Time: 8:54:37 PM - * + *

* Test a little change - * */ public class Driver implements java.sql.Driver { - private final static Logger log = LoggerFactory.getLogger(Driver.class); - - final private static String URL_PREFIX = "jdbc:stat:"; - final private static String URL_SECURE_PREFIX = "jdbc:secstat:"; + final private static String URL_PREFIX = "jdbc:stat:"; + final private static String URL_SECURE_PREFIX = "jdbc:secstat:"; public static class StatsLogger { - private volatile boolean started = false; - private NanoHttpdSimpleWeb server = null; - private java.sql.Driver driver = null; - private Settings settings = new Settings(); - private String targetUrl = null; + private volatile boolean started = false; + private NanoHttpdSimpleWeb server = null; + private java.sql.Driver driver = null; + private Settings settings = new Settings(); + private String targetUrl = null; public Settings getSettings() { return settings; } } - private static Map loggers = new ConcurrentHashMap(); - private static Map portMapping = new ConcurrentHashMap(); + private static Map loggers = new ConcurrentHashMap(); + private static Map portMapping = new ConcurrentHashMap(); public static StatsLogger get(String url) { if (!loggers.containsKey(url)) { - throw new IllegalArgumentException("No jdbc statistics logger found for url: "+url); + throw new IllegalArgumentException("No jdbc statistics logger found for url: " + url); } return loggers.get(url); @@ -56,7 +50,7 @@ public static StatsLogger get(int port) { if (!portMapping.containsKey(port)) { - throw new IllegalArgumentException("No jdbc statistics logger found on port: "+port); + throw new IllegalArgumentException("No jdbc statistics logger found on port: " + port); } return portMapping.get(port); @@ -75,7 +69,8 @@ "org.apache.derby.jdbc.EmbeddedDriver", "com.mysql.jdbc.Driver", "org.hsqldb.jdbcDriver", - "org.h2.Driver" }; + "org.h2.Driver" + }; static { log.debug("Loading driver class " + Driver.class.getName()); @@ -123,8 +118,8 @@ logger.settings.setSecure(true); } - String [] parts = url.split("\\:"); - String settingsString = "webServerConnections=5;numberOfQueries=2500;logStacktraces=true;formattedQueries=true"; + String[] parts = url.split("\\:"); + String settingsString = "webServerConnections=5;numberOfQueries=2500;logStacktraces=true;formattedQueries=true"; if (parts.length > 3) { settingsString = parts[2]; @@ -146,7 +141,7 @@ } if (logger.settings.isSecure()) { - String user = info.getProperty("user"); + String user = info.getProperty("user"); String password = info.getProperty("password"); if (user == null || password == null) { @@ -161,15 +156,21 @@ synchronized (this) { if (!logger.started) { try { - NanoHttpdSimpleWeb server = new NanoHttpdSimpleWeb(logger.settings.getWebServerPort(), new JdbcStatsMappingProvider()); + NanoHttpdSimpleWeb server = new NanoHttpdSimpleWeb( + logger.settings.getWebServerPort(), + new JdbcStatsMappingProvider() + ); server.start(); - System.out.println("Started Simple JDBC Statistics\n\turl: "+url+"\n\tport: "+logger.settings.getWebServerPort()); + System.out.println("Started Simple JDBC Statistics\n\turl: " + + url + + "\n\tport: " + + logger.settings.getWebServerPort()); logger.started = true; } catch (Exception e) { - log.error(e.getMessage(),e); + log.error(e.getMessage(), e); } } } diff --git a/src/nl/astraeus/jdbc/JdbcLogger.java b/src/nl/astraeus/jdbc/JdbcLogger.java index 44d09e6..ac7188a 100644 --- a/src/nl/astraeus/jdbc/JdbcLogger.java +++ b/src/nl/astraeus/jdbc/JdbcLogger.java @@ -1,15 +1,10 @@ package nl.astraeus.jdbc; import nl.astraeus.jdbc.util.Util; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import java.util.HashMap; -import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; @@ -19,8 +14,6 @@ * Time: 9:15:21 AM */ public class JdbcLogger { - private final static Logger logger = LoggerFactory.getLogger(JdbcLogger.class); - private final static Map instances = new ConcurrentHashMap(); public static JdbcLogger get(int port) { diff --git a/src/nl/astraeus/jdbc/PreparedStatementLogger.java b/src/nl/astraeus/jdbc/PreparedStatementLogger.java index f97959a..648fea0 100644 --- a/src/nl/astraeus/jdbc/PreparedStatementLogger.java +++ b/src/nl/astraeus/jdbc/PreparedStatementLogger.java @@ -1,8 +1,5 @@ package nl.astraeus.jdbc; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; @@ -25,12 +22,8 @@ import java.sql.Time; import java.sql.Timestamp; import java.util.Calendar; -import java.util.Comparator; -import java.util.HashSet; import java.util.Map; -import java.util.Set; import java.util.TreeMap; -import java.util.TreeSet; /** * User: riennentjes @@ -38,8 +31,6 @@ * Time: 7:47:57 PM */ public class PreparedStatementLogger implements PreparedStatement { - private final static Logger log = LoggerFactory.getLogger(PreparedStatementLogger.class); - private JdbcLogger logger; private PreparedStatement statement; diff --git a/src/nl/astraeus/jdbc/SqlFormatter.java b/src/nl/astraeus/jdbc/SqlFormatter.java index e28810b..8129dfc 100644 --- a/src/nl/astraeus/jdbc/SqlFormatter.java +++ b/src/nl/astraeus/jdbc/SqlFormatter.java @@ -4,17 +4,12 @@ import java.util.List; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/18/12 * Time: 10:10 PM */ public class SqlFormatter { - private final static Logger logger = LoggerFactory.getLogger(SqlFormatter.class); - private static SqlTokenizer tokenizer = new SqlTokenizer(); private static enum Newline { diff --git a/src/nl/astraeus/jdbc/thread/JvmSampler.java b/src/nl/astraeus/jdbc/thread/JvmSampler.java index f1b98d6..155c4ee 100644 --- a/src/nl/astraeus/jdbc/thread/JvmSampler.java +++ b/src/nl/astraeus/jdbc/thread/JvmSampler.java @@ -5,17 +5,12 @@ import java.util.Set; import java.util.TreeSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/22/13 * Time: 8:52 PM */ public class JvmSampler extends Thread { - private final static Logger logger = LoggerFactory.getLogger(JvmSampler.class); - private boolean stopped; private boolean running; diff --git a/src/nl/astraeus/jdbc/util/ReflectHelper.java b/src/nl/astraeus/jdbc/util/ReflectHelper.java index eac090f..7582e04 100644 --- a/src/nl/astraeus/jdbc/util/ReflectHelper.java +++ b/src/nl/astraeus/jdbc/util/ReflectHelper.java @@ -9,17 +9,12 @@ import java.util.List; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 10/16/13 * Time: 4:49 PM */ public class ReflectHelper { - private final static Logger logger = LoggerFactory.getLogger(ReflectHelper.class); - private final static ReflectHelper instance = new ReflectHelper(); public static ReflectHelper get() { diff --git a/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java b/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java index 555b1d3..a70febc 100644 --- a/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java +++ b/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java @@ -9,14 +9,12 @@ import nl.astraeus.jdbc.web.page.ShowStacktrace; import nl.astraeus.jdbc.web.page.TransactionDetail; import nl.astraeus.jdbc.web.page.TransactionOverview; -import nl.astraeus.web.page.Page; -import nl.astraeus.web.page.PageMapping; /** * Date: 11/24/13 * Time: 10:27 AM */ -public enum JdbcStatsMapping implements PageMapping { +public enum JdbcStatsMapping { QUERIES("queries", QueryOverview.class), QUERY("query", QueryDetail.class), @@ -36,8 +34,8 @@ MAIN("", QueryOverview.class), ; - private String uri; - private Class cls; + private final String uri; + private final Class cls; private JdbcStatsMapping(String uri, Class cls) { this.uri = uri; @@ -48,8 +46,8 @@ return uri; } - public Class getPage() { - return (Class) cls; + public Class getPage() { + return cls; } } diff --git a/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java b/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java index b05e76a..36b1819 100644 --- a/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java +++ b/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java @@ -1,15 +1,12 @@ package nl.astraeus.jdbc.web; -import nl.astraeus.web.page.MappingProvider; -import nl.astraeus.web.page.PageMapping; - /** * Date: 11/24/13 * Time: 10:24 AM */ -public class JdbcStatsMappingProvider implements MappingProvider { +public class JdbcStatsMappingProvider { - public PageMapping getMapping(String uri) { + public JdbcStatsMapping getMapping(String uri) { for (JdbcStatsMapping mapping : JdbcStatsMapping.values()) { if (uri.startsWith(mapping.getUri())) { return mapping; @@ -19,11 +16,12 @@ return null; } - public PageMapping getLoginPage() { + public JdbcStatsMapping getLoginPage() { return JdbcStatsMapping.LOGIN; } - public PageMapping get404Page() { + public JdbcStatsMapping get404Page() { return JdbcStatsMapping.NOTFOUND; } + } diff --git a/src/nl/astraeus/jdbc/web/NanoHttpdSimpleWeb.java b/src/nl/astraeus/jdbc/web/NanoHttpdSimpleWeb.java new file mode 100644 index 0000000..393445e --- /dev/null +++ b/src/nl/astraeus/jdbc/web/NanoHttpdSimpleWeb.java @@ -0,0 +1,56 @@ +package nl.astraeus.jdbc.web; + +import fi.iki.elonen.NanoHTTPD; + +public class NanoHttpdSimpleWeb extends NanoHTTPD { + private JdbcStatsMappingProvider mappingProvider; + + public NanoHttpdSimpleWeb(int port, JdbcStatsMappingProvider mappingProvider) { + super(port); + + this.mappingProvider = mappingProvider; + } + + @Override + public Response serve(IHTTPSession session) { + String uri = session.getUri(); + +/* try { + PageFinder finder = new PageFinder(uri, mappingProvider); + + Map files = new HashMap(); + session.parseBody(files); + + NanoHttpdRequestWrapper wrapper = new NanoHttpdRequestWrapper(getListeningPort(), session); + + RequestWrapperHolder.set(wrapper); + + Page page = finder.findPage(); + + ByteArrayOutputStream out = new ByteArrayOutputStream(); + + page.execute(session.getMethod(), out, mappingProvider.getLoginPage().getUri()); + + out.close(); + + byte[] buffer = out.toByteArray(); + + ByteArrayInputStream in = new ByteArrayInputStream(buffer); + // todo: mimetypes + Response response = new Response(wrapper.getStatus(), wrapper.getContentType(), in, -1); + for (Map.Entry entry : wrapper.getResponseHeaders().entrySet()) { + response.addHeader(entry.getKey(), entry.getValue()); + } + return response; + } catch (Exception e) { + logger.warn(e.getMessage(), e); + + throw new IllegalStateException(e); + } finally { + RequestWrapperHolder.remove(); + }*/ + + return newFixedLengthResponse("Ok"); + } + +} \ No newline at end of file diff --git a/src/nl/astraeus/jdbc/web/model/Settings.java b/src/nl/astraeus/jdbc/web/model/Settings.java index 043ca8a..7750833 100644 --- a/src/nl/astraeus/jdbc/web/model/Settings.java +++ b/src/nl/astraeus/jdbc/web/model/Settings.java @@ -1,16 +1,11 @@ package nl.astraeus.jdbc.web.model; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/22/12 * Time: 1:53 PM */ public class Settings { - private final static Logger logger = LoggerFactory.getLogger(Settings.class); - private final static String NUMBER_OF_QUERIES = "numberOfQueries"; private final static String LOG_STACKTRACES = "logStacktraces"; private final static String FORMATTED_QUERIES = "formattedQueries"; diff --git a/src/nl/astraeus/jdbc/web/page/FooterPage.java b/src/nl/astraeus/jdbc/web/page/FooterPage.java index fcf9931..c09b12c 100644 --- a/src/nl/astraeus/jdbc/web/page/FooterPage.java +++ b/src/nl/astraeus/jdbc/web/page/FooterPage.java @@ -1,7 +1,5 @@ package nl.astraeus.jdbc.web.page; -import nl.astraeus.web.page.TemplatePage; - /** * Date: 11/17/13 * Time: 2:31 PM diff --git a/src/nl/astraeus/jdbc/web/page/HeaderPage.java b/src/nl/astraeus/jdbc/web/page/HeaderPage.java index 2868ecc..0dceb73 100644 --- a/src/nl/astraeus/jdbc/web/page/HeaderPage.java +++ b/src/nl/astraeus/jdbc/web/page/HeaderPage.java @@ -1,7 +1,5 @@ package nl.astraeus.jdbc.web.page; -import nl.astraeus.web.page.TemplatePage; - /** * Date: 11/17/13 * Time: 2:31 PM diff --git a/src/nl/astraeus/jdbc/web/page/JvmStats.html b/src/nl/astraeus/jdbc/web/page/JvmStats.html index d38f031..98537e0 100644 --- a/src/nl/astraeus/jdbc/web/page/JvmStats.html +++ b/src/nl/astraeus/jdbc/web/page/JvmStats.html @@ -52,8 +52,6 @@ ${sample.location} ${sample.count} ${/if} - - ${/each} diff --git a/src/nl/astraeus/jdbc/web/page/Resources.java b/src/nl/astraeus/jdbc/web/page/Resources.java index 2065c73..70f0fd7 100644 --- a/src/nl/astraeus/jdbc/web/page/Resources.java +++ b/src/nl/astraeus/jdbc/web/page/Resources.java @@ -5,14 +5,13 @@ import java.io.OutputStream; import nl.astraeus.jdbc.util.IOUtils; -import nl.astraeus.web.page.Page; /** * User: rnentjes * Date: 3/28/12 * Time: 3:05 PM */ -public class Resources extends Page { +public class Resources extends TemplatePage { private long startup = System.currentTimeMillis(); @@ -27,7 +26,7 @@ } @Override - public void render(OutputStream out) throws IOException { + public void render(OutputStream out) { StringBuilder uriBuilder = new StringBuilder("nl/astraeus/jdbc/web/resources"); for (String part : parts) { @@ -59,8 +58,14 @@ setHeader("ETag", Long.toHexString(startup)); IOUtils.copy(in, out); + } catch(IOException e) { + throw new IllegalStateException(e); } finally { - in.close(); + try { + in.close(); + } catch(IOException e) { + throw new IllegalStateException(e); + } } } } diff --git a/src/nl/astraeus/jdbc/web/page/ServerInfo.java b/src/nl/astraeus/jdbc/web/page/ServerInfo.java index 5abefc7..55f6503 100644 --- a/src/nl/astraeus/jdbc/web/page/ServerInfo.java +++ b/src/nl/astraeus/jdbc/web/page/ServerInfo.java @@ -1,16 +1,11 @@ package nl.astraeus.jdbc.web.page; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/12/12 * Time: 9:16 PM */ public class ServerInfo extends StatsPage { - private static Logger logger = LoggerFactory.getLogger(ServerInfo.class); - @Override public void get() { if ("select".equals(getParameter("action"))) { diff --git a/src/nl/astraeus/jdbc/web/page/SettingsOverview.java b/src/nl/astraeus/jdbc/web/page/SettingsOverview.java index 8a5d182..2badb0f 100644 --- a/src/nl/astraeus/jdbc/web/page/SettingsOverview.java +++ b/src/nl/astraeus/jdbc/web/page/SettingsOverview.java @@ -2,7 +2,6 @@ import nl.astraeus.jdbc.Driver; import nl.astraeus.jdbc.web.model.Settings; -import nl.astraeus.web.page.Message; /** * User: rnentjes diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 41cd493..f9ae410 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -17,7 +17,7 @@ - + diff --git a/.idea/libraries-with-intellij-classes.xml b/.idea/libraries-with-intellij-classes.xml new file mode 100644 index 0000000..9fa3156 --- /dev/null +++ b/.idea/libraries-with-intellij-classes.xml @@ -0,0 +1,65 @@ + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml new file mode 100644 index 0000000..c108f80 --- /dev/null +++ b/.idea/libraries/Gradle__com_samskivert_jmustache_1_15.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml b/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml deleted file mode 100644 index 9a00155..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_template_very_simple_templates_1_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml b/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml deleted file mode 100644 index 873c2c0..0000000 --- a/.idea/libraries/Gradle__nl_astraeus_web_simple_web_0_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml new file mode 100644 index 0000000..7d1fc19 --- /dev/null +++ b/.idea/libraries/Gradle__org_nanohttpd_nanohttpd_2_2_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index be926a3..6d93540 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,7 +8,7 @@ http://www.w3.org/1999/xhtml - + diff --git a/.idea/modules/simple-jdbc-stats.main.iml b/.idea/modules/simple-jdbc-stats.main.iml index 578407e..50faa2e 100644 --- a/.idea/modules/simple-jdbc-stats.main.iml +++ b/.idea/modules/simple-jdbc-stats.main.iml @@ -1,15 +1,15 @@ - + - - + + \ No newline at end of file diff --git a/.idea/modules/simple-jdbc-stats.test.iml b/.idea/modules/simple-jdbc-stats.test.iml index 62ffcca..f5baeeb 100644 --- a/.idea/modules/simple-jdbc-stats.test.iml +++ b/.idea/modules/simple-jdbc-stats.test.iml @@ -1,7 +1,7 @@ - + @@ -10,8 +10,8 @@ - - + + diff --git a/build.gradle b/build.gradle index 8791f4a..559db71 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,6 @@ apply plugin: 'java' apply plugin: 'idea' apply plugin: 'maven' -apply plugin: 'findbugs' apply plugin: 'maven-publish' sourceSets { @@ -15,8 +14,8 @@ test.resources.srcDirs += 'test' } -sourceCompatibility = 1.5 -targetCompatibility = 1.5 +sourceCompatibility = 1.6 +targetCompatibility = 1.6 repositories { maven { @@ -24,18 +23,23 @@ } } +ext { + PUBLISH_GROUP_ID = group + PUBLISH_VERSION = version + PUBLISH_ARTIFACT_ID = name +} + +apply from: "${rootProject.projectDir}/scripts/publish-mavencentral.gradle" + dependencies { testCompile group: 'junit', name: 'junit', version: '4.12' - testCompile "org.slf4j:slf4j-simple:1.7.21" testCompile "com.h2database:h2:1.4.+" - compile "nl.astraeus.template:very-simple-templates:1.3" - compile "nl.astraeus.web:simple-web:0.3" - compile "org.slf4j:slf4j-api:1.7.21" + compile "com.samskivert:jmustache:1.15" + compile "org.nanohttpd:nanohttpd:2.2.0" configurations.compile.exclude module: 'javax.servlet-api' - configurations.compile.exclude module: 'slf4j-simple' } uploadArchives { @@ -51,10 +55,6 @@ } } -findbugs { - ignoreFailures = true -} - javadoc { failOnError = false } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 088b40b..bd4ca84 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip diff --git a/scripts/publish-mavencentral.gradle b/scripts/publish-mavencentral.gradle new file mode 100644 index 0000000..fae9b85 --- /dev/null +++ b/scripts/publish-mavencentral.gradle @@ -0,0 +1,121 @@ + +apply plugin: 'maven-publish' +apply plugin: 'signing' + +task publishSourcesJar(type: Jar) { + archiveClassifier.set('sources') + + // For pure Kotlin libraries, in case you have them + from sourceSets.main.java.srcDirs + //from sourceSets.main.kotlin.srcDirs +} + +task packageJavadoc(type: Jar) { + from javadoc + classifier = 'javadoc' +} + +artifacts { + archives publishSourcesJar +} + +File secretPropsFile = project.rootProject.file('local.properties') + +ext["signing.keyId"] = '' +ext["signing.password"] = '' +ext["signing.secretKeyRingFile"] = '' +ext["ossrhUsername"] = '' +ext["ossrhPassword"] = '' +ext["sonatypeStagingProfileId"] = '' + +if (secretPropsFile.exists()) { + Properties p = new Properties() + + new FileInputStream(secretPropsFile).withCloseable { is -> + p.load(is) + } + + p.each { name, value -> + ext[name] = value + } +} + +afterEvaluate { + publishing { + publications { + relase(MavenPublication) { + // The coordinates of the library, being set from variables that + // we'll set up later + groupId PUBLISH_GROUP_ID + artifactId PUBLISH_ARTIFACT_ID + version PUBLISH_VERSION + + // Two artifacts, the `aar` (or `jar`) and the sources + if (project.plugins.findPlugin("com.android.library")) { + artifact("$buildDir/outputs/aar/${project.getName()}-release.aar") + } else { + artifact("$buildDir/libs/${project.getName()}-${version}.jar") + } + artifact publishSourcesJar + artifact packageJavadoc + + // Mostly self-explanatory metadata + pom { + name = PUBLISH_ARTIFACT_ID + description = 'Simple JDBC wrapper for query statistics' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics' + licenses { + license { + name = 'MIT License' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics/blob/master/LICENCE.txt' + } + } + developers { + developer { + id = 'rnentjes' + name = 'Rien Nentjes' + email = 'info@nentjes.com' + } + // Add all other devs here... + } + // Version control info - if you're using GitHub, follow the format as seen here + scm { + connection = 'scm:git:github.com/rnentjes/Simple-jdbc-statistics.git' + developerConnection = 'scm:git:ssh://github.com/rnentjes/Simple-jdbc-statistics.git' + url = 'https://github.com/rnentjes/Simple-jdbc-statistics.git/tree/main' + } + // A slightly hacky fix so that your POM will include any transitive dependencies + // that your library builds upon + /* + witXml { + def dependenciesNode = asNode().appendNode('dependencies') + + project.configurations.implementation.allDependencies.each { + def dependencyNode = dependenciesNode.appendNode('dependency') + dependencyNode.appendNode('groupId', it.group) + dependencyNode.appendNode('artifactId', it.name) + dependencyNode.appendNode('version', it.version) + } + }*/ + } + } + } + // The repository to publish to, Sonatype/MavenCentral + repositories { + maven { + // This is an arbitrary name, you may also use "mavencentral" or + // any other name that's descriptive for you + name = "sonatype" + url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" + credentials { + username ossrhUsername + password ossrhPassword + } + } + } + } +} + +signing { + sign publishing.publications +} diff --git a/src/nl/astraeus/jdbc/CallableStatementLogger.java b/src/nl/astraeus/jdbc/CallableStatementLogger.java index 2e9f173..39be81c 100644 --- a/src/nl/astraeus/jdbc/CallableStatementLogger.java +++ b/src/nl/astraeus/jdbc/CallableStatementLogger.java @@ -1,8 +1,5 @@ package nl.astraeus.jdbc; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; @@ -17,8 +14,6 @@ * Time: 9:48 PM */ public class CallableStatementLogger implements CallableStatement { - private final static Logger log = LoggerFactory.getLogger(PreparedStatementLogger.class); - private JdbcLogger logger; private CallableStatement statement; diff --git a/src/nl/astraeus/jdbc/Driver.java b/src/nl/astraeus/jdbc/Driver.java index 046d756..e230a06 100644 --- a/src/nl/astraeus/jdbc/Driver.java +++ b/src/nl/astraeus/jdbc/Driver.java @@ -11,44 +11,38 @@ import java.util.concurrent.ConcurrentHashMap; import nl.astraeus.jdbc.web.JdbcStatsMappingProvider; +import nl.astraeus.jdbc.web.NanoHttpdSimpleWeb; import nl.astraeus.jdbc.web.model.Settings; -import nl.astraeus.web.NanoHttpdSimpleWeb; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * User: riennentjes * Date: Jul 10, 2008 * Time: 8:54:37 PM - * + *

* Test a little change - * */ public class Driver implements java.sql.Driver { - private final static Logger log = LoggerFactory.getLogger(Driver.class); - - final private static String URL_PREFIX = "jdbc:stat:"; - final private static String URL_SECURE_PREFIX = "jdbc:secstat:"; + final private static String URL_PREFIX = "jdbc:stat:"; + final private static String URL_SECURE_PREFIX = "jdbc:secstat:"; public static class StatsLogger { - private volatile boolean started = false; - private NanoHttpdSimpleWeb server = null; - private java.sql.Driver driver = null; - private Settings settings = new Settings(); - private String targetUrl = null; + private volatile boolean started = false; + private NanoHttpdSimpleWeb server = null; + private java.sql.Driver driver = null; + private Settings settings = new Settings(); + private String targetUrl = null; public Settings getSettings() { return settings; } } - private static Map loggers = new ConcurrentHashMap(); - private static Map portMapping = new ConcurrentHashMap(); + private static Map loggers = new ConcurrentHashMap(); + private static Map portMapping = new ConcurrentHashMap(); public static StatsLogger get(String url) { if (!loggers.containsKey(url)) { - throw new IllegalArgumentException("No jdbc statistics logger found for url: "+url); + throw new IllegalArgumentException("No jdbc statistics logger found for url: " + url); } return loggers.get(url); @@ -56,7 +50,7 @@ public static StatsLogger get(int port) { if (!portMapping.containsKey(port)) { - throw new IllegalArgumentException("No jdbc statistics logger found on port: "+port); + throw new IllegalArgumentException("No jdbc statistics logger found on port: " + port); } return portMapping.get(port); @@ -75,7 +69,8 @@ "org.apache.derby.jdbc.EmbeddedDriver", "com.mysql.jdbc.Driver", "org.hsqldb.jdbcDriver", - "org.h2.Driver" }; + "org.h2.Driver" + }; static { log.debug("Loading driver class " + Driver.class.getName()); @@ -123,8 +118,8 @@ logger.settings.setSecure(true); } - String [] parts = url.split("\\:"); - String settingsString = "webServerConnections=5;numberOfQueries=2500;logStacktraces=true;formattedQueries=true"; + String[] parts = url.split("\\:"); + String settingsString = "webServerConnections=5;numberOfQueries=2500;logStacktraces=true;formattedQueries=true"; if (parts.length > 3) { settingsString = parts[2]; @@ -146,7 +141,7 @@ } if (logger.settings.isSecure()) { - String user = info.getProperty("user"); + String user = info.getProperty("user"); String password = info.getProperty("password"); if (user == null || password == null) { @@ -161,15 +156,21 @@ synchronized (this) { if (!logger.started) { try { - NanoHttpdSimpleWeb server = new NanoHttpdSimpleWeb(logger.settings.getWebServerPort(), new JdbcStatsMappingProvider()); + NanoHttpdSimpleWeb server = new NanoHttpdSimpleWeb( + logger.settings.getWebServerPort(), + new JdbcStatsMappingProvider() + ); server.start(); - System.out.println("Started Simple JDBC Statistics\n\turl: "+url+"\n\tport: "+logger.settings.getWebServerPort()); + System.out.println("Started Simple JDBC Statistics\n\turl: " + + url + + "\n\tport: " + + logger.settings.getWebServerPort()); logger.started = true; } catch (Exception e) { - log.error(e.getMessage(),e); + log.error(e.getMessage(), e); } } } diff --git a/src/nl/astraeus/jdbc/JdbcLogger.java b/src/nl/astraeus/jdbc/JdbcLogger.java index 44d09e6..ac7188a 100644 --- a/src/nl/astraeus/jdbc/JdbcLogger.java +++ b/src/nl/astraeus/jdbc/JdbcLogger.java @@ -1,15 +1,10 @@ package nl.astraeus.jdbc; import nl.astraeus.jdbc.util.Util; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import java.util.HashMap; -import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; @@ -19,8 +14,6 @@ * Time: 9:15:21 AM */ public class JdbcLogger { - private final static Logger logger = LoggerFactory.getLogger(JdbcLogger.class); - private final static Map instances = new ConcurrentHashMap(); public static JdbcLogger get(int port) { diff --git a/src/nl/astraeus/jdbc/PreparedStatementLogger.java b/src/nl/astraeus/jdbc/PreparedStatementLogger.java index f97959a..648fea0 100644 --- a/src/nl/astraeus/jdbc/PreparedStatementLogger.java +++ b/src/nl/astraeus/jdbc/PreparedStatementLogger.java @@ -1,8 +1,5 @@ package nl.astraeus.jdbc; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; @@ -25,12 +22,8 @@ import java.sql.Time; import java.sql.Timestamp; import java.util.Calendar; -import java.util.Comparator; -import java.util.HashSet; import java.util.Map; -import java.util.Set; import java.util.TreeMap; -import java.util.TreeSet; /** * User: riennentjes @@ -38,8 +31,6 @@ * Time: 7:47:57 PM */ public class PreparedStatementLogger implements PreparedStatement { - private final static Logger log = LoggerFactory.getLogger(PreparedStatementLogger.class); - private JdbcLogger logger; private PreparedStatement statement; diff --git a/src/nl/astraeus/jdbc/SqlFormatter.java b/src/nl/astraeus/jdbc/SqlFormatter.java index e28810b..8129dfc 100644 --- a/src/nl/astraeus/jdbc/SqlFormatter.java +++ b/src/nl/astraeus/jdbc/SqlFormatter.java @@ -4,17 +4,12 @@ import java.util.List; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/18/12 * Time: 10:10 PM */ public class SqlFormatter { - private final static Logger logger = LoggerFactory.getLogger(SqlFormatter.class); - private static SqlTokenizer tokenizer = new SqlTokenizer(); private static enum Newline { diff --git a/src/nl/astraeus/jdbc/thread/JvmSampler.java b/src/nl/astraeus/jdbc/thread/JvmSampler.java index f1b98d6..155c4ee 100644 --- a/src/nl/astraeus/jdbc/thread/JvmSampler.java +++ b/src/nl/astraeus/jdbc/thread/JvmSampler.java @@ -5,17 +5,12 @@ import java.util.Set; import java.util.TreeSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/22/13 * Time: 8:52 PM */ public class JvmSampler extends Thread { - private final static Logger logger = LoggerFactory.getLogger(JvmSampler.class); - private boolean stopped; private boolean running; diff --git a/src/nl/astraeus/jdbc/util/ReflectHelper.java b/src/nl/astraeus/jdbc/util/ReflectHelper.java index eac090f..7582e04 100644 --- a/src/nl/astraeus/jdbc/util/ReflectHelper.java +++ b/src/nl/astraeus/jdbc/util/ReflectHelper.java @@ -9,17 +9,12 @@ import java.util.List; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 10/16/13 * Time: 4:49 PM */ public class ReflectHelper { - private final static Logger logger = LoggerFactory.getLogger(ReflectHelper.class); - private final static ReflectHelper instance = new ReflectHelper(); public static ReflectHelper get() { diff --git a/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java b/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java index 555b1d3..a70febc 100644 --- a/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java +++ b/src/nl/astraeus/jdbc/web/JdbcStatsMapping.java @@ -9,14 +9,12 @@ import nl.astraeus.jdbc.web.page.ShowStacktrace; import nl.astraeus.jdbc.web.page.TransactionDetail; import nl.astraeus.jdbc.web.page.TransactionOverview; -import nl.astraeus.web.page.Page; -import nl.astraeus.web.page.PageMapping; /** * Date: 11/24/13 * Time: 10:27 AM */ -public enum JdbcStatsMapping implements PageMapping { +public enum JdbcStatsMapping { QUERIES("queries", QueryOverview.class), QUERY("query", QueryDetail.class), @@ -36,8 +34,8 @@ MAIN("", QueryOverview.class), ; - private String uri; - private Class cls; + private final String uri; + private final Class cls; private JdbcStatsMapping(String uri, Class cls) { this.uri = uri; @@ -48,8 +46,8 @@ return uri; } - public Class getPage() { - return (Class) cls; + public Class getPage() { + return cls; } } diff --git a/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java b/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java index b05e76a..36b1819 100644 --- a/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java +++ b/src/nl/astraeus/jdbc/web/JdbcStatsMappingProvider.java @@ -1,15 +1,12 @@ package nl.astraeus.jdbc.web; -import nl.astraeus.web.page.MappingProvider; -import nl.astraeus.web.page.PageMapping; - /** * Date: 11/24/13 * Time: 10:24 AM */ -public class JdbcStatsMappingProvider implements MappingProvider { +public class JdbcStatsMappingProvider { - public PageMapping getMapping(String uri) { + public JdbcStatsMapping getMapping(String uri) { for (JdbcStatsMapping mapping : JdbcStatsMapping.values()) { if (uri.startsWith(mapping.getUri())) { return mapping; @@ -19,11 +16,12 @@ return null; } - public PageMapping getLoginPage() { + public JdbcStatsMapping getLoginPage() { return JdbcStatsMapping.LOGIN; } - public PageMapping get404Page() { + public JdbcStatsMapping get404Page() { return JdbcStatsMapping.NOTFOUND; } + } diff --git a/src/nl/astraeus/jdbc/web/NanoHttpdSimpleWeb.java b/src/nl/astraeus/jdbc/web/NanoHttpdSimpleWeb.java new file mode 100644 index 0000000..393445e --- /dev/null +++ b/src/nl/astraeus/jdbc/web/NanoHttpdSimpleWeb.java @@ -0,0 +1,56 @@ +package nl.astraeus.jdbc.web; + +import fi.iki.elonen.NanoHTTPD; + +public class NanoHttpdSimpleWeb extends NanoHTTPD { + private JdbcStatsMappingProvider mappingProvider; + + public NanoHttpdSimpleWeb(int port, JdbcStatsMappingProvider mappingProvider) { + super(port); + + this.mappingProvider = mappingProvider; + } + + @Override + public Response serve(IHTTPSession session) { + String uri = session.getUri(); + +/* try { + PageFinder finder = new PageFinder(uri, mappingProvider); + + Map files = new HashMap(); + session.parseBody(files); + + NanoHttpdRequestWrapper wrapper = new NanoHttpdRequestWrapper(getListeningPort(), session); + + RequestWrapperHolder.set(wrapper); + + Page page = finder.findPage(); + + ByteArrayOutputStream out = new ByteArrayOutputStream(); + + page.execute(session.getMethod(), out, mappingProvider.getLoginPage().getUri()); + + out.close(); + + byte[] buffer = out.toByteArray(); + + ByteArrayInputStream in = new ByteArrayInputStream(buffer); + // todo: mimetypes + Response response = new Response(wrapper.getStatus(), wrapper.getContentType(), in, -1); + for (Map.Entry entry : wrapper.getResponseHeaders().entrySet()) { + response.addHeader(entry.getKey(), entry.getValue()); + } + return response; + } catch (Exception e) { + logger.warn(e.getMessage(), e); + + throw new IllegalStateException(e); + } finally { + RequestWrapperHolder.remove(); + }*/ + + return newFixedLengthResponse("Ok"); + } + +} \ No newline at end of file diff --git a/src/nl/astraeus/jdbc/web/model/Settings.java b/src/nl/astraeus/jdbc/web/model/Settings.java index 043ca8a..7750833 100644 --- a/src/nl/astraeus/jdbc/web/model/Settings.java +++ b/src/nl/astraeus/jdbc/web/model/Settings.java @@ -1,16 +1,11 @@ package nl.astraeus.jdbc.web.model; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/22/12 * Time: 1:53 PM */ public class Settings { - private final static Logger logger = LoggerFactory.getLogger(Settings.class); - private final static String NUMBER_OF_QUERIES = "numberOfQueries"; private final static String LOG_STACKTRACES = "logStacktraces"; private final static String FORMATTED_QUERIES = "formattedQueries"; diff --git a/src/nl/astraeus/jdbc/web/page/FooterPage.java b/src/nl/astraeus/jdbc/web/page/FooterPage.java index fcf9931..c09b12c 100644 --- a/src/nl/astraeus/jdbc/web/page/FooterPage.java +++ b/src/nl/astraeus/jdbc/web/page/FooterPage.java @@ -1,7 +1,5 @@ package nl.astraeus.jdbc.web.page; -import nl.astraeus.web.page.TemplatePage; - /** * Date: 11/17/13 * Time: 2:31 PM diff --git a/src/nl/astraeus/jdbc/web/page/HeaderPage.java b/src/nl/astraeus/jdbc/web/page/HeaderPage.java index 2868ecc..0dceb73 100644 --- a/src/nl/astraeus/jdbc/web/page/HeaderPage.java +++ b/src/nl/astraeus/jdbc/web/page/HeaderPage.java @@ -1,7 +1,5 @@ package nl.astraeus.jdbc.web.page; -import nl.astraeus.web.page.TemplatePage; - /** * Date: 11/17/13 * Time: 2:31 PM diff --git a/src/nl/astraeus/jdbc/web/page/JvmStats.html b/src/nl/astraeus/jdbc/web/page/JvmStats.html index d38f031..98537e0 100644 --- a/src/nl/astraeus/jdbc/web/page/JvmStats.html +++ b/src/nl/astraeus/jdbc/web/page/JvmStats.html @@ -52,8 +52,6 @@ ${sample.location} ${sample.count} ${/if} - - ${/each} diff --git a/src/nl/astraeus/jdbc/web/page/Resources.java b/src/nl/astraeus/jdbc/web/page/Resources.java index 2065c73..70f0fd7 100644 --- a/src/nl/astraeus/jdbc/web/page/Resources.java +++ b/src/nl/astraeus/jdbc/web/page/Resources.java @@ -5,14 +5,13 @@ import java.io.OutputStream; import nl.astraeus.jdbc.util.IOUtils; -import nl.astraeus.web.page.Page; /** * User: rnentjes * Date: 3/28/12 * Time: 3:05 PM */ -public class Resources extends Page { +public class Resources extends TemplatePage { private long startup = System.currentTimeMillis(); @@ -27,7 +26,7 @@ } @Override - public void render(OutputStream out) throws IOException { + public void render(OutputStream out) { StringBuilder uriBuilder = new StringBuilder("nl/astraeus/jdbc/web/resources"); for (String part : parts) { @@ -59,8 +58,14 @@ setHeader("ETag", Long.toHexString(startup)); IOUtils.copy(in, out); + } catch(IOException e) { + throw new IllegalStateException(e); } finally { - in.close(); + try { + in.close(); + } catch(IOException e) { + throw new IllegalStateException(e); + } } } } diff --git a/src/nl/astraeus/jdbc/web/page/ServerInfo.java b/src/nl/astraeus/jdbc/web/page/ServerInfo.java index 5abefc7..55f6503 100644 --- a/src/nl/astraeus/jdbc/web/page/ServerInfo.java +++ b/src/nl/astraeus/jdbc/web/page/ServerInfo.java @@ -1,16 +1,11 @@ package nl.astraeus.jdbc.web.page; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * User: rnentjes * Date: 4/12/12 * Time: 9:16 PM */ public class ServerInfo extends StatsPage { - private static Logger logger = LoggerFactory.getLogger(ServerInfo.class); - @Override public void get() { if ("select".equals(getParameter("action"))) { diff --git a/src/nl/astraeus/jdbc/web/page/SettingsOverview.java b/src/nl/astraeus/jdbc/web/page/SettingsOverview.java index 8a5d182..2badb0f 100644 --- a/src/nl/astraeus/jdbc/web/page/SettingsOverview.java +++ b/src/nl/astraeus/jdbc/web/page/SettingsOverview.java @@ -2,7 +2,6 @@ import nl.astraeus.jdbc.Driver; import nl.astraeus.jdbc.web.model.Settings; -import nl.astraeus.web.page.Message; /** * User: rnentjes diff --git a/src/nl/astraeus/jdbc/web/page/TemplatePage.java b/src/nl/astraeus/jdbc/web/page/TemplatePage.java new file mode 100644 index 0000000..cdbe8b6 --- /dev/null +++ b/src/nl/astraeus/jdbc/web/page/TemplatePage.java @@ -0,0 +1,36 @@ +package nl.astraeus.jdbc.web.page; + +import java.io.OutputStream; + +public class TemplatePage { + + private String contentType = "text/html"; + private int responseCode = 200; + + public void setHeader(String name, String value) { + + } + + public void setContentType(String contentType) { + this.contentType = contentType; + } + public void sendResponse(int code) { + responseCode = code; + } + + public void get() { + sendResponse(501); + } + + public void post() { + sendResponse(501); + } + + public void render(OutputStream out) { + + } + + private String getParameter(String queries) { + return ""; + } +}