최초 커밋, 멀티 RDBMS 적용 추가, 통신 오류 수정중
@4710529d023012fdcc96db98f4cb8ae9c9344a53
+++ HELP.md
... | ... | @@ -0,0 +1,26 @@ |
| 1 | +# Getting Started | |
| 2 | + | |
| 3 | +### Reference Documentation | |
| 4 | + | |
| 5 | +For further reference, please consider the following sections: | |
| 6 | + | |
| 7 | +* [Official Gradle documentation](https://docs.gradle.org) | |
| 8 | +* [Spring Boot Gradle Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/3.3.1/gradle-plugin/reference/html/) | |
| 9 | +* [Create an OCI image](https://docs.spring.io/spring-boot/docs/3.3.1/gradle-plugin/reference/html/#build-image) | |
| 10 | +* [Spring Configuration Processor](https://docs.spring.io/spring-boot/docs/3.3.1/reference/htmlsingle/index.html#appendix.configuration-metadata.annotation-processor) | |
| 11 | +* [Spring Boot DevTools](https://docs.spring.io/spring-boot/docs/3.3.1/reference/htmlsingle/index.html#using.devtools) | |
| 12 | +* [MyBatis Framework](https://mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/) | |
| 13 | + | |
| 14 | +### Guides | |
| 15 | + | |
| 16 | +The following guides illustrate how to use some features concretely: | |
| 17 | + | |
| 18 | +* [MyBatis Quick Start](https://github.com/mybatis/spring-boot-starter/wiki/Quick-Start) | |
| 19 | +* [Accessing data with MySQL](https://spring.io/guides/gs/accessing-data-mysql/) | |
| 20 | + | |
| 21 | +### Additional Links | |
| 22 | + | |
| 23 | +These additional references should also help you: | |
| 24 | + | |
| 25 | +* [Gradle Build Scans – insights for your project's build](https://scans.gradle.com#gradle) | |
| 26 | + |
+++ build.gradle
... | ... | @@ -0,0 +1,50 @@ |
| 1 | +plugins { | |
| 2 | + id 'java' | |
| 3 | + id 'org.springframework.boot' version '3.3.1' | |
| 4 | + id 'io.spring.dependency-management' version '1.1.5' | |
| 5 | +} | |
| 6 | + | |
| 7 | +group = 'com.munjaon' | |
| 8 | +version = '0.0.1-SNAPSHOT' | |
| 9 | + | |
| 10 | +java { | |
| 11 | + toolchain { | |
| 12 | + languageVersion = JavaLanguageVersion.of(17) | |
| 13 | + } | |
| 14 | +} | |
| 15 | + | |
| 16 | +configurations { | |
| 17 | + compileOnly { | |
| 18 | + extendsFrom annotationProcessor | |
| 19 | + } | |
| 20 | +} | |
| 21 | + | |
| 22 | +repositories { | |
| 23 | + mavenCentral() | |
| 24 | +} | |
| 25 | + | |
| 26 | +dependencies { | |
| 27 | + implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:3.0.3' | |
| 28 | + compileOnly 'org.projectlombok:lombok' | |
| 29 | + developmentOnly 'org.springframework.boot:spring-boot-devtools' | |
| 30 | + runtimeOnly 'org.mariadb.jdbc:mariadb-java-client' | |
| 31 | + annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' | |
| 32 | + annotationProcessor 'org.projectlombok:lombok' | |
| 33 | + testImplementation 'org.springframework.boot:spring-boot-starter-test' | |
| 34 | + testImplementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter-test:3.0.3' | |
| 35 | + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' | |
| 36 | + // https://mvnrepository.com/artifact/com.zaxxer/HikariCP | |
| 37 | + implementation 'com.zaxxer:HikariCP:4.0.3' | |
| 38 | + // https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple | |
| 39 | + implementation 'com.googlecode.json-simple:json-simple:1.1.1' | |
| 40 | + // https://mvnrepository.com/artifact/commons-beanutils/commons-beanutils | |
| 41 | + implementation 'commons-beanutils:commons-beanutils:1.9.4' | |
| 42 | + // https://mvnrepository.com/artifact/org.jdom/jdom2 | |
| 43 | + implementation 'org.jdom:jdom2:2.0.6.1' | |
| 44 | + // https://mvnrepository.com/artifact/org.apache.commons/commons-configuration2 | |
| 45 | + implementation 'org.apache.commons:commons-configuration2:2.10.1' | |
| 46 | +} | |
| 47 | + | |
| 48 | +tasks.named('test') { | |
| 49 | + useJUnitPlatform() | |
| 50 | +} |
+++ gradle/wrapper/gradle-wrapper.jar
| Binary file is not shown |
+++ gradle/wrapper/gradle-wrapper.properties
... | ... | @@ -0,0 +1,7 @@ |
| 1 | +distributionBase=GRADLE_USER_HOME | |
| 2 | +distributionPath=wrapper/dists | |
| 3 | +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip | |
| 4 | +networkTimeout=10000 | |
| 5 | +validateDistributionUrl=true | |
| 6 | +zipStoreBase=GRADLE_USER_HOME | |
| 7 | +zipStorePath=wrapper/dists |
+++ gradlew
... | ... | @@ -0,0 +1,249 @@ |
| 1 | +#!/bin/sh | |
| 2 | + | |
| 3 | +# | |
| 4 | +# Copyright © 2015-2021 the original authors. | |
| 5 | +# | |
| 6 | +# Licensed under the Apache License, Version 2.0 (the "License"); | |
| 7 | +# you may not use this file except in compliance with the License. | |
| 8 | +# You may obtain a copy of the License at | |
| 9 | +# | |
| 10 | +# https://www.apache.org/licenses/LICENSE-2.0 | |
| 11 | +# | |
| 12 | +# Unless required by applicable law or agreed to in writing, software | |
| 13 | +# distributed under the License is distributed on an "AS IS" BASIS, | |
| 14 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 15 | +# See the License for the specific language governing permissions and | |
| 16 | +# limitations under the License. | |
| 17 | +# | |
| 18 | + | |
| 19 | +############################################################################## | |
| 20 | +# | |
| 21 | +# Gradle start up script for POSIX generated by Gradle. | |
| 22 | +# | |
| 23 | +# Important for running: | |
| 24 | +# | |
| 25 | +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is | |
| 26 | +# noncompliant, but you have some other compliant shell such as ksh or | |
| 27 | +# bash, then to run this script, type that shell name before the whole | |
| 28 | +# command line, like: | |
| 29 | +# | |
| 30 | +# ksh Gradle | |
| 31 | +# | |
| 32 | +# Busybox and similar reduced shells will NOT work, because this script | |
| 33 | +# requires all of these POSIX shell features: | |
| 34 | +# * functions; | |
| 35 | +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», | |
| 36 | +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; | |
| 37 | +# * compound commands having a testable exit status, especially «case»; | |
| 38 | +# * various built-in commands including «command», «set», and «ulimit». | |
| 39 | +# | |
| 40 | +# Important for patching: | |
| 41 | +# | |
| 42 | +# (2) This script targets any POSIX shell, so it avoids extensions provided | |
| 43 | +# by Bash, Ksh, etc; in particular arrays are avoided. | |
| 44 | +# | |
| 45 | +# The "traditional" practice of packing multiple parameters into a | |
| 46 | +# space-separated string is a well documented source of bugs and security | |
| 47 | +# problems, so this is (mostly) avoided, by progressively accumulating | |
| 48 | +# options in "$@", and eventually passing that to Java. | |
| 49 | +# | |
| 50 | +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, | |
| 51 | +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; | |
| 52 | +# see the in-line comments for details. | |
| 53 | +# | |
| 54 | +# There are tweaks for specific operating systems such as AIX, CygWin, | |
| 55 | +# Darwin, MinGW, and NonStop. | |
| 56 | +# | |
| 57 | +# (3) This script is generated from the Groovy template | |
| 58 | +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt | |
| 59 | +# within the Gradle project. | |
| 60 | +# | |
| 61 | +# You can find Gradle at https://github.com/gradle/gradle/. | |
| 62 | +# | |
| 63 | +############################################################################## | |
| 64 | + | |
| 65 | +# Attempt to set APP_HOME | |
| 66 | + | |
| 67 | +# Resolve links: $0 may be a link | |
| 68 | +app_path=$0 | |
| 69 | + | |
| 70 | +# Need this for daisy-chained symlinks. | |
| 71 | +while | |
| 72 | + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path | |
| 73 | + [ -h "$app_path" ] | |
| 74 | +do | |
| 75 | + ls=$( ls -ld "$app_path" ) | |
| 76 | + link=${ls#*' -> '} | |
| 77 | + case $link in #( | |
| 78 | + /*) app_path=$link ;; #( | |
| 79 | + *) app_path=$APP_HOME$link ;; | |
| 80 | + esac | |
| 81 | +done | |
| 82 | + | |
| 83 | +# This is normally unused | |
| 84 | +# shellcheck disable=SC2034 | |
| 85 | +APP_BASE_NAME=${0##*/} | |
| 86 | +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) | |
| 87 | +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit | |
| 88 | + | |
| 89 | +# Use the maximum available, or set MAX_FD != -1 to use that value. | |
| 90 | +MAX_FD=maximum | |
| 91 | + | |
| 92 | +warn () { | |
| 93 | + echo "$*" | |
| 94 | +} >&2 | |
| 95 | + | |
| 96 | +die () { | |
| 97 | + echo | |
| 98 | + echo "$*" | |
| 99 | + echo | |
| 100 | + exit 1 | |
| 101 | +} >&2 | |
| 102 | + | |
| 103 | +# OS specific support (must be 'true' or 'false'). | |
| 104 | +cygwin=false | |
| 105 | +msys=false | |
| 106 | +darwin=false | |
| 107 | +nonstop=false | |
| 108 | +case "$( uname )" in #( | |
| 109 | + CYGWIN* ) cygwin=true ;; #( | |
| 110 | + Darwin* ) darwin=true ;; #( | |
| 111 | + MSYS* | MINGW* ) msys=true ;; #( | |
| 112 | + NONSTOP* ) nonstop=true ;; | |
| 113 | +esac | |
| 114 | + | |
| 115 | +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar | |
| 116 | + | |
| 117 | + | |
| 118 | +# Determine the Java command to use to start the JVM. | |
| 119 | +if [ -n "$JAVA_HOME" ] ; then | |
| 120 | + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then | |
| 121 | + # IBM's JDK on AIX uses strange locations for the executables | |
| 122 | + JAVACMD=$JAVA_HOME/jre/sh/java | |
| 123 | + else | |
| 124 | + JAVACMD=$JAVA_HOME/bin/java | |
| 125 | + fi | |
| 126 | + if [ ! -x "$JAVACMD" ] ; then | |
| 127 | + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME | |
| 128 | + | |
| 129 | +Please set the JAVA_HOME variable in your environment to match the | |
| 130 | +location of your Java installation." | |
| 131 | + fi | |
| 132 | +else | |
| 133 | + JAVACMD=java | |
| 134 | + if ! command -v java >/dev/null 2>&1 | |
| 135 | + then | |
| 136 | + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. | |
| 137 | + | |
| 138 | +Please set the JAVA_HOME variable in your environment to match the | |
| 139 | +location of your Java installation." | |
| 140 | + fi | |
| 141 | +fi | |
| 142 | + | |
| 143 | +# Increase the maximum file descriptors if we can. | |
| 144 | +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then | |
| 145 | + case $MAX_FD in #( | |
| 146 | + max*) | |
| 147 | + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. | |
| 148 | + # shellcheck disable=SC2039,SC3045 | |
| 149 | + MAX_FD=$( ulimit -H -n ) || | |
| 150 | + warn "Could not query maximum file descriptor limit" | |
| 151 | + esac | |
| 152 | + case $MAX_FD in #( | |
| 153 | + '' | soft) :;; #( | |
| 154 | + *) | |
| 155 | + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. | |
| 156 | + # shellcheck disable=SC2039,SC3045 | |
| 157 | + ulimit -n "$MAX_FD" || | |
| 158 | + warn "Could not set maximum file descriptor limit to $MAX_FD" | |
| 159 | + esac | |
| 160 | +fi | |
| 161 | + | |
| 162 | +# Collect all arguments for the java command, stacking in reverse order: | |
| 163 | +# * args from the command line | |
| 164 | +# * the main class name | |
| 165 | +# * -classpath | |
| 166 | +# * -D...appname settings | |
| 167 | +# * --module-path (only if needed) | |
| 168 | +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. | |
| 169 | + | |
| 170 | +# For Cygwin or MSYS, switch paths to Windows format before running java | |
| 171 | +if "$cygwin" || "$msys" ; then | |
| 172 | + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) | |
| 173 | + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) | |
| 174 | + | |
| 175 | + JAVACMD=$( cygpath --unix "$JAVACMD" ) | |
| 176 | + | |
| 177 | + # Now convert the arguments - kludge to limit ourselves to /bin/sh | |
| 178 | + for arg do | |
| 179 | + if | |
| 180 | + case $arg in #( | |
| 181 | + -*) false ;; # don't mess with options #( | |
| 182 | + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath | |
| 183 | + [ -e "$t" ] ;; #( | |
| 184 | + *) false ;; | |
| 185 | + esac | |
| 186 | + then | |
| 187 | + arg=$( cygpath --path --ignore --mixed "$arg" ) | |
| 188 | + fi | |
| 189 | + # Roll the args list around exactly as many times as the number of | |
| 190 | + # args, so each arg winds up back in the position where it started, but | |
| 191 | + # possibly modified. | |
| 192 | + # | |
| 193 | + # NB: a `for` loop captures its iteration list before it begins, so | |
| 194 | + # changing the positional parameters here affects neither the number of | |
| 195 | + # iterations, nor the values presented in `arg`. | |
| 196 | + shift # remove old arg | |
| 197 | + set -- "$@" "$arg" # push replacement arg | |
| 198 | + done | |
| 199 | +fi | |
| 200 | + | |
| 201 | + | |
| 202 | +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. | |
| 203 | +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' | |
| 204 | + | |
| 205 | +# Collect all arguments for the java command: | |
| 206 | +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, | |
| 207 | +# and any embedded shellness will be escaped. | |
| 208 | +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be | |
| 209 | +# treated as '${Hostname}' itself on the command line. | |
| 210 | + | |
| 211 | +set -- \ | |
| 212 | + "-Dorg.gradle.appname=$APP_BASE_NAME" \ | |
| 213 | + -classpath "$CLASSPATH" \ | |
| 214 | + org.gradle.wrapper.GradleWrapperMain \ | |
| 215 | + "$@" | |
| 216 | + | |
| 217 | +# Stop when "xargs" is not available. | |
| 218 | +if ! command -v xargs >/dev/null 2>&1 | |
| 219 | +then | |
| 220 | + die "xargs is not available" | |
| 221 | +fi | |
| 222 | + | |
| 223 | +# Use "xargs" to parse quoted args. | |
| 224 | +# | |
| 225 | +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. | |
| 226 | +# | |
| 227 | +# In Bash we could simply go: | |
| 228 | +# | |
| 229 | +# readarray ARGS < <( xargs -n1 <<<"$var" ) && | |
| 230 | +# set -- "${ARGS[@]}" "$@" | |
| 231 | +# | |
| 232 | +# but POSIX shell has neither arrays nor command substitution, so instead we | |
| 233 | +# post-process each arg (as a line of input to sed) to backslash-escape any | |
| 234 | +# character that might be a shell metacharacter, then use eval to reverse | |
| 235 | +# that process (while maintaining the separation between arguments), and wrap | |
| 236 | +# the whole thing up as a single "set" statement. | |
| 237 | +# | |
| 238 | +# This will of course break if any of these variables contains a newline or | |
| 239 | +# an unmatched quote. | |
| 240 | +# | |
| 241 | + | |
| 242 | +eval "set -- $( | |
| 243 | + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | | |
| 244 | + xargs -n1 | | |
| 245 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | | |
| 246 | + tr '\n' ' ' | |
| 247 | + )" '"$@"' | |
| 248 | + | |
| 249 | +exec "$JAVACMD" "$@" |
+++ gradlew.bat
... | ... | @@ -0,0 +1,92 @@ |
| 1 | +@rem | |
| 2 | +@rem Copyright 2015 the original author or authors. | |
| 3 | +@rem | |
| 4 | +@rem Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | +@rem you may not use this file except in compliance with the License. | |
| 6 | +@rem You may obtain a copy of the License at | |
| 7 | +@rem | |
| 8 | +@rem https://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | +@rem | |
| 10 | +@rem Unless required by applicable law or agreed to in writing, software | |
| 11 | +@rem distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | +@rem See the License for the specific language governing permissions and | |
| 14 | +@rem limitations under the License. | |
| 15 | +@rem | |
| 16 | + | |
| 17 | +@if "%DEBUG%"=="" @echo off | |
| 18 | +@rem ########################################################################## | |
| 19 | +@rem | |
| 20 | +@rem Gradle startup script for Windows | |
| 21 | +@rem | |
| 22 | +@rem ########################################################################## | |
| 23 | + | |
| 24 | +@rem Set local scope for the variables with windows NT shell | |
| 25 | +if "%OS%"=="Windows_NT" setlocal | |
| 26 | + | |
| 27 | +set DIRNAME=%~dp0 | |
| 28 | +if "%DIRNAME%"=="" set DIRNAME=. | |
| 29 | +@rem This is normally unused | |
| 30 | +set APP_BASE_NAME=%~n0 | |
| 31 | +set APP_HOME=%DIRNAME% | |
| 32 | + | |
| 33 | +@rem Resolve any "." and ".." in APP_HOME to make it shorter. | |
| 34 | +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi | |
| 35 | + | |
| 36 | +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. | |
| 37 | +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" | |
| 38 | + | |
| 39 | +@rem Find java.exe | |
| 40 | +if defined JAVA_HOME goto findJavaFromJavaHome | |
| 41 | + | |
| 42 | +set JAVA_EXE=java.exe | |
| 43 | +%JAVA_EXE% -version >NUL 2>&1 | |
| 44 | +if %ERRORLEVEL% equ 0 goto execute | |
| 45 | + | |
| 46 | +echo. 1>&2 | |
| 47 | +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 | |
| 48 | +echo. 1>&2 | |
| 49 | +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 | |
| 50 | +echo location of your Java installation. 1>&2 | |
| 51 | + | |
| 52 | +goto fail | |
| 53 | + | |
| 54 | +:findJavaFromJavaHome | |
| 55 | +set JAVA_HOME=%JAVA_HOME:"=% | |
| 56 | +set JAVA_EXE=%JAVA_HOME%/bin/java.exe | |
| 57 | + | |
| 58 | +if exist "%JAVA_EXE%" goto execute | |
| 59 | + | |
| 60 | +echo. 1>&2 | |
| 61 | +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 | |
| 62 | +echo. 1>&2 | |
| 63 | +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 | |
| 64 | +echo location of your Java installation. 1>&2 | |
| 65 | + | |
| 66 | +goto fail | |
| 67 | + | |
| 68 | +:execute | |
| 69 | +@rem Setup the command line | |
| 70 | + | |
| 71 | +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar | |
| 72 | + | |
| 73 | + | |
| 74 | +@rem Execute Gradle | |
| 75 | +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* | |
| 76 | + | |
| 77 | +:end | |
| 78 | +@rem End local scope for the variables with windows NT shell | |
| 79 | +if %ERRORLEVEL% equ 0 goto mainEnd | |
| 80 | + | |
| 81 | +:fail | |
| 82 | +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of | |
| 83 | +rem the _cmd.exe /c_ return code! | |
| 84 | +set EXIT_CODE=%ERRORLEVEL% | |
| 85 | +if %EXIT_CODE% equ 0 set EXIT_CODE=1 | |
| 86 | +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% | |
| 87 | +exit /b %EXIT_CODE% | |
| 88 | + | |
| 89 | +:mainEnd | |
| 90 | +if "%OS%"=="Windows_NT" endlocal | |
| 91 | + | |
| 92 | +:omega |
+++ settings.gradle
... | ... | @@ -0,0 +1,1 @@ |
| 1 | +rootProject.name = 'client_agent' |
+++ src/main/java/com/munjaon/client/MunjaonClientApplication.java
... | ... | @@ -0,0 +1,20 @@ |
| 1 | +package com.munjaon.client; | |
| 2 | + | |
| 3 | +import com.munjaon.client.config.ServerConfig; | |
| 4 | +import lombok.RequiredArgsConstructor; | |
| 5 | +import lombok.extern.slf4j.Slf4j; | |
| 6 | +import org.springframework.boot.SpringApplication; | |
| 7 | +import org.springframework.boot.autoconfigure.SpringBootApplication; | |
| 8 | +import org.springframework.boot.builder.SpringApplicationBuilder; | |
| 9 | +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; | |
| 10 | +import org.springframework.scheduling.annotation.EnableScheduling; | |
| 11 | + | |
| 12 | +@Slf4j | |
| 13 | +@EnableScheduling | |
| 14 | +@SpringBootApplication | |
| 15 | +public class MunjaonClientApplication { | |
| 16 | + | |
| 17 | + public static void main(String[] args) { | |
| 18 | + SpringApplication.run(MunjaonClientApplication.class, args); | |
| 19 | + } | |
| 20 | +} |
+++ src/main/java/com/munjaon/client/config/DataSourceConfig.java
... | ... | @@ -0,0 +1,67 @@ |
| 1 | +package com.munjaon.client.config; | |
| 2 | + | |
| 3 | +import lombok.Getter; | |
| 4 | +import lombok.RequiredArgsConstructor; | |
| 5 | +import lombok.extern.slf4j.Slf4j; | |
| 6 | +import org.apache.commons.configuration2.ex.ConfigurationException; | |
| 7 | +import org.apache.ibatis.session.SqlSessionFactory; | |
| 8 | +import org.mybatis.spring.SqlSessionFactoryBean; | |
| 9 | +import org.mybatis.spring.SqlSessionTemplate; | |
| 10 | +import org.mybatis.spring.annotation.MapperScan; | |
| 11 | +import org.mybatis.spring.boot.autoconfigure.SpringBootVFS; | |
| 12 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 13 | +import org.springframework.boot.context.properties.ConfigurationProperties; | |
| 14 | +import org.springframework.boot.jdbc.DataSourceBuilder; | |
| 15 | +import org.springframework.context.ApplicationContext; | |
| 16 | +import org.springframework.context.annotation.Bean; | |
| 17 | +import org.springframework.context.annotation.Configuration; | |
| 18 | +import org.springframework.context.annotation.Primary; | |
| 19 | +import org.springframework.core.io.support.PathMatchingResourcePatternResolver; | |
| 20 | +import org.springframework.transaction.annotation.EnableTransactionManagement; | |
| 21 | + | |
| 22 | +import javax.sql.DataSource; | |
| 23 | + | |
| 24 | +@Slf4j | |
| 25 | +@Configuration | |
| 26 | +@RequiredArgsConstructor | |
| 27 | +@EnableTransactionManagement | |
| 28 | +@MapperScan(basePackages= "com.munjaon.client.**.mapper") | |
| 29 | +public class DataSourceConfig { | |
| 30 | + @Autowired | |
| 31 | + private ApplicationContext applicationContext; | |
| 32 | + private final ServerConfig serverConfig; | |
| 33 | + | |
| 34 | + @Primary | |
| 35 | + @Bean(name = "datasource") | |
| 36 | + public DataSource dataSource() throws ConfigurationException { | |
| 37 | + String dbms = serverConfig.getString("DB.DBMS"); | |
| 38 | + System.out.println("MARIADB.DRIVER : " + serverConfig.getString(dbms + ".DRIVER")); | |
| 39 | + System.out.println("MARIADB.URL : " + serverConfig.getString(dbms + ".URL")); | |
| 40 | + System.out.println("MARIADB.USER : " + serverConfig.getString(dbms + ".USER")); | |
| 41 | + System.out.println("MARIADB.PASSWORD : " + serverConfig.getString(dbms + ".PASSWORD")); | |
| 42 | + return DataSourceBuilder.create() | |
| 43 | + .driverClassName(serverConfig.getString(dbms + ".DRIVER")) | |
| 44 | + .url(serverConfig.getString(dbms + ".URL")) | |
| 45 | + .username(serverConfig.getString(dbms + ".USER")) | |
| 46 | + .password(serverConfig.getString(dbms + ".PASSWORD")) | |
| 47 | + .build(); | |
| 48 | + } | |
| 49 | + | |
| 50 | + @Primary | |
| 51 | + @Bean(name = "factory") | |
| 52 | + public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception { | |
| 53 | + SqlSessionFactoryBean sqlSessionFactory = new SqlSessionFactoryBean(); | |
| 54 | + sqlSessionFactory.setVfs(SpringBootVFS.class); | |
| 55 | + sqlSessionFactory.setDataSource(dataSource); | |
| 56 | + sqlSessionFactory.setTypeAliasesPackage("com.munjaon.client.**.dto"); | |
| 57 | + sqlSessionFactory.setConfigLocation(applicationContext.getResource("classpath:mybatis-config.xml")); | |
| 58 | + sqlSessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:/sqlmap/**/*.xml")); | |
| 59 | + return sqlSessionFactory.getObject(); | |
| 60 | + } | |
| 61 | + | |
| 62 | + @Primary | |
| 63 | + @Bean(name = "sqlSession") | |
| 64 | + public SqlSessionTemplate sqlSession(SqlSessionFactory sqlSessionFactory) { | |
| 65 | + return new SqlSessionTemplate(sqlSessionFactory); | |
| 66 | + } | |
| 67 | +} |
+++ src/main/java/com/munjaon/client/config/RunnerConfiguration.java
... | ... | @@ -0,0 +1,43 @@ |
| 1 | +package com.munjaon.client.config; | |
| 2 | + | |
| 3 | +import com.munjaon.client.server.service.PropertyLoader; | |
| 4 | +import lombok.RequiredArgsConstructor; | |
| 5 | +import lombok.extern.slf4j.Slf4j; | |
| 6 | +import org.apache.commons.configuration2.ex.ConfigurationException; | |
| 7 | +import org.springframework.boot.CommandLineRunner; | |
| 8 | +import org.springframework.context.annotation.Bean; | |
| 9 | +import org.springframework.context.annotation.Configuration; | |
| 10 | +import org.springframework.core.annotation.Order; | |
| 11 | + | |
| 12 | +@Slf4j | |
| 13 | +@Configuration | |
| 14 | +@RequiredArgsConstructor | |
| 15 | +public class RunnerConfiguration { | |
| 16 | + private final ServerConfig serverConfig; | |
| 17 | + | |
| 18 | + @Bean | |
| 19 | + @Order(1) | |
| 20 | + public CommandLineRunner getRunnerBeanForProperty() { | |
| 21 | + System.setProperty("PROPS", serverConfig.getServerProperyFile()); | |
| 22 | + System.setProperty("ROOTPATH", serverConfig.getServerRootPath()); | |
| 23 | + PropertyLoader.load(); | |
| 24 | + try { | |
| 25 | + String[] array = serverConfig.getStringArray("test.list"); | |
| 26 | + if (array != null && array.length > 0) { | |
| 27 | + for (String s : array) { | |
| 28 | + System.out.println("List : " + s); | |
| 29 | + } | |
| 30 | + } | |
| 31 | + } catch (ConfigurationException e) { | |
| 32 | + throw new RuntimeException(e); | |
| 33 | + } | |
| 34 | + return args -> System.out.println("Runner Bean #1 : " + serverConfig.getServerProperyFile()); | |
| 35 | + } | |
| 36 | + | |
| 37 | + @Bean | |
| 38 | + @Order(2) | |
| 39 | + public CommandLineRunner getRunnerBeanForSmsQueue() { | |
| 40 | + | |
| 41 | + return args -> System.out.println("Runner Bean #2"); | |
| 42 | + } | |
| 43 | +} |
+++ src/main/java/com/munjaon/client/config/ServerConfig.java
... | ... | @@ -0,0 +1,74 @@ |
| 1 | +package com.munjaon.client.config; | |
| 2 | + | |
| 3 | +import jakarta.annotation.PostConstruct; | |
| 4 | +import lombok.Getter; | |
| 5 | +import lombok.extern.slf4j.Slf4j; | |
| 6 | +import org.apache.commons.configuration2.PropertiesConfiguration; | |
| 7 | +import org.apache.commons.configuration2.builder.ConfigurationBuilderEvent; | |
| 8 | +import org.apache.commons.configuration2.builder.ReloadingFileBasedConfigurationBuilder; | |
| 9 | +import org.apache.commons.configuration2.builder.fluent.Parameters; | |
| 10 | +import org.apache.commons.configuration2.event.Event; | |
| 11 | +import org.apache.commons.configuration2.event.EventListener; | |
| 12 | +import org.apache.commons.configuration2.ex.ConfigurationException; | |
| 13 | +import org.apache.commons.configuration2.reloading.PeriodicReloadingTrigger; | |
| 14 | +import org.springframework.beans.factory.annotation.Value; | |
| 15 | +import org.springframework.stereotype.Component; | |
| 16 | + | |
| 17 | +import java.io.File; | |
| 18 | +import java.util.concurrent.TimeUnit; | |
| 19 | + | |
| 20 | +@Slf4j | |
| 21 | +@Component | |
| 22 | +public class ServerConfig { | |
| 23 | + @Getter | |
| 24 | +// @Value("${agent.server-property-file}") | |
| 25 | + private String serverProperyFile; | |
| 26 | + | |
| 27 | + @Getter | |
| 28 | + @Value("${agent.root-path}") | |
| 29 | + private String serverRootPath; | |
| 30 | + | |
| 31 | + private ReloadingFileBasedConfigurationBuilder<PropertiesConfiguration> builder; | |
| 32 | + | |
| 33 | + @PostConstruct | |
| 34 | + void init() throws ConfigurationException { | |
| 35 | +// this.serverRootPath = System.getProperty("SERVICE_HOME"); | |
| 36 | + this.serverProperyFile = serverRootPath + File.separator + "config" + File.separator + "munjaonAgent.conf"; | |
| 37 | + log.debug("serverProperyFile : {}", serverProperyFile); | |
| 38 | + log.debug("serverProperyFile : {}", serverProperyFile); | |
| 39 | + log.debug("serverProperyFile : {}", serverProperyFile); | |
| 40 | + System.out.println(serverProperyFile); | |
| 41 | + System.out.println(serverProperyFile); | |
| 42 | + System.out.println(serverProperyFile); | |
| 43 | + System.out.println(serverProperyFile); | |
| 44 | + System.out.println(serverProperyFile); | |
| 45 | + builder = new ReloadingFileBasedConfigurationBuilder<>(PropertiesConfiguration.class).configure(new Parameters().fileBased().setFile(new File(serverProperyFile))); | |
| 46 | + | |
| 47 | + builder.addEventListener(ConfigurationBuilderEvent.CONFIGURATION_REQUEST, new EventListener<Event>() { | |
| 48 | + @Override | |
| 49 | + public void onEvent(Event event) { | |
| 50 | + log.info("builder.getConfiguration() is Called!!"); | |
| 51 | + } | |
| 52 | + }); | |
| 53 | + | |
| 54 | + PeriodicReloadingTrigger configReloadingTrigger = new PeriodicReloadingTrigger(builder.getReloadingController(), null, 1, TimeUnit.SECONDS); | |
| 55 | + configReloadingTrigger.start(); | |
| 56 | + } | |
| 57 | + | |
| 58 | + public String getString(String key) throws ConfigurationException { | |
| 59 | + return builder.getConfiguration().getString(key); | |
| 60 | + } | |
| 61 | + | |
| 62 | + public int getInt(String key) throws ConfigurationException { | |
| 63 | + return builder.getConfiguration().getInt(key, 3); | |
| 64 | + } | |
| 65 | + | |
| 66 | + public String[] getStringArray(String key) throws ConfigurationException { | |
| 67 | + return getStringArray(key, ","); | |
| 68 | + } | |
| 69 | + | |
| 70 | + public String[] getStringArray(String key, String regExp) throws ConfigurationException { | |
| 71 | + String value = getString(key); | |
| 72 | + return value == null ? null : value.split(regExp); | |
| 73 | + } | |
| 74 | +} |
+++ src/main/java/com/munjaon/client/mariadb/mapper/MariaDBMapper.java
... | ... | @@ -0,0 +1,20 @@ |
| 1 | +package com.munjaon.client.mariadb.mapper; | |
| 2 | + | |
| 3 | +import com.munjaon.client.model.MunjaonMsg; | |
| 4 | +import org.apache.ibatis.annotations.Mapper; | |
| 5 | + | |
| 6 | +import java.util.List; | |
| 7 | + | |
| 8 | +@Mapper | |
| 9 | +public interface MariaDBMapper { | |
| 10 | + String checkTime(); | |
| 11 | + int checkTableForMessage(); | |
| 12 | + int checkTableForLog(); | |
| 13 | + List<MunjaonMsg> selectToDeliver(String msgType); | |
| 14 | + int updateToDeliver(String msgId); | |
| 15 | + int updateToReport(MunjaonMsg params); | |
| 16 | + List<MunjaonMsg> selectToMove(); | |
| 17 | + List<MunjaonMsg> selectToExpire(String expireTime); | |
| 18 | + int insertToLog(String msgId); | |
| 19 | + int deleteFromDeliver(String msgId); | |
| 20 | +} |
+++ src/main/java/com/munjaon/client/mariadb/service/MariaDBService.java
... | ... | @@ -0,0 +1,50 @@ |
| 1 | +package com.munjaon.client.mariadb.service; | |
| 2 | + | |
| 3 | +import com.munjaon.client.mariadb.mapper.MariaDBMapper; | |
| 4 | +import com.munjaon.client.model.MunjaonMsg; | |
| 5 | +import lombok.RequiredArgsConstructor; | |
| 6 | +import lombok.extern.slf4j.Slf4j; | |
| 7 | +import org.springframework.stereotype.Service; | |
| 8 | + | |
| 9 | +import java.util.List; | |
| 10 | + | |
| 11 | +@Slf4j | |
| 12 | +@Service | |
| 13 | +@RequiredArgsConstructor | |
| 14 | +public class MariaDBService { | |
| 15 | + private final MariaDBMapper mariaDBMapper; | |
| 16 | + | |
| 17 | + public boolean checkTableExists() { | |
| 18 | + boolean isExist = false; | |
| 19 | + try { | |
| 20 | + mariaDBMapper.checkTableForMessage(); | |
| 21 | + mariaDBMapper.checkTableForLog(); | |
| 22 | + isExist = true; | |
| 23 | + } catch (Exception e) { | |
| 24 | + log.error("Check table exists error : {}", e); | |
| 25 | + } | |
| 26 | + | |
| 27 | + return isExist; | |
| 28 | + } | |
| 29 | + public List<MunjaonMsg> selectToDeliver(String msgType) { | |
| 30 | + return mariaDBMapper.selectToDeliver(msgType); | |
| 31 | + } | |
| 32 | + public int updateToDeliver(String msgId) { | |
| 33 | + return mariaDBMapper.updateToDeliver(msgId); | |
| 34 | + } | |
| 35 | + public int updateToReport(MunjaonMsg params) { | |
| 36 | + return mariaDBMapper.updateToReport(params); | |
| 37 | + } | |
| 38 | + public List<MunjaonMsg> selectToMove() { | |
| 39 | + return mariaDBMapper.selectToMove(); | |
| 40 | + } | |
| 41 | + public List<MunjaonMsg> selectToExpire(String expireTime) { | |
| 42 | + return mariaDBMapper.selectToExpire(expireTime); | |
| 43 | + } | |
| 44 | + public int insertToLog(String msgId) { | |
| 45 | + return mariaDBMapper.insertToLog(msgId); | |
| 46 | + } | |
| 47 | + public int deleteFromDeliver(String msgId) { | |
| 48 | + return mariaDBMapper.deleteFromDeliver(msgId); | |
| 49 | + } | |
| 50 | +} |
+++ src/main/java/com/munjaon/client/model/MunjaonMsg.java
... | ... | @@ -0,0 +1,26 @@ |
| 1 | +package com.munjaon.client.model; | |
| 2 | + | |
| 3 | +import lombok.Getter; | |
| 4 | +import lombok.Setter; | |
| 5 | +import lombok.ToString; | |
| 6 | + | |
| 7 | +@Getter | |
| 8 | +@Setter | |
| 9 | +@ToString | |
| 10 | +public class MunjaonMsg { | |
| 11 | + private String msgId; | |
| 12 | + private String msgType; | |
| 13 | + private String sendStatus; | |
| 14 | + private String requestDate; | |
| 15 | + private String recvPhone; | |
| 16 | + private String sendPhone; | |
| 17 | + private String subject; | |
| 18 | + private String message; | |
| 19 | + private String telecom; | |
| 20 | + private String filename01; | |
| 21 | + private String filename02; | |
| 22 | + private String filename03; | |
| 23 | + private String deliverDate; | |
| 24 | + private String sentDate; | |
| 25 | + private String reportDate; | |
| 26 | +} |
+++ src/main/java/com/munjaon/client/mysql/service/MysqlService.java
... | ... | @@ -0,0 +1,11 @@ |
| 1 | +package com.munjaon.client.mysql.service; | |
| 2 | + | |
| 3 | +import lombok.RequiredArgsConstructor; | |
| 4 | +import lombok.extern.slf4j.Slf4j; | |
| 5 | +import org.springframework.stereotype.Service; | |
| 6 | + | |
| 7 | +@Slf4j | |
| 8 | +@Service | |
| 9 | +@RequiredArgsConstructor | |
| 10 | +public class MysqlService { | |
| 11 | +} |
+++ src/main/java/com/munjaon/client/server/service/PropertyLoader.java
... | ... | @@ -0,0 +1,79 @@ |
| 1 | +package com.munjaon.client.server.service; | |
| 2 | + | |
| 3 | +import java.io.FileInputStream; | |
| 4 | +import java.util.Properties; | |
| 5 | + | |
| 6 | +/** | |
| 7 | + * PropertyLoader | |
| 8 | + * @author JDS | |
| 9 | + */ | |
| 10 | +public class PropertyLoader extends Thread { | |
| 11 | + | |
| 12 | + private static Properties props = load(); | |
| 13 | + private static PropertyLoader loader; | |
| 14 | + | |
| 15 | + public static String getProp(String key, String sub) { | |
| 16 | + return get(key+"."+sub); | |
| 17 | + } | |
| 18 | + | |
| 19 | + public static String get(String key) { | |
| 20 | + return get(key, null); | |
| 21 | + } | |
| 22 | + | |
| 23 | + public static String get(String key, String dflt) { | |
| 24 | + if( props == null ) return null; | |
| 25 | + | |
| 26 | + String value = props.getProperty(key, dflt); | |
| 27 | + | |
| 28 | + if( value == null ) { | |
| 29 | + value = dflt; | |
| 30 | + System.err.println("Not Defined : [" + key + "]"); | |
| 31 | + } | |
| 32 | + else { | |
| 33 | + value = value.replaceAll("\\$WORK_HOME", System.getProperty("WORK_HOME")); | |
| 34 | + } | |
| 35 | + | |
| 36 | + return value; | |
| 37 | + } | |
| 38 | + | |
| 39 | + public synchronized static Properties load() { | |
| 40 | + String propFile = System.getProperty("PROPS"); | |
| 41 | + try { | |
| 42 | + Properties properties = new Properties(); | |
| 43 | + properties.load( new FileInputStream (propFile) ); | |
| 44 | + | |
| 45 | + props = properties; | |
| 46 | + } catch(Exception e) { | |
| 47 | + Log(e); | |
| 48 | + } | |
| 49 | + | |
| 50 | + if( loader == null ) { | |
| 51 | + loader = new PropertyLoader(); | |
| 52 | + loader.start(); | |
| 53 | + } | |
| 54 | + | |
| 55 | + return props; | |
| 56 | + } | |
| 57 | + | |
| 58 | + private synchronized static void Log(Object oLog) { | |
| 59 | + if ( oLog instanceof Exception ) { | |
| 60 | + System.out.println( (new java.util.Date()) ); | |
| 61 | + ((Exception)oLog).printStackTrace(); | |
| 62 | + } else { | |
| 63 | + System.out.println( (new java.util.Date()) + (String) oLog ); | |
| 64 | + } | |
| 65 | + } | |
| 66 | + | |
| 67 | + @Override | |
| 68 | + public void run() { | |
| 69 | + while( true ) { | |
| 70 | + try { | |
| 71 | + Thread.sleep(1000); | |
| 72 | + load(); | |
| 73 | + } catch(Exception e) { | |
| 74 | + Log(e); | |
| 75 | + } | |
| 76 | + } | |
| 77 | + } | |
| 78 | + | |
| 79 | +} |
+++ src/main/java/com/munjaon/client/service/DatabaseService.java
... | ... | @@ -0,0 +1,15 @@ |
| 1 | +package com.munjaon.client.service; | |
| 2 | + | |
| 3 | +import lombok.Getter; | |
| 4 | + | |
| 5 | +@Getter | |
| 6 | +public enum DatabaseService { | |
| 7 | + MARIADB_SERVICE, | |
| 8 | + MYSQL_SERVICE; | |
| 9 | + | |
| 10 | + private Object service; | |
| 11 | + | |
| 12 | + public void setService(Object service) { | |
| 13 | + this.service = service; | |
| 14 | + } | |
| 15 | +} |
+++ src/main/java/com/munjaon/client/service/DatabaseServiceInjector.java
... | ... | @@ -0,0 +1,30 @@ |
| 1 | +package com.munjaon.client.service; | |
| 2 | + | |
| 3 | +import com.munjaon.client.mariadb.service.MariaDBService; | |
| 4 | +import com.munjaon.client.mysql.service.MysqlService; | |
| 5 | +import jakarta.annotation.PostConstruct; | |
| 6 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 7 | +import org.springframework.stereotype.Component; | |
| 8 | + | |
| 9 | +import java.util.EnumSet; | |
| 10 | + | |
| 11 | +@Component | |
| 12 | +public class DatabaseServiceInjector { | |
| 13 | + @Autowired | |
| 14 | + private MariaDBService mariaDBService; | |
| 15 | + @Autowired | |
| 16 | + private MysqlService mysqlService; | |
| 17 | + | |
| 18 | + @PostConstruct | |
| 19 | + public void postConstruct() { | |
| 20 | + for (DatabaseService svc : EnumSet.allOf(DatabaseService.class)) { | |
| 21 | + switch (svc) { | |
| 22 | + case MARIADB_SERVICE: svc.setService(mariaDBService); | |
| 23 | + break; | |
| 24 | + case MYSQL_SERVICE: svc.setService(mysqlService); | |
| 25 | + break; | |
| 26 | + default: break; | |
| 27 | + } | |
| 28 | + } | |
| 29 | + } | |
| 30 | +} |
+++ src/main/java/com/munjaon/client/service/DatabaseTypeWorker.java
... | ... | @@ -0,0 +1,125 @@ |
| 1 | +package com.munjaon.client.service; | |
| 2 | + | |
| 3 | +import com.munjaon.client.mariadb.service.MariaDBService; | |
| 4 | +import com.munjaon.client.model.MunjaonMsg; | |
| 5 | +import lombok.Getter; | |
| 6 | + | |
| 7 | +import java.util.EnumSet; | |
| 8 | +import java.util.List; | |
| 9 | + | |
| 10 | +@Getter | |
| 11 | +public enum DatabaseTypeWorker { | |
| 12 | + TYPE_OF_MARIADB("MARIADB") { | |
| 13 | + @Override | |
| 14 | + public boolean checkTableExists() { | |
| 15 | + MariaDBService mariaDBService = (MariaDBService) DatabaseService.MARIADB_SERVICE.getService(); | |
| 16 | + return mariaDBService.checkTableExists(); | |
| 17 | + } | |
| 18 | + | |
| 19 | + @Override | |
| 20 | + public List<MunjaonMsg> selectToDeliver(String msgType) { | |
| 21 | + MariaDBService mariaDBService = (MariaDBService) DatabaseService.MARIADB_SERVICE.getService(); | |
| 22 | + return mariaDBService.selectToDeliver(msgType); | |
| 23 | + } | |
| 24 | + | |
| 25 | + @Override | |
| 26 | + public int updateToDeliver(String msgId) { | |
| 27 | + MariaDBService mariaDBService = (MariaDBService) DatabaseService.MARIADB_SERVICE.getService(); | |
| 28 | + return mariaDBService.updateToDeliver(msgId); | |
| 29 | + } | |
| 30 | + | |
| 31 | + @Override | |
| 32 | + public int updateToReport(MunjaonMsg params) { | |
| 33 | + MariaDBService mariaDBService = (MariaDBService) DatabaseService.MARIADB_SERVICE.getService(); | |
| 34 | + return mariaDBService.updateToReport(params); | |
| 35 | + } | |
| 36 | + | |
| 37 | + @Override | |
| 38 | + public List<MunjaonMsg> selectToMove() { | |
| 39 | + MariaDBService mariaDBService = (MariaDBService) DatabaseService.MARIADB_SERVICE.getService(); | |
| 40 | + return mariaDBService.selectToMove(); | |
| 41 | + } | |
| 42 | + | |
| 43 | + @Override | |
| 44 | + public List<MunjaonMsg> selectToExpire(String expireTime) { | |
| 45 | + MariaDBService mariaDBService = (MariaDBService) DatabaseService.MARIADB_SERVICE.getService(); | |
| 46 | + return mariaDBService.selectToExpire(expireTime); | |
| 47 | + } | |
| 48 | + | |
| 49 | + @Override | |
| 50 | + public int insertToLog(String msgId) { | |
| 51 | + MariaDBService mariaDBService = (MariaDBService) DatabaseService.MARIADB_SERVICE.getService(); | |
| 52 | + return mariaDBService.insertToLog(msgId); | |
| 53 | + } | |
| 54 | + | |
| 55 | + @Override | |
| 56 | + public int deleteFromDeliver(String msgId) { | |
| 57 | + MariaDBService mariaDBService = (MariaDBService) DatabaseService.MARIADB_SERVICE.getService(); | |
| 58 | + return mariaDBService.deleteFromDeliver(msgId); | |
| 59 | + } | |
| 60 | + }, | |
| 61 | + TYPE_OF_MYSQL("MYSQL") { | |
| 62 | + @Override | |
| 63 | + public boolean checkTableExists() { | |
| 64 | + return false; | |
| 65 | + } | |
| 66 | + | |
| 67 | + @Override | |
| 68 | + public List<MunjaonMsg> selectToDeliver(String msgType) { | |
| 69 | + return List.of(); | |
| 70 | + } | |
| 71 | + | |
| 72 | + @Override | |
| 73 | + public int updateToDeliver(String msgId) { | |
| 74 | + return 0; | |
| 75 | + } | |
| 76 | + | |
| 77 | + @Override | |
| 78 | + public int updateToReport(MunjaonMsg params) { | |
| 79 | + return 0; | |
| 80 | + } | |
| 81 | + | |
| 82 | + @Override | |
| 83 | + public List<MunjaonMsg> selectToMove() { | |
| 84 | + return List.of(); | |
| 85 | + } | |
| 86 | + | |
| 87 | + @Override | |
| 88 | + public List<MunjaonMsg> selectToExpire(String expireTime) { | |
| 89 | + return List.of(); | |
| 90 | + } | |
| 91 | + | |
| 92 | + @Override | |
| 93 | + public int insertToLog(String msgId) { | |
| 94 | + return 0; | |
| 95 | + } | |
| 96 | + | |
| 97 | + @Override | |
| 98 | + public int deleteFromDeliver(String msgId) { | |
| 99 | + return 0; | |
| 100 | + } | |
| 101 | + }; | |
| 102 | + | |
| 103 | + DatabaseTypeWorker(final String name) { | |
| 104 | + this.type = name; | |
| 105 | + } | |
| 106 | + private final String type; | |
| 107 | + public static DatabaseTypeWorker find(String type) { | |
| 108 | + for (DatabaseTypeWorker databaseTypeWorker : EnumSet.allOf(DatabaseTypeWorker.class)) { | |
| 109 | + if (type.equals(databaseTypeWorker.getType())) { | |
| 110 | + return databaseTypeWorker; | |
| 111 | + } | |
| 112 | + } | |
| 113 | + | |
| 114 | + return null; | |
| 115 | + } | |
| 116 | + | |
| 117 | + public abstract boolean checkTableExists(); | |
| 118 | + public abstract List<MunjaonMsg> selectToDeliver(String msgType); | |
| 119 | + public abstract int updateToDeliver(String msgId); | |
| 120 | + public abstract int updateToReport(MunjaonMsg params); | |
| 121 | + public abstract List<MunjaonMsg> selectToMove(); | |
| 122 | + public abstract List<MunjaonMsg> selectToExpire(String expireTime); | |
| 123 | + public abstract int insertToLog(String msgId); | |
| 124 | + public abstract int deleteFromDeliver(String msgId); | |
| 125 | +} |
+++ src/main/resources/application.yml
... | ... | @@ -0,0 +1,9 @@ |
| 1 | +spring: | |
| 2 | + application: | |
| 3 | + name: munjaon_client | |
| 4 | + profiles: | |
| 5 | + default: local | |
| 6 | + | |
| 7 | +agent: | |
| 8 | + root-path: ${SERVICE_HOME} | |
| 9 | + server-property-file: ${SERVICE_HOME}/config/munjaonAgent.conf(No newline at end of file) |
+++ src/main/resources/dev/application-dev.yml
... | ... | @@ -0,0 +1,3 @@ |
| 1 | +agent: | |
| 2 | + root-path: ${SERVICE_HOME} | |
| 3 | + server-property-file: ${SERVICE_HOME}/config/munjaonAgent.conf(No newline at end of file) |
+++ src/main/resources/local/application-local.yml
... | ... | @@ -0,0 +1,3 @@ |
| 1 | +agent: | |
| 2 | + root-path: ${SERVICE_HOME} | |
| 3 | + server-property-file: ${SERVICE_HOME}/config/munjaonAgent.conf(No newline at end of file) |
+++ src/main/resources/logback-spring.xml
... | ... | @@ -0,0 +1,80 @@ |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<configuration> | |
| 3 | + <timestamp key="BY_DATE" datePattern="yyyy-MM-dd"/> | |
| 4 | + <property name="LOG_PATTERN" | |
| 5 | + value="[%d{yyyy-MM-dd HH:mm:ss}:%-4relative] %green([%thread]) %highlight(%-5level) %boldWhite([%C.%M:%yellow(%L)]) - %msg%n%ex"/> | |
| 6 | + | |
| 7 | + <springProfile name="local"> | |
| 8 | + <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> | |
| 9 | + <encoder> | |
| 10 | + <pattern>${LOG_PATTERN}</pattern> | |
| 11 | + </encoder> | |
| 12 | + </appender> | |
| 13 | + <logger name="com.munjaon.server" level="DEBUG" /> | |
| 14 | + <root level="ERROR"> | |
| 15 | + <appender-ref ref="CONSOLE"/> | |
| 16 | + </root> | |
| 17 | + </springProfile> | |
| 18 | + | |
| 19 | + <springProfile name="prod|dev"> | |
| 20 | + <appender name="FILE-INFO" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |
| 21 | + <file>./log/info/info-${BY_DATE}.log</file> | |
| 22 | + <filter class = "ch.qos.logback.classic.filter.LevelFilter"> | |
| 23 | + <level>INFO</level> | |
| 24 | + <onMatch>ACCEPT</onMatch> | |
| 25 | + <onMismatch>DENY</onMismatch> | |
| 26 | + </filter> | |
| 27 | + <encoder> | |
| 28 | + <pattern>${LOG_PATTERN}</pattern> | |
| 29 | + </encoder> | |
| 30 | + <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> | |
| 31 | + <fileNamePattern> ./backup/info/info-%d{yyyy-MM-dd}.%i.log</fileNamePattern> | |
| 32 | + <maxFileSize>100MB</maxFileSize> | |
| 33 | + <maxHistory>30</maxHistory> | |
| 34 | + <totalSizeCap>3GB</totalSizeCap> | |
| 35 | + </rollingPolicy> | |
| 36 | + </appender> | |
| 37 | + | |
| 38 | + <appender name="FILE-WARN" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |
| 39 | + <file>./log/warn/warn-${BY_DATE}.log</file> | |
| 40 | + <filter class = "ch.qos.logback.classic.filter.LevelFilter"> | |
| 41 | + <level>WARN</level> | |
| 42 | + <onMatch>ACCEPT</onMatch> | |
| 43 | + <onMismatch>DENY</onMismatch> | |
| 44 | + </filter> | |
| 45 | + <encoder> | |
| 46 | + <pattern>${LOG_PATTERN}</pattern> | |
| 47 | + </encoder> | |
| 48 | + <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> | |
| 49 | + <fileNamePattern> ./backup/warn/warn-%d{yyyy-MM-dd}.%i.log</fileNamePattern> | |
| 50 | + <maxFileSize>100MB</maxFileSize> | |
| 51 | + <maxHistory>30</maxHistory> | |
| 52 | + <totalSizeCap>3GB</totalSizeCap> | |
| 53 | + </rollingPolicy> | |
| 54 | + </appender> | |
| 55 | + | |
| 56 | + <appender name="FILE-ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |
| 57 | + <file>./log/error/error-${BY_DATE}.log</file> | |
| 58 | + <filter class = "ch.qos.logback.classic.filter.LevelFilter"> | |
| 59 | + <level>ERROR</level> | |
| 60 | + <onMatch>ACCEPT</onMatch> | |
| 61 | + <onMismatch>DENY</onMismatch> | |
| 62 | + </filter> | |
| 63 | + <encoder> | |
| 64 | + <pattern>${LOG_PATTERN}</pattern> | |
| 65 | + </encoder> | |
| 66 | + <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> | |
| 67 | + <fileNamePattern> ./backup/error/error-%d{yyyy-MM-dd}.%i.log</fileNamePattern> | |
| 68 | + <maxFileSize>100MB</maxFileSize> | |
| 69 | + <maxHistory>30</maxHistory> | |
| 70 | + <totalSizeCap>3GB</totalSizeCap> | |
| 71 | + </rollingPolicy> | |
| 72 | + </appender> | |
| 73 | + | |
| 74 | + <root level="INFO"> | |
| 75 | + <appender-ref ref="FILE-INFO"/> | |
| 76 | + <appender-ref ref="FILE-WARN"/> | |
| 77 | + <appender-ref ref="FILE-ERROR"/> | |
| 78 | + </root> | |
| 79 | + </springProfile> | |
| 80 | +</configuration>(No newline at end of file) |
+++ src/main/resources/mybatis-config.xml
... | ... | @@ -0,0 +1,13 @@ |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" | |
| 3 | + "http://mybatis.org/dtd/mybatis-3-config.dtd"> | |
| 4 | +<configuration> | |
| 5 | + <settings> | |
| 6 | + <setting name="mapUnderscoreToCamelCase" value="true" /> | |
| 7 | + <setting name="callSettersOnNulls" value="true" /> | |
| 8 | + <setting name="jdbcTypeForNull" value="NULL"/> | |
| 9 | + </settings> | |
| 10 | +<!-- <typeAliases>--> | |
| 11 | +<!-- <package name="com.dopco.psm.**.dto" />--> | |
| 12 | +<!-- </typeAliases>--> | |
| 13 | +</configuration>(No newline at end of file) |
+++ src/main/resources/prod/application-prod.yml
... | ... | @@ -0,0 +1,3 @@ |
| 1 | +agent: | |
| 2 | + root-path: ${SERVICE_HOME} | |
| 3 | + server-property-file: ${SERVICE_HOME}/config/munjaonAgent.conf(No newline at end of file) |
+++ src/main/resources/sqlmap/mariadb/mariadb_sql.xml
... | ... | @@ -0,0 +1,87 @@ |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |
| 3 | +<mapper namespace="com.munjaon.client.mariadb.mapper.MariaDBMapper"> | |
| 4 | + <select id="checkTime" resultType="String"> | |
| 5 | + /* MariaDBMapper.checkTime */ | |
| 6 | + SELECT DATE_FORMAT(NOW(), '%Y%m%d%H%i%s') | |
| 7 | + </select> | |
| 8 | + <select id="checkTableForMessage" resultType="int"> | |
| 9 | + /* MariaDBMapper.checkTableForMessage */ | |
| 10 | + SELECT 1 FROM MUNJAON_MSG WHERE 1=1 LIMIT 1 | |
| 11 | + </select> | |
| 12 | + <select id="checkTableForLog" resultType="int"> | |
| 13 | + /* MariaDBMapper.checkTableForLog */ | |
| 14 | + SELECT 1 FROM MUNJAON_MSG_LOG WHERE 1=1 LIMIT 1 | |
| 15 | + </select> | |
| 16 | + <select id="selectToDeliver" resultType="com.munjaon.client.model.MunjaonMsg"> | |
| 17 | + /* MariaDBMapper.selectToDeliver */ | |
| 18 | + SELECT | |
| 19 | + MSG_ID | |
| 20 | + , MSG_TYPE | |
| 21 | + , DATE_FORMAT(REQUEST_DATE,'%Y%m%d%H%i%s') REQUEST_DATE | |
| 22 | + , RECV_PHONE | |
| 23 | + , SEND_PHONE | |
| 24 | + , SUBJECT | |
| 25 | + , MESSAGE | |
| 26 | + , FILENAME01 | |
| 27 | + , FILENAME02 | |
| 28 | + , FILENAME03 | |
| 29 | + FROM MUNJAON_MSG | |
| 30 | + WHERE SEND_STATUS = '0' | |
| 31 | + AND MSG_TYPE = #{msgType} | |
| 32 | + AND REQUEST_DATE <![CDATA[<=]]> SYSDATE() | |
| 33 | + ORDER BY REQUEST_DATE ASC | |
| 34 | + LIMIT 100 | |
| 35 | + </select> | |
| 36 | + <update id="updateToDeliver"> | |
| 37 | + /* MariaDBMapper.updateToDeliver */ | |
| 38 | + UPDATE MUNJAON_MSG SET | |
| 39 | + SEND_STATUS = '1' | |
| 40 | + , DELIVER_DATE = NOW() | |
| 41 | + WHERE MSG_ID = #{msgId} | |
| 42 | + </update> | |
| 43 | + <update id="updateToReport"> | |
| 44 | + /* MariaDBMapper.updateToReport */ | |
| 45 | + UPDATE MUNJAON_MSG SET | |
| 46 | + SEND_STATUS = #{sendStatus} | |
| 47 | + , SENT_DATE = FROM_UNIXTIME(UNIX_TIMESTAMP(#{sentDate})) | |
| 48 | + , REPORT_DATE = NOW() | |
| 49 | + , TELECOM = #{telecom} | |
| 50 | + WHERE MSG_ID = #{msgId} | |
| 51 | + </update> | |
| 52 | + <select id="selectToMove" resultType="com.munjaon.client.model.MunjaonMsg"> | |
| 53 | + /* MariaDBMapper.selectToMove */ | |
| 54 | + SELECT MSG_ID, DATE_FORMAT(REQUEST_DATE, '%Y%m') REQUEST_DATE | |
| 55 | + FROM MUNJAON_MSG | |
| 56 | + WHERE SEND_STATUS NOT IN ('0', '1') | |
| 57 | + LIMIT 100 | |
| 58 | + </select> | |
| 59 | + <select id="selectToExpire" resultType="com.munjaon.client.model.MunjaonMsg"> | |
| 60 | + /* MariaDBMapper.selectToExpire */ | |
| 61 | + SELECT MSG_ID, DATE_FORMAT(REQUEST_DATE, '%Y%m') REQUEST_DATE | |
| 62 | + FROM MUNJAON_MSG | |
| 63 | + WHERE REQUEST_DATE <![CDATA[<]]> FROM_UNIXTIME(UNIX_TIMESTAMP(#{expireTime})) | |
| 64 | + AND SEND_STATUS = '1' | |
| 65 | + LIMIT 100 | |
| 66 | + </select> | |
| 67 | + <insert id="insertToLog"> | |
| 68 | + /* MariaDBMapper.insertToLog */ | |
| 69 | + INSERT INTO MUNJAON_MSG_LOG | |
| 70 | + ( | |
| 71 | + MSG_ID, MSG_TYPE, SEND_STATUS, REQUEST_DATE, | |
| 72 | + RECV_PHONE, SEND_PHONE, SUBJECT, MESSAGE, TELECOM, | |
| 73 | + FILENAME01, FILENAME02, FILENAME03, DELIVER_DATE, SENT_DATE, REPORT_DATE | |
| 74 | + ) | |
| 75 | + SELECT | |
| 76 | + MSG_ID, MSG_TYPE, SEND_STATUS, REQUEST_DATE, | |
| 77 | + RECV_PHONE, SEND_PHONE, SUBJECT, MESSAGE, TELECOM, | |
| 78 | + FILENAME01, FILENAME02, FILENAME03, DELIVER_DATE, SENT_DATE, REPORT_DATE | |
| 79 | + FROM MUNJAON_MSG | |
| 80 | + WHERE MSG_ID = #{msgId} | |
| 81 | + </insert> | |
| 82 | + <delete id="deleteFromDeliver"> | |
| 83 | + /* MariaDBMapper.deleteFromDeliver */ | |
| 84 | + DELETE FROM MUNJAON_MSG | |
| 85 | + WHERE MSG_ID = #{msgId} | |
| 86 | + </delete> | |
| 87 | +</mapper>(No newline at end of file) |
+++ src/test/java/com/munjaon/client/MunjaonClientApplicationTests.java
... | ... | @@ -0,0 +1,13 @@ |
| 1 | +package com.munjaon.client; | |
| 2 | + | |
| 3 | +import org.junit.jupiter.api.Test; | |
| 4 | +import org.springframework.boot.test.context.SpringBootTest; | |
| 5 | + | |
| 6 | +@SpringBootTest | |
| 7 | +class MunjaonClientApplicationTests { | |
| 8 | + | |
| 9 | + @Test | |
| 10 | + void contextLoads() { | |
| 11 | + } | |
| 12 | + | |
| 13 | +} |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?