del disruptor_nmc
parent
163d107250
commit
87a0aabe8d
@ -1,33 +0,0 @@
|
||||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
Binary file not shown.
@ -1,2 +0,0 @@
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip
|
||||
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
|
||||
@ -1,308 +0,0 @@
|
||||
#!/bin/sh
|
||||
# ----------------------------------------------------------------------------
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Apache Maven Wrapper startup batch script, version 3.2.0
|
||||
#
|
||||
# Required ENV vars:
|
||||
# ------------------
|
||||
# JAVA_HOME - location of a JDK home dir
|
||||
#
|
||||
# Optional ENV vars
|
||||
# -----------------
|
||||
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
# e.g. to debug Maven itself, use
|
||||
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
if [ -z "$MAVEN_SKIP_RC" ] ; then
|
||||
|
||||
if [ -f /usr/local/etc/mavenrc ] ; then
|
||||
. /usr/local/etc/mavenrc
|
||||
fi
|
||||
|
||||
if [ -f /etc/mavenrc ] ; then
|
||||
. /etc/mavenrc
|
||||
fi
|
||||
|
||||
if [ -f "$HOME/.mavenrc" ] ; then
|
||||
. "$HOME/.mavenrc"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# OS specific support. $var _must_ be set to either true or false.
|
||||
cygwin=false;
|
||||
darwin=false;
|
||||
mingw=false
|
||||
case "$(uname)" in
|
||||
CYGWIN*) cygwin=true ;;
|
||||
MINGW*) mingw=true;;
|
||||
Darwin*) darwin=true
|
||||
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
|
||||
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
if [ -x "/usr/libexec/java_home" ]; then
|
||||
JAVA_HOME="$(/usr/libexec/java_home)"; export JAVA_HOME
|
||||
else
|
||||
JAVA_HOME="/Library/Java/Home"; export JAVA_HOME
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
if [ -r /etc/gentoo-release ] ; then
|
||||
JAVA_HOME=$(java-config --jre-home)
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched
|
||||
if $cygwin ; then
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=$(cygpath --unix "$JAVA_HOME")
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=$(cygpath --path --unix "$CLASSPATH")
|
||||
fi
|
||||
|
||||
# For Mingw, ensure paths are in UNIX format before anything is touched
|
||||
if $mingw ; then
|
||||
[ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] &&
|
||||
JAVA_HOME="$(cd "$JAVA_HOME" || (echo "cannot cd into $JAVA_HOME."; exit 1); pwd)"
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
javaExecutable="$(which javac)"
|
||||
if [ -n "$javaExecutable" ] && ! [ "$(expr "\"$javaExecutable\"" : '\([^ ]*\)')" = "no" ]; then
|
||||
# readlink(1) is not available as standard on Solaris 10.
|
||||
readLink=$(which readlink)
|
||||
if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then
|
||||
if $darwin ; then
|
||||
javaHome="$(dirname "\"$javaExecutable\"")"
|
||||
javaExecutable="$(cd "\"$javaHome\"" && pwd -P)/javac"
|
||||
else
|
||||
javaExecutable="$(readlink -f "\"$javaExecutable\"")"
|
||||
fi
|
||||
javaHome="$(dirname "\"$javaExecutable\"")"
|
||||
javaHome=$(expr "$javaHome" : '\(.*\)/bin')
|
||||
JAVA_HOME="$javaHome"
|
||||
export JAVA_HOME
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$JAVACMD" ] ; then
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
else
|
||||
JAVACMD="$(\unset -f command 2>/dev/null; \command -v java)"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
echo "Error: JAVA_HOME is not defined correctly." >&2
|
||||
echo " We cannot execute $JAVACMD" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
echo "Warning: JAVA_HOME environment variable is not set."
|
||||
fi
|
||||
|
||||
# traverses directory structure from process work directory to filesystem root
|
||||
# first directory with .mvn subdirectory is considered project base directory
|
||||
find_maven_basedir() {
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
echo "Path not specified to find_maven_basedir"
|
||||
return 1
|
||||
fi
|
||||
|
||||
basedir="$1"
|
||||
wdir="$1"
|
||||
while [ "$wdir" != '/' ] ; do
|
||||
if [ -d "$wdir"/.mvn ] ; then
|
||||
basedir=$wdir
|
||||
break
|
||||
fi
|
||||
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
|
||||
if [ -d "${wdir}" ]; then
|
||||
wdir=$(cd "$wdir/.." || exit 1; pwd)
|
||||
fi
|
||||
# end of workaround
|
||||
done
|
||||
printf '%s' "$(cd "$basedir" || exit 1; pwd)"
|
||||
}
|
||||
|
||||
# concatenates all lines of a file
|
||||
concat_lines() {
|
||||
if [ -f "$1" ]; then
|
||||
# Remove \r in case we run on Windows within Git Bash
|
||||
# and check out the repository with auto CRLF management
|
||||
# enabled. Otherwise, we may read lines that are delimited with
|
||||
# \r\n and produce $'-Xarg\r' rather than -Xarg due to word
|
||||
# splitting rules.
|
||||
tr -s '\r\n' ' ' < "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
log() {
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
printf '%s\n' "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
BASE_DIR=$(find_maven_basedir "$(dirname "$0")")
|
||||
if [ -z "$BASE_DIR" ]; then
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR
|
||||
log "$MAVEN_PROJECTBASEDIR"
|
||||
|
||||
##########################################################################################
|
||||
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||
# This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||
##########################################################################################
|
||||
wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar"
|
||||
if [ -r "$wrapperJarPath" ]; then
|
||||
log "Found $wrapperJarPath"
|
||||
else
|
||||
log "Couldn't find $wrapperJarPath, downloading it ..."
|
||||
|
||||
if [ -n "$MVNW_REPOURL" ]; then
|
||||
wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
|
||||
else
|
||||
wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
|
||||
fi
|
||||
while IFS="=" read -r key value; do
|
||||
# Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' )
|
||||
safeValue=$(echo "$value" | tr -d '\r')
|
||||
case "$key" in (wrapperUrl) wrapperUrl="$safeValue"; break ;;
|
||||
esac
|
||||
done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties"
|
||||
log "Downloading from: $wrapperUrl"
|
||||
|
||||
if $cygwin; then
|
||||
wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath")
|
||||
fi
|
||||
|
||||
if command -v wget > /dev/null; then
|
||||
log "Found wget ... using wget"
|
||||
[ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet"
|
||||
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
|
||||
wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
|
||||
else
|
||||
wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
|
||||
fi
|
||||
elif command -v curl > /dev/null; then
|
||||
log "Found curl ... using curl"
|
||||
[ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent"
|
||||
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
|
||||
curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath"
|
||||
else
|
||||
curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath"
|
||||
fi
|
||||
else
|
||||
log "Falling back to using Java to download"
|
||||
javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java"
|
||||
javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class"
|
||||
# For Cygwin, switch paths to Windows format before running javac
|
||||
if $cygwin; then
|
||||
javaSource=$(cygpath --path --windows "$javaSource")
|
||||
javaClass=$(cygpath --path --windows "$javaClass")
|
||||
fi
|
||||
if [ -e "$javaSource" ]; then
|
||||
if [ ! -e "$javaClass" ]; then
|
||||
log " - Compiling MavenWrapperDownloader.java ..."
|
||||
("$JAVA_HOME/bin/javac" "$javaSource")
|
||||
fi
|
||||
if [ -e "$javaClass" ]; then
|
||||
log " - Running MavenWrapperDownloader.java ..."
|
||||
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
##########################################################################################
|
||||
# End of extension
|
||||
##########################################################################################
|
||||
|
||||
# If specified, validate the SHA-256 sum of the Maven wrapper jar file
|
||||
wrapperSha256Sum=""
|
||||
while IFS="=" read -r key value; do
|
||||
case "$key" in (wrapperSha256Sum) wrapperSha256Sum=$value; break ;;
|
||||
esac
|
||||
done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties"
|
||||
if [ -n "$wrapperSha256Sum" ]; then
|
||||
wrapperSha256Result=false
|
||||
if command -v sha256sum > /dev/null; then
|
||||
if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c > /dev/null 2>&1; then
|
||||
wrapperSha256Result=true
|
||||
fi
|
||||
elif command -v shasum > /dev/null; then
|
||||
if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c > /dev/null 2>&1; then
|
||||
wrapperSha256Result=true
|
||||
fi
|
||||
else
|
||||
echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available."
|
||||
echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties."
|
||||
exit 1
|
||||
fi
|
||||
if [ $wrapperSha256Result = false ]; then
|
||||
echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2
|
||||
echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2
|
||||
echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin; then
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME")
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=$(cygpath --path --windows "$CLASSPATH")
|
||||
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
|
||||
MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR")
|
||||
fi
|
||||
|
||||
# Provide a "standardized" way to retrieve the CLI args that will
|
||||
# work with both Windows and non-Windows executions.
|
||||
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*"
|
||||
export MAVEN_CMD_LINE_ARGS
|
||||
|
||||
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
# shellcheck disable=SC2086 # safe args
|
||||
exec "$JAVACMD" \
|
||||
$MAVEN_OPTS \
|
||||
$MAVEN_DEBUG_OPTS \
|
||||
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||
"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
||||
@ -1,205 +0,0 @@
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Licensed to the Apache Software Foundation (ASF) under one
|
||||
@REM or more contributor license agreements. See the NOTICE file
|
||||
@REM distributed with this work for additional information
|
||||
@REM regarding copyright ownership. The ASF licenses this file
|
||||
@REM to you under the Apache License, Version 2.0 (the
|
||||
@REM "License"); you may not use this file except in compliance
|
||||
@REM with the License. You may obtain a copy of the License at
|
||||
@REM
|
||||
@REM https://www.apache.org/licenses/LICENSE-2.0
|
||||
@REM
|
||||
@REM Unless required by applicable law or agreed to in writing,
|
||||
@REM software distributed under the License is distributed on an
|
||||
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
@REM KIND, either express or implied. See the License for the
|
||||
@REM specific language governing permissions and limitations
|
||||
@REM under the License.
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Apache Maven Wrapper startup batch script, version 3.2.0
|
||||
@REM
|
||||
@REM Required ENV vars:
|
||||
@REM JAVA_HOME - location of a JDK home dir
|
||||
@REM
|
||||
@REM Optional ENV vars
|
||||
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
|
||||
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
|
||||
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
@REM e.g. to debug Maven itself, use
|
||||
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
|
||||
@echo off
|
||||
@REM set title of command window
|
||||
title %0
|
||||
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
|
||||
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
|
||||
|
||||
@REM set %HOME% to equivalent of $HOME
|
||||
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
|
||||
|
||||
@REM Execute a user defined script before this one
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
|
||||
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
|
||||
if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
|
||||
:skipRcPre
|
||||
|
||||
@setlocal
|
||||
|
||||
set ERROR_CODE=0
|
||||
|
||||
@REM To isolate internal variables from possible post scripts, we use another setlocal
|
||||
@setlocal
|
||||
|
||||
@REM ==== START VALIDATION ====
|
||||
if not "%JAVA_HOME%" == "" goto OkJHome
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME not found in your environment. >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
:OkJHome
|
||||
if exist "%JAVA_HOME%\bin\java.exe" goto init
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME is set to an invalid directory. >&2
|
||||
echo JAVA_HOME = "%JAVA_HOME%" >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
@REM ==== END VALIDATION ====
|
||||
|
||||
:init
|
||||
|
||||
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
|
||||
@REM Fallback to current working directory if not found.
|
||||
|
||||
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
|
||||
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
|
||||
|
||||
set EXEC_DIR=%CD%
|
||||
set WDIR=%EXEC_DIR%
|
||||
:findBaseDir
|
||||
IF EXIST "%WDIR%"\.mvn goto baseDirFound
|
||||
cd ..
|
||||
IF "%WDIR%"=="%CD%" goto baseDirNotFound
|
||||
set WDIR=%CD%
|
||||
goto findBaseDir
|
||||
|
||||
:baseDirFound
|
||||
set MAVEN_PROJECTBASEDIR=%WDIR%
|
||||
cd "%EXEC_DIR%"
|
||||
goto endDetectBaseDir
|
||||
|
||||
:baseDirNotFound
|
||||
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
|
||||
cd "%EXEC_DIR%"
|
||||
|
||||
:endDetectBaseDir
|
||||
|
||||
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
|
||||
|
||||
@setlocal EnableExtensions EnableDelayedExpansion
|
||||
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
|
||||
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
|
||||
|
||||
:endReadAdditionalConfig
|
||||
|
||||
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
|
||||
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
|
||||
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
|
||||
|
||||
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
|
||||
IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B
|
||||
)
|
||||
|
||||
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||
if exist %WRAPPER_JAR% (
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Found %WRAPPER_JAR%
|
||||
)
|
||||
) else (
|
||||
if not "%MVNW_REPOURL%" == "" (
|
||||
SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
|
||||
)
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Couldn't find %WRAPPER_JAR%, downloading it ...
|
||||
echo Downloading from: %WRAPPER_URL%
|
||||
)
|
||||
|
||||
powershell -Command "&{"^
|
||||
"$webclient = new-object System.Net.WebClient;"^
|
||||
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
|
||||
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
|
||||
"}"^
|
||||
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^
|
||||
"}"
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Finished downloading %WRAPPER_JAR%
|
||||
)
|
||||
)
|
||||
@REM End of extension
|
||||
|
||||
@REM If specified, validate the SHA-256 sum of the Maven wrapper jar file
|
||||
SET WRAPPER_SHA_256_SUM=""
|
||||
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
|
||||
IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B
|
||||
)
|
||||
IF NOT %WRAPPER_SHA_256_SUM%=="" (
|
||||
powershell -Command "&{"^
|
||||
"$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^
|
||||
"If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^
|
||||
" Write-Output 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^
|
||||
" Write-Output 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^
|
||||
" Write-Output 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^
|
||||
" exit 1;"^
|
||||
"}"^
|
||||
"}"
|
||||
if ERRORLEVEL 1 goto error
|
||||
)
|
||||
|
||||
@REM Provide a "standardized" way to retrieve the CLI args that will
|
||||
@REM work with both Windows and non-Windows executions.
|
||||
set MAVEN_CMD_LINE_ARGS=%*
|
||||
|
||||
%MAVEN_JAVA_EXE% ^
|
||||
%JVM_CONFIG_MAVEN_PROPS% ^
|
||||
%MAVEN_OPTS% ^
|
||||
%MAVEN_DEBUG_OPTS% ^
|
||||
-classpath %WRAPPER_JAR% ^
|
||||
"-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
|
||||
%WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
|
||||
if ERRORLEVEL 1 goto error
|
||||
goto end
|
||||
|
||||
:error
|
||||
set ERROR_CODE=1
|
||||
|
||||
:end
|
||||
@endlocal & set ERROR_CODE=%ERROR_CODE%
|
||||
|
||||
if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
|
||||
@REM check for post script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
|
||||
if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
|
||||
:skipRcPost
|
||||
|
||||
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
|
||||
if "%MAVEN_BATCH_PAUSE%"=="on" pause
|
||||
|
||||
if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
|
||||
|
||||
cmd /C exit /B %ERROR_CODE%
|
||||
@ -1,185 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.5.3</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.rehome</groupId>
|
||||
<artifactId>disruptor_nmc</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>1.0.0</version>
|
||||
<name>disruptor_nmc</name>
|
||||
<description>SpringBoot + Disruptor 实现特快高并发处理,支撑每秒 600 万订单无压力!</description>
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<spring-cloud.version>2020.0.3</spring-cloud.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>2.1.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
<artifactId>validation-api</artifactId>
|
||||
<version>2.0.1.Final</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.paho</groupId>
|
||||
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||
<version>1.2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>3.6.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>19.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.20</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api -->
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-api</artifactId>
|
||||
<version>2.17.1</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>2.17.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>swagger-bootstrap-ui</artifactId>
|
||||
<version>1.9.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.4</version>
|
||||
</dependency>
|
||||
<!--mysql驱动 -->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.26</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<!--oracle驱动 -->
|
||||
<dependency>
|
||||
<groupId>com.oracle</groupId>
|
||||
<artifactId>ojdbc6</artifactId>
|
||||
<version>11.2.0.1.0</version>
|
||||
</dependency>
|
||||
<!--sqlserver驱动 -->
|
||||
<dependency>
|
||||
<groupId>com.microsoft.sqlserver</groupId>
|
||||
<artifactId>mssql-jdbc</artifactId>
|
||||
<version>11.2.0.jre8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
<version>1.5.20</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.47</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
<version>1.60</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcpkix-jdk15on</artifactId>
|
||||
<version>1.60</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>1.11</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.lmax</groupId>
|
||||
<artifactId>disruptor</artifactId>
|
||||
<version>3.4.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.liuhuiyu</groupId>
|
||||
<artifactId>spring-util</artifactId>
|
||||
<version>2021.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.liuhuiyu</groupId>
|
||||
<artifactId>util</artifactId>
|
||||
<version>2022.1.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
<build>
|
||||
<!-- <finalName>${project.artifactId}</finalName>-->
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<skipTests>true</skipTests>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@ -1,30 +0,0 @@
|
||||
package com.rehome.disruptor_nmc.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.Proxy;
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@EntityListeners(AuditingEntityListener.class)
|
||||
@Proxy(lazy = false)
|
||||
@Data
|
||||
@Entity
|
||||
public class NmcCity implements Serializable {
|
||||
@Id
|
||||
private String code;
|
||||
|
||||
private String province;
|
||||
|
||||
private String city;
|
||||
|
||||
private String url;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date createDate;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date lastUpdateDate;
|
||||
}
|
||||
@ -1,35 +0,0 @@
|
||||
package com.rehome.disruptor_nmc.entity;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.Proxy;
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@EntityListeners(AuditingEntityListener.class)
|
||||
@Proxy(lazy = false)
|
||||
@Data
|
||||
@Entity
|
||||
public class NmcForecastWeather implements Serializable {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
//存放长文本
|
||||
@Lob
|
||||
@Basic(fetch = FetchType.LAZY)
|
||||
private String weather;
|
||||
|
||||
private String weatherDate;
|
||||
|
||||
private String code;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date createDate;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date lastUpdateDate;
|
||||
}
|
||||
@ -1,50 +0,0 @@
|
||||
package com.rehome.disruptor_nmc.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.Proxy;
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@EntityListeners(AuditingEntityListener.class)
|
||||
@Proxy(lazy = false)
|
||||
@Data
|
||||
@Entity
|
||||
@Table(indexes = {@Index(name = "idx_weatherDate", columnList = "weatherDate"),
|
||||
@Index(name = "idx_code", columnList = "code"),
|
||||
@Index(name = "idx_createDate", columnList = "createDate"),
|
||||
@Index(name = "idx_lastUpdateDate", columnList = "lastUpdateDate"),
|
||||
@Index(name = "idx_weather_date_code_nmc", columnList = "weatherDate"),
|
||||
@Index(name = "idx_weather_date_code_nmc", columnList = "code")})
|
||||
//@GenericGenerator(name = "NmcNowWeather-uuid", strategy = "uuid")
|
||||
public class NmcNowWeather implements Serializable {
|
||||
public static final int COLUMN_ID_MAX_LENGTH = 32;
|
||||
public static final int COLUMN_CNAME_MAX_LENGTH = 16;
|
||||
|
||||
// @Id
|
||||
// @GenericGenerator(name = "NmcNowWeather-uuid", strategy = "uuid")
|
||||
// @GeneratedValue(generator = "NmcNowWeather-uuid")
|
||||
// @Column(length = 32)
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
//存放长文本
|
||||
@Lob
|
||||
@Basic(fetch = FetchType.LAZY)
|
||||
private String weather;
|
||||
|
||||
private String weatherDate;
|
||||
|
||||
private String code;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date createDate;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date lastUpdateDate;
|
||||
}
|
||||
@ -1,27 +0,0 @@
|
||||
package com.rehome.disruptor_nmc.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.Proxy;
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@EntityListeners(AuditingEntityListener.class)
|
||||
@Proxy(lazy = false)
|
||||
@Data
|
||||
@Entity
|
||||
public class NmcProvince implements Serializable {
|
||||
@Id
|
||||
private String code;
|
||||
|
||||
private String name;
|
||||
|
||||
private String url;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date createDate;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date lastUpdateDate;
|
||||
}
|
||||
@ -1,40 +0,0 @@
|
||||
package com.rehome.disruptor_nmc.mq;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 获取实例化对象
|
||||
*/
|
||||
@Component
|
||||
public class BeanManager implements ApplicationContextAware {
|
||||
|
||||
|
||||
|
||||
private static ApplicationContext applicationContext = null;
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
|
||||
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
public static ApplicationContext getApplicationContext() {
|
||||
|
||||
return applicationContext; }
|
||||
|
||||
public static Object getBean(String name) {
|
||||
|
||||
|
||||
return applicationContext.getBean(name);
|
||||
}
|
||||
|
||||
public static <T> T getBean(Class<T> clazz) {
|
||||
|
||||
|
||||
return applicationContext.getBean(clazz);
|
||||
}
|
||||
}
|
||||
@ -1,16 +0,0 @@
|
||||
package com.rehome.disruptor_nmc.mq;
|
||||
|
||||
import com.rehome.disruptor_nmc.entity.NmcNowWeather;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MessageModel {
|
||||
private NmcNowWeather message;
|
||||
|
||||
private String temperatureAndHumidityData;
|
||||
|
||||
private String topic;
|
||||
|
||||
private String type;
|
||||
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
package com.rehome.disruptor_nmc.mq;
|
||||
|
||||
import com.lmax.disruptor.EventFactory;
|
||||
|
||||
public class NmcWeatherEventFactory implements EventFactory<MessageModel> {
|
||||
@Override
|
||||
public MessageModel newInstance() {
|
||||
return new MessageModel();
|
||||
}
|
||||
}
|
||||
@ -1,38 +0,0 @@
|
||||
package com.rehome.disruptor_nmc.mq;
|
||||
|
||||
import com.liuhuiyu.spring_util.SpringUtil;
|
||||
import com.lmax.disruptor.EventHandler;
|
||||
import com.rehome.disruptor_nmc.service.NmcWeatherService;
|
||||
import com.rehome.disruptor_nmc.service.TemperatureService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class NmcWeatherEventHandler implements EventHandler<MessageModel> {
|
||||
|
||||
@Override
|
||||
public void onEvent(MessageModel event, long sequence, boolean endOfBatch) {
|
||||
|
||||
try {
|
||||
//这里停止1000ms是为了确定消费消息是异步的
|
||||
log.info("消费者处理消息开始");
|
||||
if (event != null) {
|
||||
log.info("消费者消费的信息是:{}", event);
|
||||
if("mqttTemperature".equals(event.getType())){
|
||||
TemperatureService temperatureService = SpringUtil.getBean(TemperatureService.class);
|
||||
temperatureService.saveTemperature(event.getTemperatureAndHumidityData(),event.getTopic());
|
||||
}
|
||||
if("NmcWeather".equals(event.getType())){
|
||||
NmcWeatherService nmcWeatherService = SpringUtil.getBean(NmcWeatherService.class);
|
||||
nmcWeatherService.saveNowWeather(event.getMessage());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.info("消费者处理消息失败");
|
||||
}
|
||||
log.info("消费者处理消息结束");
|
||||
}
|
||||
}
|
||||
|
||||
//http://www.nmc.cn/
|
||||
@ -1,7 +0,0 @@
|
||||
package com.rehome.disruptor_nmc.response;
|
||||
|
||||
//定义返回数据结构
|
||||
public interface IResult {
|
||||
Integer getCode();
|
||||
String getMessage();
|
||||
}
|
||||
@ -1,68 +0,0 @@
|
||||
package com.rehome.disruptor_nmc.response;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.validation.FieldError;
|
||||
|
||||
//统一返回数据结构
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Result<T> {
|
||||
private Integer code;
|
||||
private String message;
|
||||
private T data;
|
||||
|
||||
public static <T> Result<T> success(T data) {
|
||||
return new Result<>(ResultEnum.SUCCESS.getCode(), ResultEnum.SUCCESS.getMessage(), data);
|
||||
}
|
||||
|
||||
public static <T> Result<T> success(String message, T data) {
|
||||
return new Result<>(ResultEnum.SUCCESS.getCode(), message, data);
|
||||
}
|
||||
|
||||
public static Result<?> failed() {
|
||||
return new Result<>(ResultEnum.COMMON_FAILED.getCode(), ResultEnum.COMMON_FAILED.getMessage(), null);
|
||||
}
|
||||
|
||||
public static Result<?> failedByParamValidated() {
|
||||
return new Result<>(ResultEnum.REQUEST_PARAM_VALIDATED_FAILED.getCode(), ResultEnum.REQUEST_PARAM_VALIDATED_FAILED.getMessage(), null);
|
||||
}
|
||||
|
||||
public static Result<?> failedByParamValidated(BindingResult bindingResult) {
|
||||
Result result = new Result<>(ResultEnum.REQUEST_PARAM_VALIDATED_FAILED.getCode(), ResultEnum.REQUEST_PARAM_VALIDATED_FAILED.getMessage(), null);
|
||||
// 处理错误信息
|
||||
for (FieldError error : bindingResult.getFieldErrors()) {
|
||||
String baseErrorMessage = result.getMessage();
|
||||
if(error.getField()!=null){
|
||||
baseErrorMessage=baseErrorMessage+","+error.getField();
|
||||
result.setMessage(baseErrorMessage);
|
||||
}
|
||||
if(error.getDefaultMessage()!=null){
|
||||
baseErrorMessage=baseErrorMessage+":"+error.getDefaultMessage();
|
||||
result.setMessage(baseErrorMessage);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Result<?> failed(String message) {
|
||||
return new Result<>(ResultEnum.COMMON_FAILED.getCode(), message, null);
|
||||
}
|
||||
|
||||
public static Result<?> failed(IResult errorResult) {
|
||||
return new Result<>(errorResult.getCode(), errorResult.getMessage(), null);
|
||||
}
|
||||
|
||||
public static <T> Result<T> instance(Integer code, String message, T data) {
|
||||
Result<T> result = new Result<>();
|
||||
result.setCode(code);
|
||||
result.setMessage(message);
|
||||
result.setData(data);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,38 +0,0 @@
|
||||
package com.rehome.disruptor_nmc.response;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
//常用结果的枚举
|
||||
public enum ResultEnum implements IResult {
|
||||
SUCCESS(2001, "接口调用成功"),
|
||||
VALIDATE_FAILED(2002, "参数校验失败"),
|
||||
COMMON_FAILED(2003, "接口调用失败"),
|
||||
FORBIDDEN(2004, "没有权限访问资源"),
|
||||
REQUEST_PARAM_VALIDATED_FAILED(2005, "请求参数校验失败");
|
||||
|
||||
private Integer code;
|
||||
private String message;
|
||||
|
||||
@Override
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
//省略get、set方法和构造方法
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
package com.rehome.disruptor_nmc.service;
|
||||
|
||||
import com.rehome.disruptor_nmc.entity.NmcNowWeather;
|
||||
|
||||
public interface DisruptorMqService {
|
||||
/**
|
||||
* 消息
|
||||
* @param message
|
||||
*/
|
||||
void pushMessageToMq(NmcNowWeather message);
|
||||
|
||||
void pushTemperatureToMq(String temperatureAndHumidityData,String topic);
|
||||
|
||||
}
|
||||
@ -1,23 +0,0 @@
|
||||
package com.rehome.disruptor_nmc.service;
|
||||
|
||||
import com.rehome.disruptor_nmc.entity.NmcCity;
|
||||
import com.rehome.disruptor_nmc.entity.NmcProvince;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface NmcCityService {
|
||||
//code查询所有省份
|
||||
NmcProvince findProvinceByCode(String code);
|
||||
|
||||
//根据code查询城市
|
||||
NmcCity findCityByCode(String code);
|
||||
|
||||
//保存省份
|
||||
void saveProvince(NmcProvince province);
|
||||
|
||||
//保存城市
|
||||
void saveCity(NmcCity city);
|
||||
|
||||
//查询所有城市
|
||||
List<NmcCity> findAllCityList();
|
||||
}
|
||||
@ -1,16 +0,0 @@
|
||||
package com.rehome.disruptor_nmc.service;
|
||||
|
||||
import com.rehome.disruptor_nmc.entity.NmcForecastWeather;
|
||||
import com.rehome.disruptor_nmc.entity.NmcNowWeather;
|
||||
|
||||
public interface NmcWeatherService {
|
||||
/**
|
||||
* 保存实时天气数据
|
||||
*/
|
||||
void saveNowWeather(NmcNowWeather nowWeather);
|
||||
|
||||
/**
|
||||
* 保存预报天气数据
|
||||
*/
|
||||
void saveForecastWeather(NmcForecastWeather forecastWeather);
|
||||
}
|
||||
@ -1,212 +0,0 @@
|
||||
package com.rehome.disruptor_nmc.service;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.rehome.disruptor_nmc.dto.NmcBaseDto;
|
||||
import com.rehome.disruptor_nmc.entity.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.*;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import com.liuhuiyu.spring_util.SpringUtil;
|
||||
|
||||
/**
|
||||
* @author huangwenfei
|
||||
* @version v1.0.0.0
|
||||
* Created DateTime 2023-10-25 11:35
|
||||
* @description: 定时任务服务
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ScheduledService {
|
||||
|
||||
@Resource
|
||||
private NmcCityService nmcCityService;
|
||||
// @Resource
|
||||
// private NmcWeatherService nmcWeatherService;
|
||||
|
||||
/**
|
||||
* @date 2022-03-16 09:41
|
||||
* @description: 从中央气象台获取省份列表
|
||||
* @Param: null
|
||||
*/
|
||||
//@Scheduled(cron = "0 49 * * * *")
|
||||
public void getNmcWeatherProvince() {
|
||||
System.out.println("scheduledGetWeather");
|
||||
System.out.println("=====>>>>>使用cron:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
||||
System.out.println(String.valueOf(System.currentTimeMillis()));
|
||||
String url = "http://www.nmc.cn/rest/province/all?_=" + String.valueOf(System.currentTimeMillis());
|
||||
System.out.println(url);
|
||||
// 初始化 OkHttpClient
|
||||
OkHttpClient client = new OkHttpClient.Builder()
|
||||
.connectTimeout(10, TimeUnit.SECONDS)
|
||||
.writeTimeout(30, TimeUnit.SECONDS)
|
||||
.readTimeout(30, TimeUnit.SECONDS)
|
||||
.build();
|
||||
|
||||
// 初始化请求体
|
||||
Request request = new Request.Builder()
|
||||
.get()
|
||||
.url(url)
|
||||
.build();
|
||||
|
||||
try {
|
||||
// 得到返回Response
|
||||
Response response = client.newCall(request).execute();
|
||||
String body = response.body().string();
|
||||
System.out.println(body);
|
||||
if (StringUtils.hasText(body)) {
|
||||
Gson gson = new Gson();
|
||||
List<NmcProvince> provinces = gson.fromJson(body, new TypeToken<List<NmcProvince>>() {
|
||||
}.getType());
|
||||
;
|
||||
for (NmcProvince province : provinces) {
|
||||
System.out.println(gson.toJson(province));
|
||||
this.nmcCityService.saveProvince(province);
|
||||
getNmcWeatherCityByCode(province.getCode());
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
System.out.println(provinces.size());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @date 2022-03-16 09:41
|
||||
* @description: 根据省份code获取城市列表
|
||||
* @Param: null
|
||||
*/
|
||||
public void getNmcWeatherCityByCode(String code) {
|
||||
String url = "http://www.nmc.cn/rest/province/" + code + "?_=" + String.valueOf(System.currentTimeMillis());
|
||||
System.out.println(url);
|
||||
// 初始化 OkHttpClient
|
||||
OkHttpClient client = new OkHttpClient.Builder()
|
||||
.connectTimeout(10, TimeUnit.SECONDS)
|
||||
.writeTimeout(30, TimeUnit.SECONDS)
|
||||
.readTimeout(30, TimeUnit.SECONDS)
|
||||
.build();
|
||||
|
||||
// 初始化请求体
|
||||
Request request = new Request.Builder()
|
||||
.get()
|
||||
.url(url)
|
||||
.build();
|
||||
|
||||
try {
|
||||
// 得到返回Response
|
||||
Response response = client.newCall(request).execute();
|
||||
String body = response.body().string();
|
||||
System.out.println(body);
|
||||
if (StringUtils.hasText(body)) {
|
||||
Gson gson = new Gson();
|
||||
List<NmcCity> citys = gson.fromJson(body, new TypeToken<List<NmcCity>>() {
|
||||
}.getType());
|
||||
;
|
||||
for (NmcCity city : citys) {
|
||||
System.out.println(gson.toJson(city));
|
||||
this.nmcCityService.saveCity(city);
|
||||
}
|
||||
System.out.println(citys.size());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @date 2022-03-16 09:41
|
||||
* @description: 从中央气象台获取天气数据
|
||||
* @Param: null
|
||||
*/
|
||||
@Scheduled(cron = "0 15 * * * *")
|
||||
public void getNmcNowWeather() {
|
||||
System.out.println("scheduledGetWeather");
|
||||
System.out.println("=====>>>>>使用cron:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
||||
System.out.println(String.valueOf(System.currentTimeMillis()));
|
||||
|
||||
|
||||
// 初始化 OkHttpClient
|
||||
OkHttpClient client = new OkHttpClient.Builder()
|
||||
.connectTimeout(10, TimeUnit.SECONDS)
|
||||
.writeTimeout(30, TimeUnit.SECONDS)
|
||||
.readTimeout(30, TimeUnit.SECONDS)
|
||||
.build();
|
||||
|
||||
List<NmcCity> citys = this.nmcCityService.findAllCityList();
|
||||
|
||||
for (NmcCity city : citys) {
|
||||
String url = "http://www.nmc.cn/rest/weather?stationid=" + city.getCode() + "&_=" + String.valueOf(System.currentTimeMillis());
|
||||
System.out.println(url);
|
||||
// 初始化请求体
|
||||
Request request = new Request.Builder()
|
||||
.get()
|
||||
.url(url)
|
||||
.build();
|
||||
|
||||
try {
|
||||
Thread.sleep(200);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
client.newCall(request).enqueue(new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
String body = response.body().string();
|
||||
System.out.println(body);
|
||||
if (StringUtils.hasText(body)) {
|
||||
try {
|
||||
Gson gson = new Gson();
|
||||
NmcBaseDto nmcBaseDto = gson.fromJson(body, NmcBaseDto.class);
|
||||
if (nmcBaseDto != null && nmcBaseDto.getCode() == 0) {
|
||||
Date now = new Date();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String nowDate = sdf.format(new Date());
|
||||
|
||||
NmcNowWeather nowWeather = new NmcNowWeather();
|
||||
nowWeather.setCode(city.getCode());
|
||||
nowWeather.setWeather(body);
|
||||
nowWeather.setWeatherDate(nowDate);
|
||||
nowWeather.setLastUpdateDate(now);
|
||||
nowWeather.setCreateDate(now);
|
||||
|
||||
//用 Disruptor 消息队列 实现特快高并发处理,支撑每秒 600 万订单无压力!
|
||||
DisruptorMqService disruptorMqService = SpringUtil.getBean(DisruptorMqService.class);
|
||||
disruptorMqService.pushMessageToMq(nowWeather);
|
||||
|
||||
//直接jpa存储数据到表
|
||||
// NmcWeatherService nmcWeatherServiceTemp = SpringUtil.getBean(NmcWeatherService.class);
|
||||
// nmcWeatherServiceTemp.saveNowWeather(nowWeather);
|
||||
log.info("消息队列已发送完毕");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,6 +0,0 @@
|
||||
package com.rehome.disruptor_nmc.service;
|
||||
|
||||
public interface TemperatureService {
|
||||
//温度和湿度
|
||||
void saveTemperature(String temperatureAndHumidityData,String topic);
|
||||
}
|
||||
@ -1,75 +0,0 @@
|
||||
package com.rehome.disruptor_nmc.service.impl;
|
||||
|
||||
|
||||
|
||||
import com.rehome.disruptor_nmc.dao.NmcCityRepository;
|
||||
import com.rehome.disruptor_nmc.dao.NmcProvinceRepository;
|
||||
import com.rehome.disruptor_nmc.entity.NmcCity;
|
||||
import com.rehome.disruptor_nmc.entity.NmcProvince;
|
||||
import com.rehome.disruptor_nmc.service.NmcCityService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class NmcCityServiceImpl implements NmcCityService {
|
||||
|
||||
@Resource
|
||||
private NmcCityRepository nmcCityRepository;
|
||||
@Resource
|
||||
private NmcProvinceRepository nmcProvinceRepository;
|
||||
|
||||
@Override
|
||||
public NmcProvince findProvinceByCode(String code) {
|
||||
return this.nmcProvinceRepository.findByCode(code);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NmcCity findCityByCode(String code) {
|
||||
return this.nmcCityRepository.findByCode(code);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void saveProvince(NmcProvince province) {
|
||||
if (province != null) {
|
||||
Date now = new Date();
|
||||
NmcProvince provinceDB = this.nmcProvinceRepository.findByCode(province.getCode());
|
||||
if (provinceDB != null) {
|
||||
provinceDB.setName(province.getName());
|
||||
provinceDB.setUrl(province.getUrl());
|
||||
provinceDB.setLastUpdateDate(now);
|
||||
this.nmcProvinceRepository.save(provinceDB);
|
||||
} else {
|
||||
province.setLastUpdateDate(now);
|
||||
province.setCreateDate(now);
|
||||
this.nmcProvinceRepository.save(province);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveCity(NmcCity city) {
|
||||
if (city != null) {
|
||||
Date now = new Date();
|
||||
NmcCity cityDB = this.nmcCityRepository.findByCode(city.getCode());
|
||||
if (cityDB != null) {
|
||||
cityDB.setCity(city.getCity());
|
||||
cityDB.setProvince(city.getProvince());
|
||||
cityDB.setUrl(city.getUrl());
|
||||
cityDB.setLastUpdateDate(now);
|
||||
this.nmcCityRepository.save(cityDB);
|
||||
} else {
|
||||
city.setLastUpdateDate(now);
|
||||
city.setCreateDate(now);
|
||||
this.nmcCityRepository.save(city);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NmcCity> findAllCityList() {
|
||||
return this.nmcCityRepository.findAll();
|
||||
}
|
||||
}
|
||||
@ -1,30 +0,0 @@
|
||||
package com.rehome.disruptor_nmc.service.impl;
|
||||
|
||||
|
||||
import com.rehome.disruptor_nmc.dao.NmcForecastWeatherRepository;
|
||||
import com.rehome.disruptor_nmc.dao.NmcNowWeatherRepository;
|
||||
import com.rehome.disruptor_nmc.entity.NmcForecastWeather;
|
||||
import com.rehome.disruptor_nmc.entity.NmcNowWeather;
|
||||
import com.rehome.disruptor_nmc.service.NmcWeatherService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Service
|
||||
public class NmcWeatherServiceImpl implements NmcWeatherService {
|
||||
@Resource
|
||||
private NmcNowWeatherRepository nmcNowWeatherRepository;
|
||||
@Resource
|
||||
private NmcForecastWeatherRepository nmcForecastWeatherRepository;
|
||||
|
||||
|
||||
@Override
|
||||
public void saveNowWeather(NmcNowWeather nowWeather) {
|
||||
this.nmcNowWeatherRepository.save(nowWeather);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveForecastWeather(NmcForecastWeather forecastWeather) {
|
||||
this.nmcForecastWeatherRepository.save(forecastWeather);
|
||||
}
|
||||
}
|
||||
@ -1,54 +0,0 @@
|
||||
package com.rehome.disruptor_nmc.service.impl;
|
||||
|
||||
|
||||
import com.rehome.disruptor_nmc.dao.TemperatureRepository;
|
||||
import com.rehome.disruptor_nmc.entity.Temperature;
|
||||
import com.rehome.disruptor_nmc.service.TemperatureService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
@Service
|
||||
public class TemperatureServiceImpl implements TemperatureService {
|
||||
|
||||
@Resource
|
||||
private TemperatureRepository temperatureRepository;
|
||||
|
||||
@Override
|
||||
public void saveTemperature(String temperatureAndHumidityData,String topic) {
|
||||
if(temperatureAndHumidityData!=null&&temperatureAndHumidityData.length()>0){
|
||||
String[] strDataTemperature = temperatureAndHumidityData.split(" ");
|
||||
Date now = new Date();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
SimpleDateFormat sdfHour = new SimpleDateFormat("yyyy-MM-dd HH");
|
||||
SimpleDateFormat sdfMinute = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||
|
||||
String nowDate = sdf.format(now);
|
||||
String nowHour = sdfHour.format(now);
|
||||
String dataMinute = sdfMinute.format(now);
|
||||
Temperature temperature = new Temperature();
|
||||
temperature.setCreateDate(now);
|
||||
temperature.setDataDate(nowDate);
|
||||
temperature.setDataHour(nowHour);
|
||||
temperature.setDataMinute(dataMinute);
|
||||
if(topic!=null){
|
||||
temperature.setTopic(topic);
|
||||
if(topic.equals("WifiSHT/7C87CE9CA4E6/SHT20")){
|
||||
temperature.setLocationDesc("广东省珠海市高新区唐家湾镇东岸村水风三街28号501");
|
||||
}
|
||||
if(topic.equals("WifiSHT/7C87CE9F5CBF/SHT20")){
|
||||
temperature.setLocationDesc("广东省珠海市金湾区三灶镇百川路1号1栋1单元1508");
|
||||
}
|
||||
if(topic.equals("WifiSHT/4CEBD686B6AA/SHT20")){
|
||||
temperature.setLocationDesc("广西壮族自治区崇左市天等县天等镇荣华村弄在屯113号");
|
||||
}
|
||||
}
|
||||
temperature.setHumidity(Double.valueOf(strDataTemperature[0]));
|
||||
temperature.setTemperature(Double.valueOf(strDataTemperature[1]));
|
||||
|
||||
this.temperatureRepository.save(temperature);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,91 +0,0 @@
|
||||
package com.rehome.disruptor_nmc.utils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* @author huangwenfei
|
||||
* @version v1.0.0.0
|
||||
* Created DateTime 2021-04-27 9:35
|
||||
* @description: http请求工具类
|
||||
*/
|
||||
public class HttpURLConnectionUtil {
|
||||
|
||||
/**
|
||||
* @date 2021-04-29 11:23
|
||||
* @description: get请求
|
||||
* @Param: urlStr get请求的url
|
||||
*/
|
||||
public static String getNetData(String urlStr) {
|
||||
HttpURLConnection conn = null;
|
||||
|
||||
//连接成功后我们是要读取数据的 所以要有一个输入流
|
||||
InputStream inputStream = null;
|
||||
|
||||
// 因为读取的都是文本信息 所以使用BufferedReader
|
||||
BufferedReader bufferedReader = null;
|
||||
|
||||
//StringBuilder来把接收到的数据拼接起来
|
||||
StringBuilder result = new StringBuilder();
|
||||
try {
|
||||
// 读取初始url 并且创建对象
|
||||
URL url = new URL(urlStr);
|
||||
//打开url连接
|
||||
conn = (HttpURLConnection) url.openConnection();
|
||||
//设置连接
|
||||
//请求的方法
|
||||
conn.setRequestMethod("GET");
|
||||
//设置主机连接超时(单位:毫秒)
|
||||
// 发送请求端 连接到 url目标地址端的时间 受距离长短和网络速度的影响
|
||||
conn.setConnectTimeout(15000);
|
||||
//设置从主机读取数据超时(单位:毫秒)
|
||||
// 连接成功后 获取数据的时间 受数据量和服务器处理数据的影响
|
||||
conn.setReadTimeout(60000);
|
||||
|
||||
//设置请求参数 可以指定接收json参数 服务端的key为content-type
|
||||
conn.setRequestProperty("Accept", "application/json");
|
||||
|
||||
//发送请求
|
||||
conn.connect();
|
||||
|
||||
//获取响应码 如果响应码不为200 表示请求不成功
|
||||
if (conn.getResponseCode() != 200) {
|
||||
//todo 此处应该增加异常处理手段
|
||||
return "请求失败!!!";
|
||||
}
|
||||
|
||||
//获取响应码 如果响应码为200 表示请求成功 然后可以读取数据
|
||||
//获取输入流 然后读取数据
|
||||
inputStream = conn.getInputStream();
|
||||
bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
|
||||
|
||||
//逐行读取数据
|
||||
String line;//用来读取数据
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
result.append(line);
|
||||
//System.out.print(line);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
//关闭各种流
|
||||
try {
|
||||
if (bufferedReader != null) {
|
||||
bufferedReader.close();
|
||||
}
|
||||
if (inputStream != null) {
|
||||
inputStream.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
@ -1,90 +0,0 @@
|
||||
package com.rehome.disruptor_nmc.utils;
|
||||
|
||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||
import org.bouncycastle.openssl.PEMKeyPair;
|
||||
import org.bouncycastle.openssl.PEMParser;
|
||||
import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.security.KeyPair;
|
||||
import java.security.KeyStore;
|
||||
import java.security.Security;
|
||||
import java.security.cert.CertificateFactory;
|
||||
import java.security.cert.X509Certificate;
|
||||
|
||||
public class MqttSSLSocketFactory {
|
||||
public static SSLSocketFactory getSingleSocketFactory(InputStream caCrtFileInputStream) throws Exception {
|
||||
Security.addProvider(new BouncyCastleProvider());
|
||||
X509Certificate caCert = null;
|
||||
|
||||
BufferedInputStream bis = new BufferedInputStream(caCrtFileInputStream);
|
||||
CertificateFactory cf = CertificateFactory.getInstance("X.509");
|
||||
|
||||
while (bis.available() > 0) {
|
||||
caCert = (X509Certificate) cf.generateCertificate(bis);
|
||||
}
|
||||
KeyStore caKs = KeyStore.getInstance(KeyStore.getDefaultType());
|
||||
caKs.load(null, null);
|
||||
caKs.setCertificateEntry("cert-certificate", caCert);
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(caKs);
|
||||
SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
|
||||
sslContext.init(null, tmf.getTrustManagers(), null);
|
||||
return sslContext.getSocketFactory();
|
||||
}
|
||||
|
||||
public static SSLSocketFactory getTwoDirSocketFactory(InputStream caCrtFile, InputStream crtFile, InputStream keyFile,
|
||||
String password) throws Exception {
|
||||
Security.addProvider(new BouncyCastleProvider());
|
||||
|
||||
// load CA certificate
|
||||
X509Certificate caCert = null;
|
||||
|
||||
BufferedInputStream bis = new BufferedInputStream(caCrtFile);
|
||||
CertificateFactory cf = CertificateFactory.getInstance("X.509");
|
||||
|
||||
while (bis.available() > 0) {
|
||||
caCert = (X509Certificate) cf.generateCertificate(bis);
|
||||
}
|
||||
|
||||
// load client certificate
|
||||
bis = new BufferedInputStream(crtFile);
|
||||
X509Certificate cert = null;
|
||||
while (bis.available() > 0) {
|
||||
cert = (X509Certificate) cf.generateCertificate(bis);
|
||||
}
|
||||
|
||||
// load client private cert
|
||||
PEMParser pemParser = new PEMParser(new InputStreamReader(keyFile));
|
||||
Object object = pemParser.readObject();
|
||||
JcaPEMKeyConverter converter = new JcaPEMKeyConverter();
|
||||
KeyPair key = converter.getKeyPair((PEMKeyPair) object);
|
||||
|
||||
KeyStore caKs = KeyStore.getInstance(KeyStore.getDefaultType());
|
||||
caKs.load(null, null);
|
||||
caKs.setCertificateEntry("cert-certificate", caCert);
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(caKs);
|
||||
|
||||
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
|
||||
ks.load(null, null);
|
||||
ks.setCertificateEntry("certificate", cert);
|
||||
ks.setKeyEntry("private-cert", key.getPrivate(), password.toCharArray(),
|
||||
new java.security.cert.Certificate[]{cert});
|
||||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||
kmf.init(ks, password.toCharArray());
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
|
||||
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
|
||||
|
||||
return sslContext.getSocketFactory();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
package com.rehome.disruptor_nmc.utils;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class UUIDUtil {
|
||||
public static String getUUID() {
|
||||
return UUID.randomUUID().toString();
|
||||
}
|
||||
}
|
||||
@ -1,68 +0,0 @@
|
||||
package com.rehome.disruptor_nmc.utils;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
/**
|
||||
* @author huangwenfei
|
||||
* @version v1.0.0.0
|
||||
* Created DateTime 2021-04-26 9:35
|
||||
* @description: http请求工具类
|
||||
*/
|
||||
public class WeatherUtil {
|
||||
/**
|
||||
* @date 2021-04-29 11:23
|
||||
* @description: get请求
|
||||
* @Param: url get请求的url
|
||||
*/
|
||||
public static String analysisUrl(String url){
|
||||
HttpURLConnection httpConnection = null;
|
||||
String output = "";
|
||||
try {
|
||||
URL targetUrl = new URL(url);
|
||||
httpConnection = (HttpURLConnection) targetUrl.openConnection();
|
||||
httpConnection.setDoOutput(true);
|
||||
httpConnection.setRequestMethod("GET");
|
||||
httpConnection.setRequestProperty("Content-Type",
|
||||
"application/json");
|
||||
InputStreamReader isr = new InputStreamReader(httpConnection
|
||||
.getInputStream(),"utf-8");
|
||||
BufferedReader responseBuffer = new BufferedReader(isr);
|
||||
output = responseBuffer.readLine();
|
||||
} catch (Exception e) {
|
||||
|
||||
} finally {
|
||||
httpConnection.disconnect();
|
||||
}
|
||||
return output;
|
||||
}
|
||||
/**
|
||||
* @date 2021-04-29 11:23
|
||||
* @description: get请求
|
||||
* @Param: url get请求的url
|
||||
*/
|
||||
public static String analysisUrlGzip(String url){
|
||||
HttpURLConnection httpConnection = null;
|
||||
String output = "";
|
||||
try {
|
||||
URL targetUrl = new URL(url);
|
||||
httpConnection = (HttpURLConnection) targetUrl.openConnection();
|
||||
httpConnection.setDoOutput(true);
|
||||
httpConnection.setRequestMethod("GET");
|
||||
httpConnection.setRequestProperty("Content-Type", "application/json");
|
||||
InputStream stream = new GZIPInputStream(httpConnection.getInputStream());
|
||||
output = IOUtils.toString(stream,"utf-8");
|
||||
} catch (Exception e) {
|
||||
|
||||
} finally {
|
||||
httpConnection.disconnect();
|
||||
}
|
||||
return output;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@ -1,27 +0,0 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEpAIBAAKCAQEA4omYWBuiZ2bPhpmZFuvX50FMP07k/rI4uajLT1irRwoUn0ZR
|
||||
xLO+voWb+0pMnLH6Aq/ehBW+WVOn4eQ4BBpSNXm4n5tJo71+FKKMk0uaX7NnBJ+P
|
||||
FJxJxoBn5kFNAXUWdDojCTVMBX3k/QG679n6bYzzguk5Ky/pIEvePleox49MJJ5W
|
||||
C3fHWNMODhWEYJXGgxjCSmWynLPmEdOyi2/KfKfplgCx1NYPbPW1JtZSRjJ9zK6b
|
||||
5g2uGts50JEDuWAkYXpztAetaBF68+h79aHKP78AAHRa+0cT+4J1uxwcf9XK7fQt
|
||||
5UGkuDZpUVWjQ9a44ciwaAXcKy9hqYRfSm9GBQIDAQABAoIBAQDCVBxOgK4pG2Ws
|
||||
ZjiQFBJqe3ZH3IrN/d5xTV3SnBKZZwlXtD/SiAp5by3mO89Kn9YC1hEAp5JZGE0s
|
||||
ltSCmH2rB9abe9+IybXNR79lX3Z23/PgYGuh14vl7yKxv5SqSmHPpEuHy6OCFoQH
|
||||
kaNlu0x7C22dACodZQULwmlMe2/6dtHQbs9x0OROnJa9SpnScXfaPW/g/ONqR7S1
|
||||
rytHsM8dWUSEvNCUBqGqUFCTBPX44+w1RBLji36ZP1zeenlcBSMGlBifVJKH5OCk
|
||||
MFR33iwh3BXxIi+he+DGBX8c1CRplgfitQZlSnX5I0OXcBm1r0I9zrC2hs1w4WVd
|
||||
KNpr556FAoGBAPxqeqp7UaVfSQOMLQrpFAEBP6sqYd9dM3S81COpEB0i1i/6eZiE
|
||||
dPiP92OXp5Ka3/0pT0h66K+enkmKQ788OaGtJpz6KIU25ZRN+t+tS4UslFg67BY5
|
||||
bdFad2pIF2Ql89EzqCmzHz6q2xc0SD467jEPS4FcNf8G91lJvamuLYkvAoGBAOXB
|
||||
DIP8FiF3jn0DaoQpv3sX4R9UKNXOcaJmaprVZ5VHml8vrszrKju2HogKtyEzCMiS
|
||||
I+MBSg9Vum5n9MFHUd/eRAqV1oh3l2QsR0AEJe230xXotoZ8Vdid32JNtsnR7YRL
|
||||
q/OcMFhdpk50J8cVlx3gnC61S54jl1pAEFWSMW8LAoGATjZkKf0qMFbVFe9SaaYN
|
||||
F76eTthEGWUUs6BrD12sa4rG2XkAQn0QjZB2dHqiZu/sZdJuCaRkAz7gByN7mH79
|
||||
0JYJd+yfr59yBcEf8j0NQIeus6QWUVCcMZmZlOofrV2BLhqWic1B6jYgyxDdLcMu
|
||||
2S7HE59R7+Lls9oAldotq+sCgYEAhd6IFldJ5dItufXFmKBiq6xsRb7Z1Epnt8KJ
|
||||
FxKFOlvwPMohxdC4WPZyr73emn+L/KH6OwjDSFAhQrdby0ptEE4Hw0svJ3DXS0zp
|
||||
bwl7uBlF6xwfThkgRAko4bR6bvnctRsKY/V7zeEzR78ydjPES2pWVnjYSJpgU/vE
|
||||
CLgYCaUCgYBzgGR2IrTfGdu9TVkEt9dAYS2QKwI+iEpTBLdJBCPiXbfg1Jh8xH5t
|
||||
vmFOYQPnvyu6cRg9JQFXAVmEHcjC0VPwy/wURxVcgw1il/zmUrUAERVhpG/4uC4N
|
||||
XQK0ipg/gvSEJKyiqeQN+nLv0PrdQ9vCQSG9sSMvWHL6dTcQDeNDiw==
|
||||
-----END RSA PRIVATE KEY-----
|
||||
Binary file not shown.
Binary file not shown.
@ -1,27 +0,0 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEogIBAAKCAQEApkLWaF5mqX/9Qv0PiFgvsEO9vNNzKcGjyAyLZBNQb70PgF33
|
||||
i7XsOBwNzo/xdisBXmWsCOPWVM60MUIGT4v7iCNueWQlMOsYYNxV47EV3ZclZbz4
|
||||
Ji5sKKczn1U1l25w5v3jNZEYcxHU6uwmtiBFCZa2SeEV0jI356qNU5Wvt9u/Io9Z
|
||||
tb5tZOMa71ERejViqZtfNIg5Q3oRB7gyhyFKVKjPZI5MnfA895+7SrL4Nm4OIApm
|
||||
dKM0dTV7Xz1VsRnO3IlivnmaQy7sBMv7ak8vNXCMO1qHQGKOmNrKHtQTswxOdute
|
||||
5kSSzVRBE25Xrk/RyG+01mtccU2liNWMjfTEwwIDAQABAoIBAEkt9g1uL6W/jgvk
|
||||
MugCWMsupd7s+y2P67TrwJbF4YutHZuUwJaf9l8kCfe3Z8JpX2rbOYOYNQiTCsD7
|
||||
nKd6p7XeUovfxnbno41OrgdQNJ2aH33OVTMJD9Y88f3ZlYMXu14Qtecn/Cj52kuk
|
||||
sc1MGtcDnSybg+1G6VBww0/c/MDhpHSEevJ8LZaxTOyNPvt4qVJZKtArBGnFPh81
|
||||
VKiBQy6Aumm4k9gRkrVbAR0xo9DiOYE0hfga04J3EwYdI2uhGvgew2zeRVSdsN81
|
||||
TN8mNJ/BTra2Yqf4bp22IhNT6G9AgfjqTb1mDfaQHkN5SABgB8TE/HubJ4wH/Jn+
|
||||
ptVLR5ECgYEA0gzbolhfskVJ00eNs1ik6SKpBQwKz27OokNILfG5+BzLTK5kBYtU
|
||||
jov9lSRz/PWHX+g7Do3ncdueSvHpBALaUcsxVsY1QoWcxQ8NLlZfcY1dm1Vuudzg
|
||||
dy3Ccl7vKsoQBkI/an+3+ooiy/XX9pydt4/QfkmzCaAre0SuLavNWJcCgYEAyqG4
|
||||
DUf41LFQTDNTTUxcg924JDk6pxO3+4Qr98CSJz+6pICkTw3fy/cKOj1wFc1RA4/0
|
||||
DndiXBXnA0wnfPb2dktZ970cXofaIXMbpcteBSJC/Atqd8Mmcit+A21FTx5nI/dv
|
||||
CGgmAj0j0Y7nX91+jos4l6/ihXskQQDfUYA2LrUCgYBqGOKLsxXLRyJOHPNfJqRN
|
||||
uhsjmHyRYEfxQAjiZBnqUCkEN4YAIut4AQ/6WGpZ2G8jq3rBFD5WjXb8Jgrr4sEB
|
||||
1Z+7U+ytCC4yfzLKOAiHo78nadS+/ulGaY+xE3C87UmAz8+WbKKyYznGSgxm3Z7w
|
||||
jCzkzTco4oV0AzHzkbbsSwKBgDaOVgyVXSR+3Py3MO116s7CKmruUaFcSMPaMTBS
|
||||
U8dnfCwASrzSIng6+jD2C7CDCBXqcy5V7FCYwQr9PQCDSZZN8VonO3UkJJGu+Tmp
|
||||
SJYfRGOx+ydljntcxF/N0sRbji971hQwXlNp/LPWQutnqkRcrY8Blv6TSg6KWpYJ
|
||||
7AylAoGAMp/nSsfpjnoYW+8KdC+iEZw66FjCg5HV11rWCUqj7gsgNOfCUhku826M
|
||||
23SwZWWVQzOR5dJsmtUuzO1cXcpxKSpMdpVikB4TYFm4U1l5QZuSG+L2516IjwwJ
|
||||
q96skUIZ649Tu1B5ecQLMPD0S/Hc8Guhcr31KGnisOQt/CbSA1w=
|
||||
-----END RSA PRIVATE KEY-----
|
||||
Binary file not shown.
@ -1,13 +0,0 @@
|
||||
package com.rehome.disruptor_nmc;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class DisruptorNmcApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue