Upgrade to Spring Boot + Spring Data.
Update this repository to use modern Spring practices including: * Spring Boot * Spring Data JPA * Spring Framework's Java configuration
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -13,3 +13,5 @@ atlassian-ide-plugin*.xml
|
||||
/*/*/build
|
||||
/*/*/*/build
|
||||
.gradle
|
||||
|
||||
target
|
||||
BIN
.mvn/wrapper/maven-wrapper.jar
vendored
Normal file
BIN
.mvn/wrapper/maven-wrapper.jar
vendored
Normal file
Binary file not shown.
1
.mvn/wrapper/maven-wrapper.properties
vendored
Normal file
1
.mvn/wrapper/maven-wrapper.properties
vendored
Normal file
@@ -0,0 +1 @@
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip
|
||||
@@ -1,19 +0,0 @@
|
||||
subprojects {
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'idea'
|
||||
|
||||
repositories {
|
||||
maven { url 'https://repo.spring.io/libs-release' }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testCompile("junit:junit:4.10")
|
||||
testCompile("org.easymock:easymock:3.1")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
task wrapper(type: Wrapper) {
|
||||
gradleVersion = '1.8'
|
||||
}
|
||||
BIN
airline/client/axis1/.mvn/wrapper/maven-wrapper.jar
vendored
Normal file
BIN
airline/client/axis1/.mvn/wrapper/maven-wrapper.jar
vendored
Normal file
Binary file not shown.
1
airline/client/axis1/.mvn/wrapper/maven-wrapper.properties
vendored
Normal file
1
airline/client/axis1/.mvn/wrapper/maven-wrapper.properties
vendored
Normal file
@@ -0,0 +1 @@
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip
|
||||
@@ -1,62 +0,0 @@
|
||||
configurations {
|
||||
axis
|
||||
}
|
||||
|
||||
ext.axisVersion = '1.4'
|
||||
|
||||
task axis {
|
||||
ext.sourcesDir = "${buildDir}/generated-sources/axis"
|
||||
ext.classesDir = "${buildDir}/classes/axis"
|
||||
ext.wsdl = "${projectDir}/../airline.wsdl"
|
||||
|
||||
inputs.files wsdl
|
||||
outputs.dir classesDir
|
||||
|
||||
doLast() {
|
||||
project.ant {
|
||||
taskdef name: "axis", classname: "org.apache.axis.tools.ant.wsdl.Wsdl2javaAntTask",
|
||||
classpath: configurations.axis.asPath
|
||||
|
||||
mkdir(dir: sourcesDir)
|
||||
mkdir(dir: classesDir)
|
||||
|
||||
axis(output: sourcesDir, url: wsdl) {
|
||||
mapping(namespace: "https://www.springframework.org/spring-ws/samples/airline/definitions",
|
||||
package: "org.springframework.ws.samples.airline.client.axis1")
|
||||
mapping(namespace: "https://www.springframework.org/spring-ws/samples/airline/schemas/messages",
|
||||
package: "org.springframework.ws.samples.airline.client.axis1")
|
||||
mapping(namespace: "https://www.springframework.org/spring-ws/samples/airline/schemas/types",
|
||||
package: "org.springframework.ws.samples.airline.client.axis1")
|
||||
}
|
||||
|
||||
javac(destdir: classesDir, source: 1.6, target: 1.6, debug: true,
|
||||
debugLevel: "lines,vars,source",
|
||||
classpath: configurations.axis.asPath) {
|
||||
src(path: sourcesDir)
|
||||
include(name: "**/*.java")
|
||||
include(name: "*.java")
|
||||
}
|
||||
|
||||
copy(todir: classesDir) {
|
||||
fileset(dir: sourcesDir, erroronmissingdir: false) {
|
||||
exclude(name: "**/*.java")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile("axis:axis:$axisVersion")
|
||||
compile("axis:axis-jaxrpc:$axisVersion")
|
||||
compile(files(axis.classesDir).builtBy(axis))
|
||||
runtime("log4j:log4j:1.2.16")
|
||||
axis("axis:axis:$axisVersion")
|
||||
axis("axis:axis-ant:$axisVersion")
|
||||
}
|
||||
|
||||
task runClient(dependsOn: 'classes', type:JavaExec) {
|
||||
main = "org.springframework.ws.samples.airline.client.axis1.Main"
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
}
|
||||
286
airline/client/axis1/mvnw
vendored
Executable file
286
airline/client/axis1/mvnw
vendored
Executable file
@@ -0,0 +1,286 @@
|
||||
#!/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
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Maven2 Start Up Batch script
|
||||
#
|
||||
# Required ENV vars:
|
||||
# ------------------
|
||||
# JAVA_HOME - location of a JDK home dir
|
||||
#
|
||||
# Optional ENV vars
|
||||
# -----------------
|
||||
# M2_HOME - location of maven2's installed home dir
|
||||
# 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 /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
|
||||
export JAVA_HOME="`/usr/libexec/java_home`"
|
||||
else
|
||||
export JAVA_HOME="/Library/Java/Home"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
if [ -r /etc/gentoo-release ] ; then
|
||||
JAVA_HOME=`java-config --jre-home`
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$M2_HOME" ] ; then
|
||||
## resolve links - $0 may be a link to maven's home
|
||||
PRG="$0"
|
||||
|
||||
# need this for relative symlinks
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG="`dirname "$PRG"`/$link"
|
||||
fi
|
||||
done
|
||||
|
||||
saveddir=`pwd`
|
||||
|
||||
M2_HOME=`dirname "$PRG"`/..
|
||||
|
||||
# make it fully qualified
|
||||
M2_HOME=`cd "$M2_HOME" && pwd`
|
||||
|
||||
cd "$saveddir"
|
||||
# echo Using m2 at $M2_HOME
|
||||
fi
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched
|
||||
if $cygwin ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --unix "$M2_HOME"`
|
||||
[ -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 "$M2_HOME" ] &&
|
||||
M2_HOME="`(cd "$M2_HOME"; pwd)`"
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
|
||||
# TODO classpath?
|
||||
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="`which 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
|
||||
|
||||
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
|
||||
|
||||
# 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/.."; pwd`
|
||||
fi
|
||||
# end of workaround
|
||||
done
|
||||
echo "${basedir}"
|
||||
}
|
||||
|
||||
# concatenates all lines of a file
|
||||
concat_lines() {
|
||||
if [ -f "$1" ]; then
|
||||
echo "$(tr -s '\n' ' ' < "$1")"
|
||||
fi
|
||||
}
|
||||
|
||||
BASE_DIR=`find_maven_basedir "$(pwd)"`
|
||||
if [ -z "$BASE_DIR" ]; then
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
##########################################################################################
|
||||
# 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.
|
||||
##########################################################################################
|
||||
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found .mvn/wrapper/maven-wrapper.jar"
|
||||
fi
|
||||
else
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
|
||||
fi
|
||||
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
|
||||
while IFS="=" read key value; do
|
||||
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
|
||||
esac
|
||||
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Downloading from: $jarUrl"
|
||||
fi
|
||||
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
|
||||
|
||||
if command -v wget > /dev/null; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found wget ... using wget"
|
||||
fi
|
||||
wget "$jarUrl" -O "$wrapperJarPath"
|
||||
elif command -v curl > /dev/null; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found curl ... using curl"
|
||||
fi
|
||||
curl -o "$wrapperJarPath" "$jarUrl"
|
||||
else
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Falling back to using Java to download"
|
||||
fi
|
||||
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
|
||||
if [ -e "$javaClass" ]; then
|
||||
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo " - Compiling MavenWrapperDownloader.java ..."
|
||||
fi
|
||||
# Compiling the Java class
|
||||
("$JAVA_HOME/bin/javac" "$javaClass")
|
||||
fi
|
||||
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
||||
# Running the downloader
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo " - Running MavenWrapperDownloader.java ..."
|
||||
fi
|
||||
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
##########################################################################################
|
||||
# End of extension
|
||||
##########################################################################################
|
||||
|
||||
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo $MAVEN_PROJECTBASEDIR
|
||||
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 "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --path --windows "$M2_HOME"`
|
||||
[ -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
|
||||
|
||||
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
exec "$JAVACMD" \
|
||||
$MAVEN_OPTS \
|
||||
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
||||
161
airline/client/axis1/mvnw.cmd
vendored
Normal file
161
airline/client/axis1/mvnw.cmd
vendored
Normal file
@@ -0,0 +1,161 @@
|
||||
@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 http://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 Maven2 Start Up Batch script
|
||||
@REM
|
||||
@REM Required ENV vars:
|
||||
@REM JAVA_HOME - location of a JDK home dir
|
||||
@REM
|
||||
@REM Optional ENV vars
|
||||
@REM M2_HOME - location of maven2's installed home dir
|
||||
@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 key stroke 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 my 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 "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
|
||||
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\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 DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
|
||||
FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO (
|
||||
IF "%%A"=="wrapperUrl" SET DOWNLOAD_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% (
|
||||
echo Found %WRAPPER_JAR%
|
||||
) else (
|
||||
echo Couldn't find %WRAPPER_JAR%, downloading it ...
|
||||
echo Downloading from: %DOWNLOAD_URL%
|
||||
powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"
|
||||
echo Finished downloading %WRAPPER_JAR%
|
||||
)
|
||||
@REM End of extension
|
||||
|
||||
%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 "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
|
||||
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\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%
|
||||
|
||||
exit /B %ERROR_CODE%
|
||||
173
airline/client/axis1/pom.xml
Normal file
173
airline/client/axis1/pom.xml
Normal file
@@ -0,0 +1,173 @@
|
||||
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.ws</groupId>
|
||||
<artifactId>spring-ws-samples</artifactId>
|
||||
<version>1.0.0.BUILD-SNAPSHOT</version>
|
||||
<relativePath>../../../</relativePath> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<groupId>org.springframework.ws</groupId>
|
||||
<artifactId>airline-client-axis1</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>Spring Web Services Samples - Airline - Client - Axis1</name>
|
||||
<description>Demo project for Spring Web Services</description>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<axis.version>1.4</axis.version>
|
||||
<log4j.version>1.2.16</log4j.version>
|
||||
<sourcesDir>${project.basedir}/target/generated-sources/axis</sourcesDir>
|
||||
<classesDir>${project.basedir}/target/classes</classesDir>
|
||||
<wsdl>${project.basedir}/../airline.wsdl</wsdl>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>axis</groupId>
|
||||
<artifactId>axis</artifactId>
|
||||
<version>${axis.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>axis</groupId>
|
||||
<artifactId>axis-jaxrpc</artifactId>
|
||||
<version>${axis.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>${log4j.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>axis</groupId>
|
||||
<artifactId>axis</artifactId>
|
||||
<version>${axis.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>axis</groupId>
|
||||
<artifactId>axis-ant</artifactId>
|
||||
<version>${axis.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>generate-sources</phase>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<taskdef name="axis-wsdl2java"
|
||||
classname="org.apache.axis.tools.ant.wsdl.Wsdl2javaAntTask">
|
||||
<classpath refid="maven.compile.classpath"/>
|
||||
</taskdef>
|
||||
|
||||
<mkdir dir="${sourcesDir}"/>
|
||||
<mkdir dir="${classesDir}"/>
|
||||
|
||||
<axis-wsdl2java
|
||||
output="${sourcesDir}"
|
||||
url="${wsdl}">
|
||||
<mapping
|
||||
namespace="http://www.springframework.org/spring-ws/samples/airline/definitions"
|
||||
package="org.springframework.ws.samples.airline.client.axis1"/>
|
||||
<mapping
|
||||
namespace="http://www.springframework.org/spring-ws/samples/airline/schemas/messages"
|
||||
package="org.springframework.ws.samples.airline.client.axis1"/>
|
||||
<mapping
|
||||
namespace="http://www.springframework.org/spring-ws/samples/airline/schemas/types"
|
||||
package="org.springframework.ws.samples.airline.client.axis1"/>
|
||||
</axis-wsdl2java>
|
||||
|
||||
<javac fork="true"
|
||||
destdir="${classesDir}"
|
||||
source="1.6" target="1.6" debug="true"
|
||||
debugLevel="lines,vars,source">
|
||||
<classpath refid="maven.compile.classpath"/>
|
||||
<src path="${sourcesDir}"/>
|
||||
<include name="**/*.java"/>
|
||||
<include name="*.java"/>
|
||||
</javac>
|
||||
|
||||
<copy todir="${classesDir}">
|
||||
<fileset dir="${sourcesDir}" erroronmissingdir="false">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</tasks>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<version>1.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>add-source</id>
|
||||
<phase>process-sources</phase>
|
||||
<goals>
|
||||
<goal>add-source</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>${sourcesDir}</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-snapshots</id>
|
||||
<name>Spring Snapshots</name>
|
||||
<url>https://repo.spring.io/snapshot</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>spring-snapshots</id>
|
||||
<name>Spring Snapshots</name>
|
||||
<url>https://repo.spring.io/snapshot</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
<pluginRepository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright 2006 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.samples.airline.client.axis1;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.xml.rpc.ServiceException;
|
||||
|
||||
/**
|
||||
* Simple client that calls the <code>GetFlights</code> and <code>BookFlight</code> operations using JAX-RPC (Axis 1).
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class AxisMain {
|
||||
|
||||
public static void main(String[] args) throws ServiceException, RemoteException {
|
||||
|
||||
AirlineServiceLocator service = new AirlineServiceLocator();
|
||||
if (args.length > 0) {
|
||||
service.setAirlineSoap11EndpointAddress(args[0]);
|
||||
}
|
||||
Airline airline = service.getAirlineSoap11();
|
||||
GetFlightsRequest request = new GetFlightsRequest();
|
||||
request.setFrom("AMS");
|
||||
request.setTo("VCE");
|
||||
Calendar departureCalendar = Calendar.getInstance();
|
||||
departureCalendar.set(Calendar.YEAR, 2006);
|
||||
departureCalendar.set(Calendar.MONTH, Calendar.JANUARY);
|
||||
departureCalendar.set(Calendar.DATE, 31);
|
||||
Date departureDate = departureCalendar.getTime();
|
||||
request.setDepartureDate(departureDate);
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
System.out.println("Requesting flights on " + dateFormat.format(departureDate));
|
||||
Flight[] flights = airline.getFlights(request);
|
||||
System.out.println("Got " + flights.length + " results");
|
||||
if (flights.length > 0) {
|
||||
// Book the first flight using John Doe as a frequent flyer
|
||||
BookFlightRequest bookFlightRequest = new BookFlightRequest();
|
||||
bookFlightRequest.setFlightNumber(flights[0].getNumber());
|
||||
bookFlightRequest.setDepartureTime(flights[0].getDepartureTime());
|
||||
BookFlightRequestPassengers passengers = new BookFlightRequestPassengers();
|
||||
passengers.setUsername("john");
|
||||
bookFlightRequest.setPassengers(passengers);
|
||||
Ticket ticket = airline.bookFlight(bookFlightRequest);
|
||||
writeTicket(ticket);
|
||||
}
|
||||
}
|
||||
|
||||
private static void writeTicket(Ticket ticket) {
|
||||
|
||||
System.out.println("Ticket " + ticket.getId());
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
System.out.println("Ticket issue date:\t" + dateFormat.format(ticket.getIssueDate()));
|
||||
for (int i = 0; i < ticket.getPassengers().length; i++) {
|
||||
writeName(ticket.getPassengers()[i]);
|
||||
|
||||
}
|
||||
writeFlight(ticket.getFlight());
|
||||
}
|
||||
|
||||
private static void writeName(Name name) {
|
||||
|
||||
System.out.println("Passenger Name:");
|
||||
System.out.println(name.getFirst() + " " + name.getLast());
|
||||
System.out.println("------------");
|
||||
}
|
||||
|
||||
private static void writeFlight(Flight flight) {
|
||||
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||
System.out.println(dateFormat.format(flight.getDepartureTime().getTime()));
|
||||
System.out.println(flight.getNumber() + "\t" + flight.getServiceClass());
|
||||
System.out.println("------------");
|
||||
System.out.println("Depart:\t" + flight.getFrom().getCode() + "-" + flight.getFrom().getName() + "\t"
|
||||
+ dateFormat.format(flight.getDepartureTime().getTime()));
|
||||
System.out.println("\t" + flight.getFrom().getCity());
|
||||
System.out.println("Arrive:\t" + flight.getTo().getCode() + "-" + flight.getTo().getName() + "\t"
|
||||
+ dateFormat.format(flight.getArrivalTime().getTime()));
|
||||
System.out.println("\t" + flight.getTo().getCity());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
/*
|
||||
* Copyright 2006 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.samples.airline.client.axis1;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Calendar;
|
||||
import javax.xml.rpc.ServiceException;
|
||||
|
||||
/**
|
||||
* Simple client that calls the <code>GetFlights</code> and <code>BookFlight</code> operations using JAX-RPC (Axis 1).
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) throws ServiceException, RemoteException {
|
||||
AirlineServiceLocator service = new AirlineServiceLocator();
|
||||
if (args.length > 0) {
|
||||
service.setAirlineSoap11EndpointAddress(args[0]);
|
||||
}
|
||||
Airline airline = service.getAirlineSoap11();
|
||||
GetFlightsRequest request = new GetFlightsRequest();
|
||||
request.setFrom("AMS");
|
||||
request.setTo("VCE");
|
||||
Calendar departureCalendar = Calendar.getInstance();
|
||||
departureCalendar.set(Calendar.YEAR, 2006);
|
||||
departureCalendar.set(Calendar.MONTH, Calendar.JANUARY);
|
||||
departureCalendar.set(Calendar.DATE, 31);
|
||||
Date departureDate = departureCalendar.getTime();
|
||||
request.setDepartureDate(departureDate);
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
System.out.println("Requesting flights on " + dateFormat.format(departureDate));
|
||||
Flight[] flights = airline.getFlights(request);
|
||||
System.out.println("Got " + flights.length + " results");
|
||||
if (flights.length > 0)
|
||||
{
|
||||
// Book the first flight using John Doe as a frequent flyer
|
||||
BookFlightRequest bookFlightRequest = new BookFlightRequest();
|
||||
bookFlightRequest.setFlightNumber(flights[0].getNumber());
|
||||
bookFlightRequest.setDepartureTime(flights[0].getDepartureTime());
|
||||
BookFlightRequestPassengers passengers = new BookFlightRequestPassengers();
|
||||
passengers.setUsername("john");
|
||||
bookFlightRequest.setPassengers(passengers);
|
||||
Ticket ticket = airline.bookFlight(bookFlightRequest);
|
||||
writeTicket(ticket);
|
||||
}
|
||||
}
|
||||
|
||||
private static void writeTicket(Ticket ticket) {
|
||||
System.out.println("Ticket " + ticket.getId());
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
System.out.println("Ticket issue date:\t" + dateFormat.format(ticket.getIssueDate()));
|
||||
for (int i = 0; i < ticket.getPassengers().length; i++) {
|
||||
writeName(ticket.getPassengers()[i]);
|
||||
|
||||
}
|
||||
writeFlight(ticket.getFlight());
|
||||
}
|
||||
|
||||
private static void writeName(Name name) {
|
||||
System.out.println("Passenger Name:");
|
||||
System.out.println(name.getFirst() + " " + name.getLast());
|
||||
System.out.println("------------");
|
||||
}
|
||||
|
||||
private static void writeFlight(Flight flight) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||
System.out.println(dateFormat.format(flight.getDepartureTime().getTime()));
|
||||
System.out.println(flight.getNumber() + "\t" + flight.getServiceClass());
|
||||
System.out.println("------------");
|
||||
System.out.println("Depart:\t" + flight.getFrom().getCode() + "-" + flight.getFrom().getName() + "\t" + dateFormat.format(flight.getDepartureTime().getTime()));
|
||||
System.out.println("\t" + flight.getFrom().getCity());
|
||||
System.out.println("Arrive:\t" + flight.getTo().getCode() + "-" + flight.getTo().getName() + "\t" + dateFormat.format(flight.getArrivalTime().getTime()));
|
||||
System.out.println("\t" + flight.getTo().getCity());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
BIN
airline/client/jax-ws/.mvn/wrapper/maven-wrapper.jar
vendored
Normal file
BIN
airline/client/jax-ws/.mvn/wrapper/maven-wrapper.jar
vendored
Normal file
Binary file not shown.
1
airline/client/jax-ws/.mvn/wrapper/maven-wrapper.properties
vendored
Normal file
1
airline/client/jax-ws/.mvn/wrapper/maven-wrapper.properties
vendored
Normal file
@@ -0,0 +1 @@
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip
|
||||
@@ -1,38 +0,0 @@
|
||||
configurations {
|
||||
wsimport
|
||||
}
|
||||
|
||||
ext.springWsVersion = '2.1.4.RELEASE'
|
||||
|
||||
task wsImport {
|
||||
ext.outputDir = "${buildDir}/classes/wsimport"
|
||||
ext.wsdl = "${projectDir}/../airline.wsdl"
|
||||
|
||||
inputs.files wsdl
|
||||
outputs.dir outputDir
|
||||
|
||||
doLast() {
|
||||
project.ant {
|
||||
taskdef name: "wsimport", classname: "com.sun.tools.ws.ant.WsImport",
|
||||
classpath: configurations.wsimport.asPath
|
||||
mkdir(dir: outputDir)
|
||||
|
||||
wsimport(destdir: outputDir, wsdl: wsdl,
|
||||
package: "org.springframework.ws.samples.airline.client.jaxws") {
|
||||
produces(dir: outputDir, includes: "**/*.class")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile("org.springframework.ws:spring-ws-core:$springWsVersion")
|
||||
compile(files(wsImport.outputDir).builtBy(wsImport))
|
||||
runtime("log4j:log4j:1.2.16")
|
||||
wsimport "com.sun.xml.ws:jaxws-tools:2.1.7"
|
||||
}
|
||||
|
||||
task runClient(dependsOn: 'classes', type:JavaExec) {
|
||||
main = "org.springframework.ws.samples.airline.client.jaxws.Main"
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
}
|
||||
286
airline/client/jax-ws/mvnw
vendored
Executable file
286
airline/client/jax-ws/mvnw
vendored
Executable file
@@ -0,0 +1,286 @@
|
||||
#!/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
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Maven2 Start Up Batch script
|
||||
#
|
||||
# Required ENV vars:
|
||||
# ------------------
|
||||
# JAVA_HOME - location of a JDK home dir
|
||||
#
|
||||
# Optional ENV vars
|
||||
# -----------------
|
||||
# M2_HOME - location of maven2's installed home dir
|
||||
# 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 /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
|
||||
export JAVA_HOME="`/usr/libexec/java_home`"
|
||||
else
|
||||
export JAVA_HOME="/Library/Java/Home"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
if [ -r /etc/gentoo-release ] ; then
|
||||
JAVA_HOME=`java-config --jre-home`
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$M2_HOME" ] ; then
|
||||
## resolve links - $0 may be a link to maven's home
|
||||
PRG="$0"
|
||||
|
||||
# need this for relative symlinks
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG="`dirname "$PRG"`/$link"
|
||||
fi
|
||||
done
|
||||
|
||||
saveddir=`pwd`
|
||||
|
||||
M2_HOME=`dirname "$PRG"`/..
|
||||
|
||||
# make it fully qualified
|
||||
M2_HOME=`cd "$M2_HOME" && pwd`
|
||||
|
||||
cd "$saveddir"
|
||||
# echo Using m2 at $M2_HOME
|
||||
fi
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched
|
||||
if $cygwin ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --unix "$M2_HOME"`
|
||||
[ -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 "$M2_HOME" ] &&
|
||||
M2_HOME="`(cd "$M2_HOME"; pwd)`"
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
|
||||
# TODO classpath?
|
||||
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="`which 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
|
||||
|
||||
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
|
||||
|
||||
# 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/.."; pwd`
|
||||
fi
|
||||
# end of workaround
|
||||
done
|
||||
echo "${basedir}"
|
||||
}
|
||||
|
||||
# concatenates all lines of a file
|
||||
concat_lines() {
|
||||
if [ -f "$1" ]; then
|
||||
echo "$(tr -s '\n' ' ' < "$1")"
|
||||
fi
|
||||
}
|
||||
|
||||
BASE_DIR=`find_maven_basedir "$(pwd)"`
|
||||
if [ -z "$BASE_DIR" ]; then
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
##########################################################################################
|
||||
# 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.
|
||||
##########################################################################################
|
||||
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found .mvn/wrapper/maven-wrapper.jar"
|
||||
fi
|
||||
else
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
|
||||
fi
|
||||
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
|
||||
while IFS="=" read key value; do
|
||||
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
|
||||
esac
|
||||
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Downloading from: $jarUrl"
|
||||
fi
|
||||
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
|
||||
|
||||
if command -v wget > /dev/null; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found wget ... using wget"
|
||||
fi
|
||||
wget "$jarUrl" -O "$wrapperJarPath"
|
||||
elif command -v curl > /dev/null; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found curl ... using curl"
|
||||
fi
|
||||
curl -o "$wrapperJarPath" "$jarUrl"
|
||||
else
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Falling back to using Java to download"
|
||||
fi
|
||||
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
|
||||
if [ -e "$javaClass" ]; then
|
||||
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo " - Compiling MavenWrapperDownloader.java ..."
|
||||
fi
|
||||
# Compiling the Java class
|
||||
("$JAVA_HOME/bin/javac" "$javaClass")
|
||||
fi
|
||||
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
||||
# Running the downloader
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo " - Running MavenWrapperDownloader.java ..."
|
||||
fi
|
||||
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
##########################################################################################
|
||||
# End of extension
|
||||
##########################################################################################
|
||||
|
||||
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo $MAVEN_PROJECTBASEDIR
|
||||
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 "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --path --windows "$M2_HOME"`
|
||||
[ -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
|
||||
|
||||
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
exec "$JAVACMD" \
|
||||
$MAVEN_OPTS \
|
||||
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
||||
161
airline/client/jax-ws/mvnw.cmd
vendored
Normal file
161
airline/client/jax-ws/mvnw.cmd
vendored
Normal file
@@ -0,0 +1,161 @@
|
||||
@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 http://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 Maven2 Start Up Batch script
|
||||
@REM
|
||||
@REM Required ENV vars:
|
||||
@REM JAVA_HOME - location of a JDK home dir
|
||||
@REM
|
||||
@REM Optional ENV vars
|
||||
@REM M2_HOME - location of maven2's installed home dir
|
||||
@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 key stroke 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 my 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 "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
|
||||
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\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 DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
|
||||
FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO (
|
||||
IF "%%A"=="wrapperUrl" SET DOWNLOAD_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% (
|
||||
echo Found %WRAPPER_JAR%
|
||||
) else (
|
||||
echo Couldn't find %WRAPPER_JAR%, downloading it ...
|
||||
echo Downloading from: %DOWNLOAD_URL%
|
||||
powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"
|
||||
echo Finished downloading %WRAPPER_JAR%
|
||||
)
|
||||
@REM End of extension
|
||||
|
||||
%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 "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
|
||||
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\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%
|
||||
|
||||
exit /B %ERROR_CODE%
|
||||
120
airline/client/jax-ws/pom.xml
Normal file
120
airline/client/jax-ws/pom.xml
Normal file
@@ -0,0 +1,120 @@
|
||||
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.ws</groupId>
|
||||
<artifactId>spring-ws-samples</artifactId>
|
||||
<version>1.0.0.BUILD-SNAPSHOT</version>
|
||||
<relativePath>../../../</relativePath> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<groupId>org.springframework.ws</groupId>
|
||||
<artifactId>airline-client-jax-ws</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>Spring Web Services Samples - Airline - Client - JAX-WS</name>
|
||||
<description>Demo project for Spring Web Services</description>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<jax-ws.version>2.1.7</jax-ws.version>
|
||||
<log4j.version>1.2.16</log4j.version>
|
||||
<spring-ws.version>2.1.4.RELEASE</spring-ws.version>
|
||||
<sourcesDir>${project.basedir}/target/generated-sources/jaxws</sourcesDir>
|
||||
<classesDir>${project.basedir}/target/classes</classesDir>
|
||||
<wsdl>${project.basedir}/../airline.wsdl</wsdl>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.ws</groupId>
|
||||
<artifactId>spring-ws-core</artifactId>
|
||||
<version>${spring-ws.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>${log4j.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.ws</groupId>
|
||||
<artifactId>jaxws-tools</artifactId>
|
||||
<version>${jax-ws.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun</groupId>
|
||||
<artifactId>tools</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${env.JAVA_HOME}/lib/tools.jar</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>generate-sources</phase>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<taskdef name="wsimport"
|
||||
classname="com.sun.tools.ws.ant.WsImport">
|
||||
<classpath refid="maven.compile.classpath"/>
|
||||
</taskdef>
|
||||
|
||||
<mkdir dir="${sourcesDir}" />
|
||||
<mkdir dir="${classesDir}" />
|
||||
|
||||
<wsimport
|
||||
destdir="${classesDir}"
|
||||
sourcedestdir="${sourcesDir}"
|
||||
keep="true"
|
||||
verbose="true"
|
||||
extension="true"
|
||||
wsdl="${wsdl}"
|
||||
package="org.springframework.ws.samples.airline.client.jaxws">
|
||||
<produces dir="${classesDir}" includes="**/*.class" />
|
||||
</wsimport>
|
||||
</tasks>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<version>1.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>add-source</id>
|
||||
<phase>process-sources</phase>
|
||||
<goals>
|
||||
<goal>add-source</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>${sourcesDir}</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright 2006 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.samples.airline.client.jaxws;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.xml.datatype.DatatypeConfigurationException;
|
||||
import javax.xml.datatype.DatatypeConstants;
|
||||
import javax.xml.datatype.DatatypeFactory;
|
||||
import javax.xml.datatype.XMLGregorianCalendar;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.ws.soap.SOAPFaultException;
|
||||
|
||||
/**
|
||||
* Simple client that calls the <code>GetFlights</code> and <code>BookFlight</code> operations using JAX-WS.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class JaxWsMain {
|
||||
|
||||
public static void main(String[] args) throws MalformedURLException, DatatypeConfigurationException {
|
||||
|
||||
try {
|
||||
AirlineService service;
|
||||
if (args.length == 0) {
|
||||
service = new AirlineService();
|
||||
} else {
|
||||
QName serviceName = new QName("http://www.springframework.org/spring-ws/samples/airline/definitions",
|
||||
"AirlineService");
|
||||
service = new AirlineService(new URL(args[0]), serviceName);
|
||||
}
|
||||
Airline airline = service.getAirlineSoap11();
|
||||
GetFlightsRequest request = new GetFlightsRequest();
|
||||
request.setFrom("AMS");
|
||||
request.setTo("VCE");
|
||||
XMLGregorianCalendar departureDate = DatatypeFactory.newInstance().newXMLGregorianCalendarDate(2006, 1, 31,
|
||||
DatatypeConstants.FIELD_UNDEFINED);
|
||||
request.setDepartureDate(departureDate);
|
||||
System.out.format("Requesting flights on %1tD%n", departureDate.toGregorianCalendar());
|
||||
GetFlightsResponse response = airline.getFlights(request);
|
||||
System.out.format("Got %1d results%n", response.getFlight().size());
|
||||
if (!response.getFlight().isEmpty())
|
||||
// Book the first flight using John Doe as a frequent flyer
|
||||
{
|
||||
Flight flight = response.getFlight().get(0);
|
||||
BookFlightRequest bookFlightRequest = new BookFlightRequest();
|
||||
bookFlightRequest.setFlightNumber(flight.getNumber());
|
||||
bookFlightRequest.setDepartureTime(flight.getDepartureTime());
|
||||
BookFlightRequest.Passengers passengers = new BookFlightRequest.Passengers();
|
||||
passengers.getPassengerOrUsername().add("john");
|
||||
bookFlightRequest.setPassengers(passengers);
|
||||
Ticket ticket = airline.bookFlight(bookFlightRequest);
|
||||
writeTicket(ticket);
|
||||
}
|
||||
} catch (SOAPFaultException ex) {
|
||||
System.out.format("SOAP Fault Code %1s%n", ex.getFault().getFaultCodeAsQName());
|
||||
System.out.format("SOAP Fault String: %1s%n", ex.getFault().getFaultString());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static void writeTicket(Ticket ticket) {
|
||||
|
||||
System.out.format("Ticket %1d%n", ticket.getId());
|
||||
System.out.format("Ticket issue date:\t%1tD%n", ticket.getIssueDate().toGregorianCalendar());
|
||||
for (Name passenger : ticket.getPassengers().getPassenger()) {
|
||||
writeName(passenger);
|
||||
|
||||
}
|
||||
writeFlight(ticket.flight);
|
||||
}
|
||||
|
||||
private static void writeName(Name name) {
|
||||
|
||||
System.out.format("Passenger Name:%n");
|
||||
System.out.format("%1s %2s%n", name.getFirst(), name.getLast());
|
||||
System.out.format("------------%n");
|
||||
}
|
||||
|
||||
private static void writeFlight(Flight flight) {
|
||||
|
||||
System.out.format("%1tD%n", flight.getDepartureTime().toGregorianCalendar());
|
||||
System.out.format("%1s\t%2s%n", flight.getNumber(), flight.getServiceClass());
|
||||
System.out.format("------------%n");
|
||||
System.out.format("Depart:\t%1s-%2s\t%tR%n", flight.getFrom().getCode(), flight.getFrom().getName(),
|
||||
flight.getDepartureTime().toGregorianCalendar());
|
||||
System.out.format("\t%1s%n", flight.getFrom().getCity());
|
||||
System.out.format("Arrive:\t%1s-%2s\t%tR%n", flight.getTo().getCode(), flight.getTo().getName(),
|
||||
flight.getArrivalTime().toGregorianCalendar());
|
||||
System.out.format("\t%1s%n", flight.getTo().getCity());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
/*
|
||||
* Copyright 2006 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.samples.airline.client.jaxws;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import javax.xml.datatype.DatatypeConfigurationException;
|
||||
import javax.xml.datatype.DatatypeConstants;
|
||||
import javax.xml.datatype.DatatypeFactory;
|
||||
import javax.xml.datatype.XMLGregorianCalendar;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.ws.soap.SOAPFaultException;
|
||||
|
||||
/**
|
||||
* Simple client that calls the <code>GetFlights</code> and <code>BookFlight</code> operations using JAX-WS.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) throws MalformedURLException, DatatypeConfigurationException {
|
||||
try {
|
||||
AirlineService service;
|
||||
if (args.length == 0) {
|
||||
service = new AirlineService();
|
||||
}
|
||||
else {
|
||||
QName serviceName = new QName("http://www.springframework.org/spring-ws/samples/airline/definitions",
|
||||
"AirlineService");
|
||||
service = new AirlineService(new URL(args[0]), serviceName);
|
||||
}
|
||||
Airline airline = service.getAirlineSoap11();
|
||||
GetFlightsRequest request = new GetFlightsRequest();
|
||||
request.setFrom("AMS");
|
||||
request.setTo("VCE");
|
||||
XMLGregorianCalendar departureDate =
|
||||
DatatypeFactory.newInstance().newXMLGregorianCalendarDate(2006, 1, 31,
|
||||
DatatypeConstants.FIELD_UNDEFINED);
|
||||
request.setDepartureDate(departureDate);
|
||||
System.out.format("Requesting flights on %1tD%n", departureDate.toGregorianCalendar());
|
||||
GetFlightsResponse response = airline.getFlights(request);
|
||||
System.out.format("Got %1d results%n", response.getFlight().size());
|
||||
if (!response.getFlight().isEmpty())
|
||||
// Book the first flight using John Doe as a frequent flyer
|
||||
{
|
||||
Flight flight = response.getFlight().get(0);
|
||||
BookFlightRequest bookFlightRequest = new BookFlightRequest();
|
||||
bookFlightRequest.setFlightNumber(flight.getNumber());
|
||||
bookFlightRequest.setDepartureTime(flight.getDepartureTime());
|
||||
BookFlightRequest.Passengers passengers = new BookFlightRequest.Passengers();
|
||||
passengers.getPassengerOrUsername().add("john");
|
||||
bookFlightRequest.setPassengers(passengers);
|
||||
Ticket ticket = airline.bookFlight(bookFlightRequest);
|
||||
writeTicket(ticket);
|
||||
}
|
||||
}
|
||||
catch (SOAPFaultException ex) {
|
||||
System.out.format("SOAP Fault Code %1s%n", ex.getFault().getFaultCodeAsQName());
|
||||
System.out.format("SOAP Fault String: %1s%n", ex.getFault().getFaultString());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static void writeTicket(Ticket ticket) {
|
||||
System.out.format("Ticket %1d%n", ticket.getId());
|
||||
System.out.format("Ticket issue date:\t%1tD%n", ticket.getIssueDate().toGregorianCalendar());
|
||||
for (Name passenger : ticket.getPassengers().getPassenger()) {
|
||||
writeName(passenger);
|
||||
|
||||
}
|
||||
writeFlight(ticket.flight);
|
||||
}
|
||||
|
||||
private static void writeName(Name name) {
|
||||
System.out.format("Passenger Name:%n");
|
||||
System.out.format("%1s %2s%n", name.getFirst(), name.getLast());
|
||||
System.out.format("------------%n");
|
||||
}
|
||||
|
||||
private static void writeFlight(Flight flight) {
|
||||
System.out.format("%1tD%n", flight.getDepartureTime().toGregorianCalendar());
|
||||
System.out.format("%1s\t%2s%n", flight.getNumber(), flight.getServiceClass());
|
||||
System.out.format("------------%n");
|
||||
System.out.format("Depart:\t%1s-%2s\t%tR%n", flight.getFrom().getCode(), flight.getFrom().getName(), flight.getDepartureTime().toGregorianCalendar());
|
||||
System.out.format("\t%1s%n", flight.getFrom().getCity());
|
||||
System.out.format("Arrive:\t%1s-%2s\t%tR%n", flight.getTo().getCode(), flight.getTo().getName(), flight.getArrivalTime().toGregorianCalendar());
|
||||
System.out.format("\t%1s%n", flight.getTo().getCity());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
ext.springWsVersion = '2.1.4.RELEASE'
|
||||
|
||||
dependencies {
|
||||
compile("org.springframework.ws:spring-ws-core:$springWsVersion")
|
||||
compile("org.springframework.ws:spring-ws-support:$springWsVersion")
|
||||
compile("org.apache.geronimo.specs:geronimo-jms_1.1_spec:1.1")
|
||||
runtime("log4j:log4j:1.2.16")
|
||||
runtime("org.apache.activemq:activemq-core:4.1.2")
|
||||
}
|
||||
|
||||
task runClient(dependsOn: 'classes', type:JavaExec) {
|
||||
main = "org.springframework.ws.samples.airline.client.jms.JmsClient"
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
}
|
||||
62
airline/client/jms/pom.xml
Normal file
62
airline/client/jms/pom.xml
Normal file
@@ -0,0 +1,62 @@
|
||||
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.ws</groupId>
|
||||
<artifactId>spring-ws-samples</artifactId>
|
||||
<version>1.0.0.BUILD-SNAPSHOT</version>
|
||||
<relativePath>../../../</relativePath> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<groupId>org.springframework.ws</groupId>
|
||||
<artifactId>airline-client-jms</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>Spring Web Services Samples - Airline - Client - JMS</name>
|
||||
<description>Demo project for Spring Web Services</description>
|
||||
|
||||
<properties>
|
||||
<activemq.version>4.1.2</activemq.version>
|
||||
<java.version>1.8</java.version>
|
||||
<jms.version>1.1</jms.version>
|
||||
<log4j.version>1.2.16</log4j.version>
|
||||
<sourcesDir>${project.basedir}/target/generated-sources/jaxws</sourcesDir>
|
||||
<classesDir>${project.basedir}/target/classes</classesDir>
|
||||
<wsdl>${project.basedir}/../airline.wsdl</wsdl>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.ws</groupId>
|
||||
<artifactId>spring-ws-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.ws</groupId>
|
||||
<artifactId>spring-ws-support</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.geronimo.specs</groupId>
|
||||
<artifactId>geronimo-jms_1.1_spec</artifactId>
|
||||
<version>${jms.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>${log4j.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.activemq</groupId>
|
||||
<artifactId>activemq-core</artifactId>
|
||||
<version>${activemq.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -16,10 +16,6 @@
|
||||
|
||||
package org.springframework.ws.samples.airline.client.jms;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.jms.JMSException;
|
||||
import javax.xml.soap.SOAPException;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
@@ -30,19 +26,11 @@ import org.springframework.xml.transform.StringSource;
|
||||
/** @author Arjen Poutsma */
|
||||
public class JmsClient extends WebServiceGatewaySupport {
|
||||
|
||||
private static final String PAYLOAD =
|
||||
"<airline:GetFlightsRequest xmlns:airline=\"http://www.springframework.org/spring-ws/samples/airline/schemas/messages\">" +
|
||||
"<airline:from>AMS</airline:from>" + "<airline:to>VCE</airline:to>" +
|
||||
"<airline:departureDate>2006-01-31</airline:departureDate>" + "</airline:GetFlightsRequest>";
|
||||
private static final String PAYLOAD = "<airline:GetFlightsRequest xmlns:airline=\"http://www.springframework.org/spring-ws/samples/airline/schemas/messages\">"
|
||||
+ "<airline:from>AMS</airline:from>" + "<airline:to>VCE</airline:to>"
|
||||
+ "<airline:departureDate>2006-01-31</airline:departureDate>" + "</airline:GetFlightsRequest>";
|
||||
|
||||
public void getFlights() throws SOAPException, IOException, TransformerException, JMSException {
|
||||
getWebServiceTemplate().sendSourceAndReceiveToResult(new StringSource(PAYLOAD), new StreamResult(System.out));
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
ApplicationContext applicationContext =
|
||||
new ClassPathXmlApplicationContext("applicationContext.xml", JmsClient.class);
|
||||
JmsClient jmsClient = (JmsClient) applicationContext.getBean("jmsClient", JmsClient.class);
|
||||
jmsClient.getFlights();
|
||||
}
|
||||
}
|
||||
public void getFlights() {
|
||||
getWebServiceTemplate().sendSourceAndReceiveToResult(new StringSource(PAYLOAD), new StreamResult(System.out));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright 2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.samples.airline.client.jms;
|
||||
|
||||
import javax.jms.ConnectionFactory;
|
||||
|
||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.ws.transport.jms.JmsMessageSender;
|
||||
|
||||
/**
|
||||
* Java configuration for setting up a JMS-based client.
|
||||
*
|
||||
* @author Greg Turnquist
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class JmsConfiguration {
|
||||
|
||||
@Bean
|
||||
ConnectionFactory connectionFactory() {
|
||||
return new ActiveMQConnectionFactory("tcp://localhost:61616");
|
||||
}
|
||||
|
||||
@Bean
|
||||
JmsMessageSender jmsMessageSender(ConnectionFactory connectionFactory) {
|
||||
return new JmsMessageSender(connectionFactory);
|
||||
}
|
||||
|
||||
@Bean
|
||||
JmsClient jmsClient(JmsMessageSender messageSender) {
|
||||
|
||||
JmsClient jmsClient = new JmsClient();
|
||||
jmsClient.setDefaultUri("jms:RequestQueue");
|
||||
jmsClient.setMessageSender(messageSender);
|
||||
return jmsClient;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.samples.airline.client.jms;
|
||||
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
|
||||
/**
|
||||
* "Main" that creates a {@link JmsClient} and uses it to talk to the SOAP-based server.
|
||||
*
|
||||
* @author Greg Turnquist
|
||||
*/
|
||||
public class JmsMain {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(JmsConfiguration.class);
|
||||
|
||||
ctx.getBean(JmsClient.class).getFlights();
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
|
||||
|
||||
<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
|
||||
<property name="brokerURL" value="tcp://localhost:61616"/>
|
||||
</bean>
|
||||
|
||||
<bean id="jmsClient" class="org.springframework.ws.samples.airline.client.jms.JmsClient">
|
||||
<property name="defaultUri" value="jms:RequestQueue"/>
|
||||
<property name="messageSenders">
|
||||
<bean class="org.springframework.ws.transport.jms.JmsMessageSender">
|
||||
<property name="connectionFactory" ref="connectionFactory"/>
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@@ -1,10 +0,0 @@
|
||||
dependencies {
|
||||
compile("com.sun.xml.wss:xws-security:3.0") {
|
||||
exclude group: 'javax.xml.crypto', module: 'xmldsig'
|
||||
}
|
||||
}
|
||||
|
||||
task runClient(dependsOn: 'classes', type:JavaExec) {
|
||||
main = "org.springframework.ws.samples.airline.client.saaj.Driver"
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
}
|
||||
86
airline/client/saaj/pom.xml
Normal file
86
airline/client/saaj/pom.xml
Normal file
@@ -0,0 +1,86 @@
|
||||
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.ws</groupId>
|
||||
<artifactId>spring-ws-samples</artifactId>
|
||||
<version>1.0.0.BUILD-SNAPSHOT</version>
|
||||
<relativePath>../../../</relativePath> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<groupId>org.springframework.ws</groupId>
|
||||
<artifactId>airline-client-saaj</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>Spring Web Services Samples - Airline - Client - SAAJ</name>
|
||||
<description>Demo project for Spring Web Services</description>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<xws.version>3.0</xws.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.wss</groupId>
|
||||
<artifactId>xws-security</artifactId>
|
||||
<version>${xws.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>javax.xml.crypto</groupId>
|
||||
<artifactId>xmldsig</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>javax.activation</groupId>
|
||||
<artifactId>activation</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>javax.activation</groupId>-->
|
||||
<!-- <artifactId>activation</artifactId>-->
|
||||
<!-- <version>1.1</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
</dependencies>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-snapshots</id>
|
||||
<name>Spring Snapshots</name>
|
||||
<url>https://repo.spring.io/snapshot</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>spring-snapshots</id>
|
||||
<name>Spring Snapshots</name>
|
||||
<url>https://repo.spring.io/snapshot</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
<pluginRepository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
</project>
|
||||
@@ -16,23 +16,32 @@
|
||||
|
||||
package org.springframework.ws.samples.airline.client.saaj;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class Driver {
|
||||
public class SaajMain {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(SaajMain.class);
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
String url = "http://localhost:8080/airline-server/services";
|
||||
if (args.length > 0) {
|
||||
url = args[0];
|
||||
}
|
||||
|
||||
logger.info("Connecting to " + url + " for flight details...");
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
String url = "http://localhost:8080/airline-server/services";
|
||||
if (args.length > 0) {
|
||||
url = args[0];
|
||||
}
|
||||
GetFlights getFlights = new GetFlights(url);
|
||||
getFlights.getFlights();
|
||||
getFlights.getFlights();
|
||||
|
||||
String username = "john";
|
||||
String password = "changeme";
|
||||
GetFrequentFlyerMileage getMileage = new GetFrequentFlyerMileage(url);
|
||||
getMileage.getMileage(username, password);
|
||||
}
|
||||
String username = "john";
|
||||
String password = "changeme";
|
||||
GetFrequentFlyerMileage getMileage = new GetFrequentFlyerMileage(url);
|
||||
getMileage.getMileage(username, password);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
logging.level.org.springframework.ws=TRACE
|
||||
logging.level.javax.xml.soap=TRACE
|
||||
logging.level.com.sun.xml=TRACE
|
||||
logging.level.javax.security.auth=TRACE
|
||||
@@ -1,3 +1,3 @@
|
||||
<xwss:SecurityConfiguration dumpMessages="false" xmlns:xwss="https://java.sun.com/xml/ns/xwss/config">
|
||||
<xwss:SecurityConfiguration dumpMessages="false" xmlns:xwss="http://java.sun.com/xml/ns/xwss/config">
|
||||
<xwss:UsernameToken digestPassword="true" useNonce="true"/>
|
||||
</xwss:SecurityConfiguration>
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
configurations {
|
||||
xmlbeans
|
||||
}
|
||||
|
||||
ext.springWsVersion = '2.1.4.RELEASE'
|
||||
|
||||
task xmlbeans {
|
||||
ext.schema = "${projectDir}/../../server/src/main/webapp/messages.xsd"
|
||||
ext.classesDir = "${buildDir}/classes/xmlbeans"
|
||||
|
||||
inputs.files schema
|
||||
outputs.dir classesDir
|
||||
|
||||
doLast() {
|
||||
project.ant {
|
||||
taskdef name: "xmlbeans",
|
||||
classname: "org.apache.xmlbeans.impl.tool.XMLBean",
|
||||
classpath: configurations.xmlbeans.asPath
|
||||
|
||||
xmlbeans(classgendir: classesDir, schema: schema,
|
||||
compiler: "modern", verbose: "false",
|
||||
classpath: configurations.xmlbeans.asPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile(files(xmlbeans.classesDir).builtBy(xmlbeans))
|
||||
compile("org.apache.xmlbeans:xmlbeans:2.4.0")
|
||||
compile("org.springframework.ws:spring-ws-core:$springWsVersion")
|
||||
runtime("org.springframework.ws:spring-ws-security:$springWsVersion") {
|
||||
exclude group: 'com.sun.xml.wsit', module: 'wsit-rt'
|
||||
exclude group: 'com.sun.xml.wsit', module: 'xws-security'
|
||||
}
|
||||
runtime("com.sun.xml.wss:xws-security:3.0") {
|
||||
exclude group: 'javax.xml.crypto', module: 'xmldsig'
|
||||
}
|
||||
runtime("log4j:log4j:1.2.16")
|
||||
testCompile("org.springframework.ws:spring-ws-test:$springWsVersion")
|
||||
xmlbeans("org.apache.xmlbeans:xmlbeans:2.4.0")
|
||||
}
|
||||
|
||||
task runClient(dependsOn: 'classes', type:JavaExec) {
|
||||
main = "org.springframework.ws.samples.airline.client.sws.Driver"
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
}
|
||||
135
airline/client/spring-ws/pom.xml
Normal file
135
airline/client/spring-ws/pom.xml
Normal file
@@ -0,0 +1,135 @@
|
||||
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.ws</groupId>
|
||||
<artifactId>spring-ws-samples</artifactId>
|
||||
<version>1.0.0.BUILD-SNAPSHOT</version>
|
||||
<relativePath>../../../</relativePath> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<groupId>org.springframework.ws</groupId>
|
||||
<artifactId>airline-client-spring-ws</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>Spring Web Services Samples - Airline - Client - Spring WS</name>
|
||||
<description>Demo project for Spring Web Services</description>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<jax-ws.version>2.1.7</jax-ws.version>
|
||||
<log4j.version>1.2.16</log4j.version>
|
||||
<xmlbeans.version>2.4.0</xmlbeans.version>
|
||||
<xws.version>3.0</xws.version>
|
||||
<sourcesDir>${project.basedir}/target/generated-sources/xjc</sourcesDir>
|
||||
<classesDir>${project.basedir}/target/classes</classesDir>
|
||||
<schema>${project.basedir}/../../server/src/main/resources</schema>
|
||||
<wsdl>${project.basedir}/../airline.wsdl</wsdl>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.ws</groupId>
|
||||
<artifactId>spring-ws-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.ws</groupId>
|
||||
<artifactId>spring-ws-security</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.sun.xml.wsit</groupId>
|
||||
<artifactId>wsit-rt</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.sun.xml.wsit</groupId>
|
||||
<artifactId>xws-security</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.wss</groupId>
|
||||
<artifactId>xws-security</artifactId>
|
||||
<version>${xws.version}</version>
|
||||
<scope>runtime</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>javax.xml.crypto</groupId>
|
||||
<artifactId>xmldsig</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>javax.activation</groupId>
|
||||
<artifactId>activation</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>${log4j.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.ws</groupId>
|
||||
<artifactId>spring-ws-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.jvnet.jaxb2.maven2</groupId>
|
||||
<artifactId>maven-jaxb2-plugin</artifactId>
|
||||
<version>0.14.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>generate</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<schemaLanguage>WSDL</schemaLanguage>
|
||||
<generatePackage>org.springframework.springWs.samples.airline.schemas</generatePackage>
|
||||
<schemas>
|
||||
<schema>
|
||||
<url>${wsdl}</url>
|
||||
</schema>
|
||||
</schemas>
|
||||
<addCompileSourceRoot>true</addCompileSourceRoot>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<version>1.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>add-source</id>
|
||||
<phase>process-sources</phase>
|
||||
<goals>
|
||||
<goal>add-source</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>${sourcesDir}</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright 2005-2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.samples.airline.client.sws;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class Driver {
|
||||
|
||||
public static void main(String[] args) {
|
||||
ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
|
||||
"org/springframework/ws/samples/airline/client/sws/applicationContext.xml");
|
||||
GetFlights getFlights = applicationContext.getBean("getFlights", GetFlights.class);
|
||||
getFlights.getFlights();
|
||||
|
||||
GetFrequentFlyerMileage getFrequentFlyerMileage = applicationContext
|
||||
.getBean("getFrequentFlyerMileage", GetFrequentFlyerMileage.class);
|
||||
getFrequentFlyerMileage.getFrequentFlyerMileage();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,87 +16,87 @@
|
||||
|
||||
package org.springframework.ws.samples.airline.client.sws;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import javax.xml.datatype.DatatypeConfigurationException;
|
||||
import javax.xml.datatype.DatatypeConstants;
|
||||
import javax.xml.datatype.DatatypeFactory;
|
||||
import javax.xml.datatype.XMLGregorianCalendar;
|
||||
|
||||
import org.springframework.springWs.samples.airline.schemas.messages.BookFlightRequestDocument;
|
||||
import org.springframework.springWs.samples.airline.schemas.messages.BookFlightResponseDocument;
|
||||
import org.springframework.springWs.samples.airline.schemas.messages.GetFlightsRequestDocument;
|
||||
import org.springframework.springWs.samples.airline.schemas.messages.GetFlightsResponseDocument;
|
||||
import org.springframework.springWs.samples.airline.schemas.types.Flight;
|
||||
import org.springframework.springWs.samples.airline.schemas.types.Name;
|
||||
import org.springframework.springWs.samples.airline.schemas.types.Ticket;
|
||||
import org.springframework.springWs.samples.airline.schemas.BookFlightRequest;
|
||||
import org.springframework.springWs.samples.airline.schemas.Flight;
|
||||
import org.springframework.springWs.samples.airline.schemas.GetFlightsRequest;
|
||||
import org.springframework.springWs.samples.airline.schemas.GetFlightsResponse;
|
||||
import org.springframework.springWs.samples.airline.schemas.Name;
|
||||
import org.springframework.springWs.samples.airline.schemas.Ticket;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.ws.WebServiceMessageFactory;
|
||||
import org.springframework.ws.client.core.support.WebServiceGatewaySupport;
|
||||
|
||||
public class GetFlights extends WebServiceGatewaySupport {
|
||||
|
||||
public GetFlights(WebServiceMessageFactory messageFactory) {
|
||||
super(messageFactory);
|
||||
}
|
||||
public GetFlights(WebServiceMessageFactory messageFactory) {
|
||||
super(messageFactory);
|
||||
}
|
||||
|
||||
public void getFlights() {
|
||||
GetFlightsRequestDocument getFlightsRequestDocument = GetFlightsRequestDocument.Factory.newInstance();
|
||||
GetFlightsRequestDocument.GetFlightsRequest getFlightsRequest =
|
||||
getFlightsRequestDocument.addNewGetFlightsRequest();
|
||||
getFlightsRequest.setFrom("AMS");
|
||||
getFlightsRequest.setTo("VCE");
|
||||
Calendar departureDate = Calendar.getInstance();
|
||||
departureDate.clear();
|
||||
departureDate.set(2006, Calendar.JANUARY, 31);
|
||||
getFlightsRequest.setDepartureDate(departureDate);
|
||||
public void getFlights() {
|
||||
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
System.out.println("Requesting flights on " + dateFormat.format(departureDate.getTime()));
|
||||
GetFlightsResponseDocument getFlightsResponseDocument =
|
||||
(GetFlightsResponseDocument) getWebServiceTemplate().marshalSendAndReceive(getFlightsRequestDocument);
|
||||
GetFlightsResponseDocument.GetFlightsResponse response = getFlightsResponseDocument.getGetFlightsResponse();
|
||||
System.out.println("Got " + response.sizeOfFlightArray() + " results");
|
||||
if (response.sizeOfFlightArray() > 0) {
|
||||
// Book the first flight using John Doe as a frequent flyer
|
||||
BookFlightRequestDocument bookFlightRequestDocument = BookFlightRequestDocument.Factory.newInstance();
|
||||
BookFlightRequestDocument.BookFlightRequest bookFlightRequest =
|
||||
bookFlightRequestDocument.addNewBookFlightRequest();
|
||||
bookFlightRequest.setFlightNumber(response.getFlightArray(0).getNumber());
|
||||
bookFlightRequest.setDepartureTime(response.getFlightArray(0).getDepartureTime());
|
||||
BookFlightRequestDocument.BookFlightRequest.Passengers passengers = bookFlightRequest.addNewPassengers();
|
||||
passengers.addUsername("john");
|
||||
GetFlightsRequest getFlightsRequest = new GetFlightsRequest();
|
||||
getFlightsRequest.setFrom("AMS");
|
||||
getFlightsRequest.setTo("VCE");
|
||||
XMLGregorianCalendar departureDate = null;
|
||||
try {
|
||||
departureDate = DatatypeFactory.newInstance().newXMLGregorianCalendarDate(2006, 1, 31,
|
||||
DatatypeConstants.FIELD_UNDEFINED);
|
||||
} catch (DatatypeConfigurationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
BookFlightResponseDocument bookFlightResponseDocument = (BookFlightResponseDocument) getWebServiceTemplate()
|
||||
.marshalSendAndReceive(bookFlightRequestDocument);
|
||||
Ticket ticket = bookFlightResponseDocument.getBookFlightResponse();
|
||||
writeTicket(ticket);
|
||||
}
|
||||
}
|
||||
getFlightsRequest.setDepartureDate(departureDate);
|
||||
|
||||
private void writeTicket(Ticket ticket) {
|
||||
System.out.println("Ticket " + ticket.getId());
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
System.out.println("Ticket issue date:\t" + dateFormat.format(ticket.getIssueDate().getTime()));
|
||||
for (int i = 0; i < ticket.getPassengers().sizeOfPassengerArray(); i++) {
|
||||
writeName(ticket.getPassengers().getPassengerArray(i));
|
||||
System.out.println("Requesting flights on " + departureDate);
|
||||
GetFlightsResponse response = (GetFlightsResponse) getWebServiceTemplate().marshalSendAndReceive(getFlightsRequest);
|
||||
System.out.println("Got " + response.getFlight().size() + " results");
|
||||
if (response.getFlight().size() > 0) {
|
||||
// Book the first flight using John Doe as a frequent flyer
|
||||
BookFlightRequest bookFlightRequest = new BookFlightRequest();
|
||||
bookFlightRequest.setFlightNumber(response.getFlight().get(0).getNumber());
|
||||
bookFlightRequest.setDepartureTime(response.getFlight().get(0).getDepartureTime());
|
||||
BookFlightRequest.Passengers passengers = new BookFlightRequest.Passengers();
|
||||
passengers.getPassengerOrUsername().add("john");
|
||||
bookFlightRequest.setPassengers(passengers);
|
||||
|
||||
}
|
||||
writeFlight(ticket.getFlight());
|
||||
}
|
||||
JAXBElement<Ticket> ticket = (JAXBElement<Ticket>) getWebServiceTemplate()
|
||||
.marshalSendAndReceive(bookFlightRequest);
|
||||
|
||||
private void writeName(Name name) {
|
||||
System.out.println("Passenger Name:");
|
||||
System.out.println(name.getFirst() + " " + name.getLast());
|
||||
System.out.println("------------");
|
||||
}
|
||||
writeTicket(ticket.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
private void writeFlight(Flight flight) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||
System.out.println(dateFormat.format(flight.getDepartureTime().getTime()));
|
||||
System.out.println(flight.getNumber() + "\t" + flight.getServiceClass());
|
||||
System.out.println("------------");
|
||||
System.out.println("Depart:\t" + flight.getFrom().getCode() + "-" + flight.getFrom().getName() + "\t" +
|
||||
dateFormat.format(flight.getDepartureTime().getTime()));
|
||||
System.out.println("\t" + flight.getFrom().getCity());
|
||||
System.out.println("Arrive:\t" + flight.getTo().getCode() + "-" + flight.getTo().getName() + "\t" +
|
||||
dateFormat.format(flight.getArrivalTime().getTime()));
|
||||
System.out.println("\t" + flight.getTo().getCity());
|
||||
}
|
||||
private void writeTicket(Ticket ticket) {
|
||||
|
||||
System.out.println("Ticket " + ticket.getId());
|
||||
System.out.println("Ticket issue date:\t" + ticket.getIssueDate());
|
||||
ticket.getPassengers().getPassenger().forEach(this::writeName);
|
||||
writeFlight(ticket.getFlight());
|
||||
}
|
||||
|
||||
private void writeName(Name name) {
|
||||
|
||||
System.out.println("Passenger Name:");
|
||||
System.out.println(name.getFirst() + " " + name.getLast());
|
||||
System.out.println("------------");
|
||||
}
|
||||
|
||||
private void writeFlight(Flight flight) {
|
||||
|
||||
System.out.println(flight.getDepartureTime());
|
||||
System.out.println(flight.getNumber() + "\t" + flight.getServiceClass());
|
||||
System.out.println("------------");
|
||||
System.out.println(
|
||||
"Depart:\t" + flight.getFrom().getCode() + "-" + flight.getFrom().getName() + "\t" + flight.getDepartureTime());
|
||||
System.out.println("\t" + flight.getFrom().getCity());
|
||||
System.out.println(
|
||||
"Arrive:\t" + flight.getTo().getCode() + "-" + flight.getTo().getName() + "\t" + flight.getArrivalTime());
|
||||
System.out.println("\t" + flight.getTo().getCity());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,16 +25,17 @@ import org.springframework.xml.transform.StringSource;
|
||||
|
||||
public class GetFrequentFlyerMileage extends WebServiceGatewaySupport {
|
||||
|
||||
public GetFrequentFlyerMileage(WebServiceMessageFactory messageFactory) {
|
||||
super(messageFactory);
|
||||
}
|
||||
public GetFrequentFlyerMileage(WebServiceMessageFactory messageFactory) {
|
||||
super(messageFactory);
|
||||
}
|
||||
|
||||
public void getFrequentFlyerMileage() {
|
||||
Source source = new StringSource(
|
||||
"<GetFrequentFlyerMileageRequest xmlns=\"http://www.springframework.org/spring-ws/samples/airline/schemas/messages\" />");
|
||||
public void getFrequentFlyerMileage() {
|
||||
|
||||
getWebServiceTemplate().sendSourceAndReceiveToResult(source, new StreamResult(System.out));
|
||||
Source source = new StringSource(
|
||||
"<GetFrequentFlyerMileageRequest xmlns=\"http://www.springframework.org/spring-ws/samples/airline/schemas/messages\" />");
|
||||
|
||||
}
|
||||
getWebServiceTemplate().sendSourceAndReceiveToResult(source, new StreamResult(System.out));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2005-2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.samples.airline.client.sws;
|
||||
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class SpringWsMain {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(WsConfiguration.class);
|
||||
|
||||
GetFlights getFlights = ctx.getBean(GetFlights.class);
|
||||
getFlights.getFlights();
|
||||
|
||||
GetFrequentFlyerMileage getFrequentFlyerMileage = ctx.getBean(GetFrequentFlyerMileage.class);
|
||||
getFrequentFlyerMileage.getFrequentFlyerMileage();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package org.springframework.ws.samples.airline.client.sws;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.oxm.jaxb.Jaxb2Marshaller;
|
||||
import org.springframework.ws.soap.SoapMessageFactory;
|
||||
import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;
|
||||
import org.springframework.ws.soap.security.wss4j2.Wss4jSecurityInterceptor;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class WsConfiguration {
|
||||
|
||||
@Bean
|
||||
SoapMessageFactory messageFactory() {
|
||||
return new SaajSoapMessageFactory();
|
||||
}
|
||||
|
||||
@Bean
|
||||
Jaxb2Marshaller marshaller() {
|
||||
|
||||
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
|
||||
marshaller.setPackagesToScan("org.springframework.springWs.samples.airline.schemas");
|
||||
return marshaller;
|
||||
}
|
||||
|
||||
@Bean
|
||||
GetFlights getFlights(SoapMessageFactory messageFactory, Jaxb2Marshaller marshaller) {
|
||||
|
||||
GetFlights getFlights = new GetFlights(messageFactory);
|
||||
getFlights.setDefaultUri("http://localhost:8080/airline-server/services");
|
||||
getFlights.setMarshaller(marshaller);
|
||||
getFlights.setUnmarshaller(marshaller);
|
||||
return getFlights;
|
||||
}
|
||||
|
||||
@Bean
|
||||
GetFrequentFlyerMileage getFrequentFlyerMileage(SoapMessageFactory messageFactory,
|
||||
Wss4jSecurityInterceptor securityInterceptor) {
|
||||
|
||||
GetFrequentFlyerMileage getFrequentFlyerMileage = new GetFrequentFlyerMileage(messageFactory);
|
||||
getFrequentFlyerMileage.setDefaultUri("http://localhost:8080/airline-server/services");
|
||||
getFrequentFlyerMileage.setInterceptors(new Wss4jSecurityInterceptor[] { securityInterceptor });
|
||||
return getFrequentFlyerMileage;
|
||||
}
|
||||
|
||||
@Bean
|
||||
Wss4jSecurityInterceptor securityInterceptor() {
|
||||
|
||||
Wss4jSecurityInterceptor interceptor = new Wss4jSecurityInterceptor();
|
||||
interceptor.setSecurementActions("UsernameToken");
|
||||
interceptor.setSecurementUsername("john");
|
||||
interceptor.setSecurementPassword("changeme");
|
||||
return interceptor;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
|
||||
|
||||
<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory"/>
|
||||
|
||||
<bean id="abstractClient" abstract="true">
|
||||
<constructor-arg ref="messageFactory"/>
|
||||
<property name="defaultUri" value="http://localhost:8080/airline-server/services"/>
|
||||
</bean>
|
||||
|
||||
<bean id="marshaller" class="org.springframework.oxm.xmlbeans.XmlBeansMarshaller"/>
|
||||
|
||||
<bean id="getFlights" parent="abstractClient" class="org.springframework.ws.samples.airline.client.sws.GetFlights">
|
||||
<property name="marshaller" ref="marshaller"/>
|
||||
<property name="unmarshaller" ref="marshaller"/>
|
||||
</bean>
|
||||
|
||||
<bean id="getFrequentFlyerMileage" parent="abstractClient"
|
||||
class="org.springframework.ws.samples.airline.client.sws.GetFrequentFlyerMileage">
|
||||
<property name="interceptors" ref="securityInterceptor"/>
|
||||
</bean>
|
||||
|
||||
<bean id="securityInterceptor" class="org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor">
|
||||
<property name="securementActions" value="UsernameToken"/>
|
||||
<property name="securementUsername" value="john"/>
|
||||
<property name="securementPassword" value="changeme"/>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@@ -16,85 +16,78 @@
|
||||
|
||||
package org.springframework.ws.samples.airline.client.sws;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import javax.xml.transform.Source;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.xml.transform.StringSource;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.ws.test.client.MockWebServiceServer;
|
||||
import static org.springframework.ws.test.client.RequestMatchers.*;
|
||||
import static org.springframework.ws.test.client.ResponseCreators.*;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.transform.Source;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.ws.test.client.MockWebServiceServer;
|
||||
import org.springframework.xml.transform.StringSource;
|
||||
|
||||
/**
|
||||
* This test illustrates the use of the client-side testing API, introduced in Spring-WS 2.0.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("applicationContext.xml")
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@Import(WsConfiguration.class)
|
||||
public class GetFlightsTest {
|
||||
|
||||
@Autowired
|
||||
GetFlights getFlights;
|
||||
|
||||
private MockWebServiceServer mockServer;
|
||||
@Autowired GetFlights getFlights;
|
||||
|
||||
private static final String MESSAGES_NS =
|
||||
"http://www.springframework.org/spring-ws/samples/airline/schemas/messages";
|
||||
private MockWebServiceServer mockServer;
|
||||
|
||||
private static final String TYPES_NS = "http://www.springframework.org/spring-ws/samples/airline/schemas/types";
|
||||
private static final String MESSAGES_NS = "http://www.springframework.org/spring-ws/samples/airline/schemas/messages";
|
||||
|
||||
@Before
|
||||
public void setUpMocks() throws Exception {
|
||||
mockServer = MockWebServiceServer.createServer(getFlights);
|
||||
}
|
||||
private static final String TYPES_NS = "http://www.springframework.org/spring-ws/samples/airline/schemas/types";
|
||||
|
||||
@Test
|
||||
public void getFlights() throws Exception {
|
||||
Source getFlightsRequest = new StringSource(
|
||||
"<GetFlightsRequest xmlns='" + MESSAGES_NS + "'>" + "<from>AMS</from>" + "<to>VCE</to>" +
|
||||
"<departureDate>2006-01-31</departureDate>" + "</GetFlightsRequest>");
|
||||
@BeforeEach
|
||||
public void setUpMocks() {
|
||||
mockServer = MockWebServiceServer.createServer(getFlights);
|
||||
}
|
||||
|
||||
String flightInfo =
|
||||
"<t:number>KL1653</t:number>" + "<t:departureTime>2006-01-31T10:05:00.000+01:00</t:departureTime>" +
|
||||
"<t:from><t:code>AMS</t:code><t:name>Schiphol Airport</t:name><t:city>Amsterdam</t:city></t:from>" +
|
||||
"<t:arrivalTime>2006-01-31T12:25:00.000+01:00</t:arrivalTime>" +
|
||||
"<t:to><t:code>VCE</t:code><t:name>Marco Polo Airport</t:name><t:city>Venice</t:city></t:to>" +
|
||||
"<t:serviceClass>economy</t:serviceClass>";
|
||||
@Test
|
||||
public void getFlights() {
|
||||
|
||||
Source getFlightsResponse = new StringSource(
|
||||
"<m:GetFlightsResponse xmlns:m='" + MESSAGES_NS + "' xmlns:t='" + TYPES_NS + "'>" + "<m:flight>" +
|
||||
flightInfo + "</m:flight>" + "</m:GetFlightsResponse>");
|
||||
Source getFlightsRequest = new StringSource("<GetFlightsRequest xmlns='" + MESSAGES_NS + "'>" + "<from>AMS</from>"
|
||||
+ "<to>VCE</to>" + "<departureDate>2006-01-31</departureDate>" + "</GetFlightsRequest>");
|
||||
|
||||
mockServer.expect(payload(getFlightsRequest)).andRespond(withPayload(getFlightsResponse));
|
||||
String flightInfo = "<t:number>KL1653</t:number>"
|
||||
+ "<t:departureTime>2006-01-31T10:05:00.000+01:00</t:departureTime>"
|
||||
+ "<t:from><t:code>AMS</t:code><t:name>Schiphol Airport</t:name><t:city>Amsterdam</t:city></t:from>"
|
||||
+ "<t:arrivalTime>2006-01-31T12:25:00.000+01:00</t:arrivalTime>"
|
||||
+ "<t:to><t:code>VCE</t:code><t:name>Marco Polo Airport</t:name><t:city>Venice</t:city></t:to>"
|
||||
+ "<t:serviceClass>economy</t:serviceClass>";
|
||||
|
||||
Source bookFlightResponse = new StringSource(
|
||||
"<m:BookFlightResponse xmlns:m='" + MESSAGES_NS + "' xmlns:t='" + TYPES_NS + "'>" + "<t:id>4</t:id>" +
|
||||
"<t:issueDate>2010-07-28</t:issueDate>" +
|
||||
"<t:passengers><t:passenger><t:first>John</t:first><t:last>Doe</t:last></t:passenger></t:passengers>" +
|
||||
"<t:flight>" + flightInfo + "</t:flight>" + "</m:BookFlightResponse>");
|
||||
Source getFlightsResponse = new StringSource("<m:GetFlightsResponse xmlns:m='" + MESSAGES_NS + "' xmlns:t='"
|
||||
+ TYPES_NS + "'>" + "<m:flight>" + flightInfo + "</m:flight>" + "</m:GetFlightsResponse>");
|
||||
|
||||
Map<String, String> namespaces = Collections.singletonMap("m", MESSAGES_NS);
|
||||
mockServer.expect(payload(getFlightsRequest)).andRespond(withPayload(getFlightsResponse));
|
||||
|
||||
mockServer.expect(xpath("/m:BookFlightRequest/m:flightNumber", namespaces).exists())
|
||||
.andExpect(xpath("/m:BookFlightRequest/m:departureTime", namespaces).exists())
|
||||
.andExpect(xpath("/m:BookFlightRequest/m:passengers", namespaces).exists())
|
||||
.andRespond(withPayload(bookFlightResponse));
|
||||
Source bookFlightResponse = new StringSource("<m:BookFlightResponse xmlns:m='" + MESSAGES_NS + "' xmlns:t='"
|
||||
+ TYPES_NS + "'>" + "<t:id>4</t:id>" + "<t:issueDate>2010-07-28</t:issueDate>"
|
||||
+ "<t:passengers><t:passenger><t:first>John</t:first><t:last>Doe</t:last></t:passenger></t:passengers>"
|
||||
+ "<t:flight>" + flightInfo + "</t:flight>" + "</m:BookFlightResponse>");
|
||||
|
||||
getFlights.getFlights();
|
||||
Map<String, String> namespaces = Collections.singletonMap("m", MESSAGES_NS);
|
||||
|
||||
mockServer.verify();
|
||||
mockServer.expect(xpath("/m:BookFlightRequest/m:flightNumber", namespaces).exists())
|
||||
.andExpect(xpath("/m:BookFlightRequest/m:departureTime", namespaces).exists())
|
||||
.andExpect(xpath("/m:BookFlightRequest/m:passengers", namespaces).exists())
|
||||
.andRespond(withPayload(bookFlightResponse));
|
||||
|
||||
}
|
||||
getFlights.getFlights();
|
||||
|
||||
mockServer.verify();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,147 +0,0 @@
|
||||
configurations {
|
||||
jaxb
|
||||
openjpa
|
||||
}
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'org.gradle.api.plugins:gradle-tomcat-plugin:0.9.9'
|
||||
}
|
||||
}
|
||||
|
||||
ext.springVersion = '3.2.4.RELEASE'
|
||||
ext.springWsVersion = '2.1.4.RELEASE'
|
||||
ext.springSecVersion = '3.1.0.RELEASE'
|
||||
ext.tomcatVersion = '7.0.42'
|
||||
|
||||
apply plugin: 'war'
|
||||
apply plugin: 'tomcat'
|
||||
|
||||
|
||||
task genJaxb {
|
||||
ext.sourcesDir = "${buildDir}/generated-sources/jaxb"
|
||||
ext.classesDir = "${buildDir}/classes/jaxb"
|
||||
ext.schema = "${projectDir}/src/main/webapp/messages.xsd"
|
||||
|
||||
inputs.files schema
|
||||
outputs.dir classesDir
|
||||
|
||||
doLast() {
|
||||
project.ant {
|
||||
taskdef name: "xjc", classname: "com.sun.tools.xjc.XJCTask",
|
||||
classpath: configurations.jaxb.asPath
|
||||
mkdir(dir: sourcesDir)
|
||||
mkdir(dir: classesDir)
|
||||
|
||||
xjc(destdir: sourcesDir, schema: schema,
|
||||
package: "org.springframework.ws.samples.airline.schema") {
|
||||
produces(dir: sourcesDir, includes: "**/*.java")
|
||||
}
|
||||
|
||||
javac(destdir: classesDir, source: 1.6, target: 1.6, debug: true,
|
||||
debugLevel: "lines,vars,source",
|
||||
classpath: configurations.jaxb.asPath) {
|
||||
src(path: sourcesDir)
|
||||
include(name: "**/*.java")
|
||||
include(name: "*.java")
|
||||
}
|
||||
|
||||
copy(todir: classesDir) {
|
||||
fileset(dir: sourcesDir, erroronmissingdir: false) {
|
||||
exclude(name: "**/*.java")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task enhance {
|
||||
doLast {
|
||||
ant.taskdef( name : 'openjpaenhancer',
|
||||
classpath : project.runtimeClasspath.asPath,
|
||||
classname : 'org.apache.openjpa.ant.PCEnhancerTask'
|
||||
)
|
||||
|
||||
ant.openjpaenhancer(
|
||||
classpath : project.runtimeClasspath.asPath)
|
||||
ant.fileset(dir: "${projectDir}/src/main/java/") {
|
||||
include(name: '**/domain/*.java')
|
||||
exclude(name: 'ServiceClass.java')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
war {
|
||||
it.dependsOn enhance
|
||||
}
|
||||
|
||||
test {
|
||||
it.dependsOn enhance
|
||||
}
|
||||
|
||||
tomcatRun {
|
||||
it.dependsOn enhance
|
||||
contextPath = 'airline-server'
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
dependencies {
|
||||
compile(files(genJaxb.classesDir).builtBy(genJaxb))
|
||||
|
||||
// Spring-WS
|
||||
compile("org.springframework.ws:spring-ws-core:$springWsVersion")
|
||||
compile("org.springframework.ws:spring-ws-security:$springWsVersion") {
|
||||
exclude group: 'com.sun.xml.wsit', module: 'wsit-rt'
|
||||
exclude group: 'com.sun.xml.wsit', module: 'xws-security'
|
||||
}
|
||||
|
||||
runtime("org.springframework.ws:spring-ws-support:$springWsVersion")
|
||||
|
||||
// Spring
|
||||
runtime("org.springframework:spring-orm:$springVersion")
|
||||
testCompile("org.springframework:spring-jdbc:$springVersion")
|
||||
testCompile("org.springframework:spring-test:$springVersion")
|
||||
|
||||
// Spring Security
|
||||
runtime("org.springframework.security:spring-security-core:$springSecVersion")
|
||||
runtime("org.springframework.security:spring-security-config:$springSecVersion")
|
||||
runtime("org.springframework.security:spring-security-web:$springSecVersion")
|
||||
|
||||
// JEE
|
||||
runtime("javax.servlet:jstl:1.2")
|
||||
|
||||
// ORM
|
||||
compile("org.apache.openjpa:openjpa:1.2.3")
|
||||
runtime("commons-dbcp:commons-dbcp:1.2.1") {
|
||||
exclude group: 'xml-apis', module: 'xml-apis'
|
||||
exclude group: 'xerces', module: 'xerces'
|
||||
}
|
||||
runtime("hsqldb:hsqldb:1.8.0.7")
|
||||
|
||||
// Various
|
||||
runtime("org.apache.activemq:activemq-core:4.1.2")
|
||||
runtime("org.apache.derby:derby:10.3.1.4")
|
||||
runtime("org.apache.ws.xmlschema:xmlschema-core:2.0.2")
|
||||
runtime("com.sun.xml.wss:xws-security:3.0") {
|
||||
exclude group: 'javax.xml.crypto', module: 'xmldsig'
|
||||
}
|
||||
runtime("joda-time:joda-time-jsptags:1.1.1")
|
||||
|
||||
runtime("log4j:log4j:1.2.16")
|
||||
|
||||
|
||||
jaxb "com.sun.xml.bind:jaxb-xjc:2.1.7"
|
||||
openjpa "org.apache.openjpa:openjpa:1.2.3"
|
||||
|
||||
tomcat("org.apache.tomcat.embed:tomcat-embed-core:$tomcatVersion",
|
||||
"org.apache.tomcat.embed:tomcat-embed-logging-juli:$tomcatVersion")
|
||||
tomcat("org.apache.tomcat.embed:tomcat-embed-jasper:$tomcatVersion") {
|
||||
exclude group: 'org.eclipse.jdt.core.compiler', module: 'ecj'
|
||||
}
|
||||
}
|
||||
224
airline/server/pom.xml
Normal file
224
airline/server/pom.xml
Normal file
@@ -0,0 +1,224 @@
|
||||
<?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 http://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.3.1.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<groupId>org.springframework.ws</groupId>
|
||||
<artifactId>airline-server</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>Spring Web Services Samples - Airline - Server</name>
|
||||
<description>Demo project for Spring Web Services</description>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<joda-time.version>2.10.6</joda-time.version>
|
||||
<log4j.version>1.2.16</log4j.version>
|
||||
<sourcesDir>${project.basedir}/target/generated-sources/axis</sourcesDir>
|
||||
<classesDir>${project.basedir}/target/classes</classesDir>
|
||||
<wsdl>${project.basedir}/../airline.wsdl</wsdl>
|
||||
<xmlschema.version>2.0.2</xmlschema.version>
|
||||
<xws-security.version>3.0</xws-security.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web-services</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.ws</groupId>
|
||||
<artifactId>spring-ws-security</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.sun.xml.wsit</groupId>
|
||||
<artifactId>wsit-rt</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.sun.xml.wsit</groupId>
|
||||
<artifactId>xws-security</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.wss</groupId>
|
||||
<artifactId>xws-security</artifactId>
|
||||
<version>${xws-security.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>javax.activation</groupId>
|
||||
<artifactId>activation</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>javax.xml.crypto</groupId>
|
||||
<artifactId>xmldsig</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>javax.xml.stream</groupId>
|
||||
<artifactId>stax-api</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>javax.xml.ws</groupId>
|
||||
<artifactId>jaxws-api</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>javax.mail</groupId>
|
||||
<artifactId>mail</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.ws</groupId>
|
||||
<artifactId>spring-ws-support</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>wsdl4j</groupId>
|
||||
<artifactId>wsdl4j</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.ws.xmlschema</groupId>
|
||||
<artifactId>xmlschema-core</artifactId>
|
||||
<version>${xmlschema.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-activemq</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.activemq</groupId>
|
||||
<artifactId>activemq-kahadb-store</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
<version>${joda-time.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>log4j</groupId>-->
|
||||
<!-- <artifactId>log4j</artifactId>-->
|
||||
<!-- <version>${log4j.version}</version>-->
|
||||
<!-- <scope>runtime</scope>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>jaxb2-maven-plugin</artifactId>
|
||||
<version>2.5.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>xjc</id>
|
||||
<goals>
|
||||
<goal>xjc</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<sources>${project.basedir}/src/main/resources/messages.xsd</sources>
|
||||
<packageName>org.springframework.ws.samples.airline.schema</packageName>
|
||||
<target>2.1</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<version>1.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>add-source</id>
|
||||
<phase>process-sources</phase>
|
||||
<goals>
|
||||
<goal>add-source</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>target/generated-sources/xjc</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,13 @@
|
||||
package org.springframework.ws.samples.airline;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
|
||||
|
||||
@SpringBootApplication(exclude = SecurityAutoConfiguration.class)
|
||||
public class AirlineServerApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AirlineServerApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package org.springframework.ws.samples.airline.dao;
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.ws.samples.airline.domain.Airport;
|
||||
|
||||
public interface AirportDao extends CrudRepository<Airport, Long> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package org.springframework.ws.samples.airline.dao;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.ws.samples.airline.domain.Airport;
|
||||
import org.springframework.ws.samples.airline.domain.Flight;
|
||||
import org.springframework.ws.samples.airline.domain.FrequentFlyer;
|
||||
import org.springframework.ws.samples.airline.domain.ServiceClass;
|
||||
|
||||
@Configuration
|
||||
public class Databaseinit {
|
||||
|
||||
@Bean
|
||||
CommandLineRunner initializeDatabase(AirportDao airportDao, FlightDao flightDao, FrequentFlyerDao frequentFlyerDao) {
|
||||
return args -> {
|
||||
Airport amsterdam = airportDao.save(new Airport("AMS", "Schiphol Airport", "Amsterdam"));
|
||||
Airport venice = airportDao.save(new Airport("VCE", "Marco Polo Airport", "Venice"));
|
||||
Airport rotterdam = airportDao.save(new Airport("RTM", "Rotterdam Airport", "Rotterdam"));
|
||||
Airport gardermoen = airportDao.save(new Airport("OSL", "Gardermoen", "Oslo"));
|
||||
|
||||
Flight flight = new Flight();
|
||||
flight.setNumber("KL1653");
|
||||
flight.setDepartureTime(new DateTime(2006, 1, 31, 10, 5, 0, 0).toGregorianCalendar().toZonedDateTime());
|
||||
flight.setFrom(amsterdam);
|
||||
flight.setArrivalTime(new DateTime(2006, 1, 31, 12, 25, 0, 0).toGregorianCalendar().toZonedDateTime());
|
||||
flight.setTo(venice);
|
||||
flight.setServiceClass(ServiceClass.ECONOMY);
|
||||
flight.setSeatsAvailable(5);
|
||||
flight.setMiles(200);
|
||||
|
||||
flightDao.save(flight);
|
||||
|
||||
flight = new Flight();
|
||||
flight.setNumber("KL1654");
|
||||
flight.setDepartureTime(new DateTime(2006, 2, 5, 12, 40, 0, 0).toGregorianCalendar().toZonedDateTime());
|
||||
flight.setFrom(venice);
|
||||
flight.setArrivalTime(new DateTime(2006, 2, 5, 14, 15, 0, 0).toGregorianCalendar().toZonedDateTime());
|
||||
flight.setTo(amsterdam);
|
||||
flight.setServiceClass(ServiceClass.ECONOMY);
|
||||
flight.setSeatsAvailable(5);
|
||||
flight.setMiles(200);
|
||||
|
||||
flightDao.save(flight);
|
||||
|
||||
frequentFlyerDao.save(new FrequentFlyer("John", "Doe", "john", "changeme"));
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -15,22 +15,50 @@
|
||||
*/
|
||||
package org.springframework.ws.samples.airline.dao;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Interval;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.ws.samples.airline.domain.Flight;
|
||||
import org.springframework.ws.samples.airline.domain.ServiceClass;
|
||||
|
||||
public interface FlightDao {
|
||||
public interface FlightDao extends CrudRepository<Flight, Long> {
|
||||
|
||||
List<Flight> findFlights(String fromAirportCode, String toAirportCode, Interval interval, ServiceClass serviceClass)
|
||||
throws DataAccessException;
|
||||
@Query("SELECT f FROM Flight f WHERE f.from.code = :fromAirportCode "
|
||||
+ "AND f.to.code = :toAirportCode AND f.departureTime >= :#{#interval.start.toGregorianCalendar().toZonedDateTime()} AND f.departureTime <= :#{#interval.end.toGregorianCalendar().toZonedDateTime()} AND "
|
||||
+ "f.serviceClass = :class")
|
||||
List<Flight> findFlights(@Param("fromAirportCode") String fromAirportCode, //
|
||||
@Param("toAirportCode") String toAirportCode, //
|
||||
@Param("interval") Interval interval, //
|
||||
@Param("class") ServiceClass serviceClass);
|
||||
|
||||
Flight getFlight(Long id);
|
||||
/**
|
||||
* @deprecated Migrate to {@link #findById(Object)}.
|
||||
*/
|
||||
default Flight getFlight(Long id) {
|
||||
return findById(id).get();
|
||||
}
|
||||
|
||||
Flight getFlight(String flightNumber, DateTime departureTime);
|
||||
;
|
||||
|
||||
Flight update(Flight flight);
|
||||
/**
|
||||
* @deprecated Migrate to {@link #findFlightByNumberAndDepartureTime(String, ZonedDateTime)}.
|
||||
*/
|
||||
@Deprecated
|
||||
default Flight getFlight(String flightNumber, ZonedDateTime departureTime) {
|
||||
return findFlightByNumberAndDepartureTime(flightNumber, departureTime);
|
||||
}
|
||||
|
||||
Flight findFlightByNumberAndDepartureTime(String flightNumber, ZonedDateTime departureTime);
|
||||
|
||||
/**
|
||||
* @deprecated Migrate to {@link #save(Object)}.
|
||||
*/
|
||||
@Deprecated
|
||||
default Flight update(Flight flight) {
|
||||
return save(flight);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,10 +17,19 @@
|
||||
package org.springframework.ws.samples.airline.dao;
|
||||
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.ws.samples.airline.domain.FrequentFlyer;
|
||||
|
||||
public interface FrequentFlyerDao {
|
||||
public interface FrequentFlyerDao extends CrudRepository<FrequentFlyer, Long> {
|
||||
|
||||
FrequentFlyer get(String username) throws DataAccessException;
|
||||
/**
|
||||
* @deprecated Migrate to {@link #findByUsername(String)}.
|
||||
*/
|
||||
@Deprecated
|
||||
default FrequentFlyer get(String username) throws DataAccessException {
|
||||
return findByUsername(username);
|
||||
}
|
||||
|
||||
FrequentFlyer findByUsername(String username);
|
||||
|
||||
}
|
||||
|
||||
@@ -16,11 +16,9 @@
|
||||
|
||||
package org.springframework.ws.samples.airline.dao;
|
||||
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.ws.samples.airline.domain.Ticket;
|
||||
|
||||
public interface TicketDao {
|
||||
|
||||
void save(Ticket ticket) throws DataAccessException;
|
||||
public interface TicketDao extends CrudRepository<Ticket, Long> {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,108 +0,0 @@
|
||||
/*
|
||||
* Copyright 2005-2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.samples.airline.dao.jpa;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
import org.springframework.transaction.support.TransactionCallbackWithoutResult;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
import org.springframework.ws.samples.airline.domain.Airport;
|
||||
import org.springframework.ws.samples.airline.domain.Flight;
|
||||
import org.springframework.ws.samples.airline.domain.FrequentFlyer;
|
||||
import org.springframework.ws.samples.airline.domain.ServiceClass;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/**
|
||||
* A simple class that uses JPA to initialize the database.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @since 1.5.0
|
||||
*/
|
||||
@Component
|
||||
public class DatabaseInitializer {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(DatabaseInitializer.class);
|
||||
|
||||
private final TransactionTemplate transactionTemplate;
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager entityManager;
|
||||
|
||||
private Airport amsterdam;
|
||||
|
||||
private Airport venice;
|
||||
|
||||
@Autowired
|
||||
public DatabaseInitializer(PlatformTransactionManager transactionManager) {
|
||||
this.transactionTemplate = new TransactionTemplate(transactionManager);
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void initDatabase() {
|
||||
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
|
||||
protected void doInTransactionWithoutResult(TransactionStatus transactionStatus) {
|
||||
logger.info("Initializing Database");
|
||||
createAirports();
|
||||
createFlights();
|
||||
createFrequentFlyers();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void createAirports() {
|
||||
amsterdam = new Airport("AMS", "Schiphol Airport", "Amsterdam");
|
||||
entityManager.persist(amsterdam);
|
||||
venice = new Airport("VCE", "Marco Polo Airport", "Venice");
|
||||
entityManager.persist(venice);
|
||||
}
|
||||
|
||||
private void createFlights() {
|
||||
Flight flight = new Flight();
|
||||
flight.setNumber("KL1653");
|
||||
flight.setDepartureTime(new DateTime(2006, 1, 31, 10, 5, 0, 0));
|
||||
flight.setFrom(amsterdam);
|
||||
flight.setArrivalTime(new DateTime(2006, 1, 31, 12, 25, 0, 0));
|
||||
flight.setTo(venice);
|
||||
flight.setServiceClass(ServiceClass.ECONOMY);
|
||||
flight.setSeatsAvailable(5);
|
||||
flight.setMiles(200);
|
||||
entityManager.persist(flight);
|
||||
flight = new Flight();
|
||||
flight.setNumber("KL1654");
|
||||
flight.setDepartureTime(new DateTime(2006, 2, 5, 12, 40, 0, 0));
|
||||
flight.setFrom(venice);
|
||||
flight.setArrivalTime(new DateTime(2006, 2, 5, 14, 15, 0, 0));
|
||||
flight.setTo(amsterdam);
|
||||
flight.setServiceClass(ServiceClass.ECONOMY);
|
||||
flight.setSeatsAvailable(5);
|
||||
flight.setMiles(200);
|
||||
entityManager.persist(flight);
|
||||
}
|
||||
|
||||
private void createFrequentFlyers() {
|
||||
entityManager.persist(new FrequentFlyer("John", "Doe", "john", "changeme"));
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Copyright 2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.samples.airline.dao.jpa;
|
||||
|
||||
import java.util.List;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.NoResultException;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import javax.persistence.Query;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Interval;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.ws.samples.airline.dao.FlightDao;
|
||||
import org.springframework.ws.samples.airline.domain.Flight;
|
||||
import org.springframework.ws.samples.airline.domain.ServiceClass;
|
||||
|
||||
@Repository
|
||||
public class JpaFlightDao implements FlightDao {
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager entityManager;
|
||||
|
||||
public List<Flight> findFlights(String fromAirportCode,
|
||||
String toAirportCode,
|
||||
Interval interval,
|
||||
ServiceClass serviceClass) throws DataAccessException {
|
||||
Query query = entityManager.createQuery("SELECT f FROM Flight f WHERE f.from.code = :fromParam " +
|
||||
"AND f.to.code = :toParam AND f.departureTime >= :start AND f.departureTime <= :end AND " +
|
||||
"f.serviceClass = :class");
|
||||
query.setParameter("fromParam", fromAirportCode);
|
||||
query.setParameter("toParam", toAirportCode);
|
||||
query.setParameter("start", interval.getStart());
|
||||
query.setParameter("end", interval.getEnd());
|
||||
query.setParameter("class", serviceClass);
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
public Flight getFlight(Long id) {
|
||||
return entityManager.find(Flight.class, id);
|
||||
}
|
||||
|
||||
public Flight getFlight(String flightNumber, DateTime departureTime) {
|
||||
Query query = entityManager
|
||||
.createQuery("SELECT f FROM Flight f WHERE f.number = :number AND f.departureTime = :departureTime");
|
||||
query.setParameter("number", flightNumber);
|
||||
query.setParameter("departureTime", departureTime);
|
||||
try {
|
||||
return (Flight) query.getSingleResult();
|
||||
}
|
||||
catch (NoResultException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Flight update(Flight flight) {
|
||||
return entityManager.merge(flight);
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright 2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.samples.airline.dao.jpa;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.NoResultException;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import javax.persistence.Query;
|
||||
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.ws.samples.airline.dao.FrequentFlyerDao;
|
||||
import org.springframework.ws.samples.airline.domain.FrequentFlyer;
|
||||
|
||||
@Repository
|
||||
public class JpaFrequentFlyerDao implements FrequentFlyerDao {
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager entityManager;
|
||||
|
||||
public FrequentFlyer get(String username) throws DataAccessException {
|
||||
Query query = entityManager.createQuery("SELECT f FROM FrequentFlyer f WHERE f.username = :username");
|
||||
query.setParameter("username", username);
|
||||
try {
|
||||
return (FrequentFlyer) query.getSingleResult();
|
||||
}
|
||||
catch (NoResultException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright 2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.samples.airline.dao.jpa;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.ws.samples.airline.dao.TicketDao;
|
||||
import org.springframework.ws.samples.airline.domain.Ticket;
|
||||
|
||||
@Repository
|
||||
public class JpaTicketDao implements TicketDao {
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager entityManager;
|
||||
|
||||
public void save(Ticket ticket) throws DataAccessException {
|
||||
entityManager.persist(ticket);
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.ws.samples.airline.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
package org.springframework.ws.samples.airline.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
@@ -27,153 +29,131 @@ import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.apache.openjpa.persistence.Persistent;
|
||||
import org.joda.time.DateTime;
|
||||
import org.springframework.data.annotation.Persistent;
|
||||
|
||||
@Entity
|
||||
@Table(name = "FLIGHT")
|
||||
public class Flight implements Serializable {
|
||||
|
||||
@Id
|
||||
@Column(name = "ID")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
@Id @Column(name = "ID") @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id;
|
||||
|
||||
@Column(name = "NUMBER")
|
||||
private String number;
|
||||
@Column(name = "NUMBER") private String number;
|
||||
|
||||
@Column(name = "DEPARTURE_TIME")
|
||||
@Persistent
|
||||
private DateTime departureTime;
|
||||
@Column(name = "DEPARTURE_TIME") @Persistent private ZonedDateTime departureTime;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "FROM_AIRPORT_CODE", nullable = false)
|
||||
private Airport from;
|
||||
@ManyToOne @JoinColumn(name = "FROM_AIRPORT_CODE", nullable = false) private Airport from;
|
||||
|
||||
@Column(name = "ARRIVAL_TIME")
|
||||
@Persistent
|
||||
private DateTime arrivalTime;
|
||||
@Column(name = "ARRIVAL_TIME") @Persistent private ZonedDateTime arrivalTime;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "TO_AIRPORT_CODE", nullable = false)
|
||||
private Airport to;
|
||||
@ManyToOne @JoinColumn(name = "TO_AIRPORT_CODE", nullable = false) private Airport to;
|
||||
|
||||
@Column(name = "SERVICE_CLASS")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private ServiceClass serviceClass;
|
||||
@Column(name = "SERVICE_CLASS") @Enumerated(EnumType.STRING) private ServiceClass serviceClass;
|
||||
|
||||
@Column(name = "SEATS_AVAILABLE")
|
||||
private int seatsAvailable;
|
||||
@Column(name = "SEATS_AVAILABLE") private int seatsAvailable;
|
||||
|
||||
@Column(name = "MILES")
|
||||
private int miles;
|
||||
@Column(name = "MILES") private int miles;
|
||||
|
||||
public Flight() {
|
||||
}
|
||||
public Flight() {}
|
||||
|
||||
public Flight(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
public Flight(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public DateTime getArrivalTime() {
|
||||
return arrivalTime;
|
||||
}
|
||||
public ZonedDateTime getArrivalTime() {
|
||||
return arrivalTime;
|
||||
}
|
||||
|
||||
public void setArrivalTime(DateTime arrivalTime) {
|
||||
this.arrivalTime = arrivalTime;
|
||||
}
|
||||
public void setArrivalTime(ZonedDateTime arrivalTime) {
|
||||
this.arrivalTime = arrivalTime;
|
||||
}
|
||||
|
||||
public DateTime getDepartureTime() {
|
||||
return departureTime;
|
||||
}
|
||||
public ZonedDateTime getDepartureTime() {
|
||||
return departureTime;
|
||||
}
|
||||
|
||||
public void setDepartureTime(DateTime departureTime) {
|
||||
this.departureTime = departureTime;
|
||||
}
|
||||
public void setDepartureTime(ZonedDateTime departureTime) {
|
||||
this.departureTime = departureTime;
|
||||
}
|
||||
|
||||
public Airport getFrom() {
|
||||
return from;
|
||||
}
|
||||
public Airport getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
public void setFrom(Airport from) {
|
||||
this.from = from;
|
||||
}
|
||||
public void setFrom(Airport from) {
|
||||
this.from = from;
|
||||
}
|
||||
|
||||
public int getMiles() {
|
||||
return miles;
|
||||
}
|
||||
public int getMiles() {
|
||||
return miles;
|
||||
}
|
||||
|
||||
public void setMiles(int miles) {
|
||||
this.miles = miles;
|
||||
}
|
||||
public void setMiles(int miles) {
|
||||
this.miles = miles;
|
||||
}
|
||||
|
||||
public String getNumber() {
|
||||
return number;
|
||||
}
|
||||
public String getNumber() {
|
||||
return number;
|
||||
}
|
||||
|
||||
public void setNumber(String number) {
|
||||
this.number = number;
|
||||
}
|
||||
public void setNumber(String number) {
|
||||
this.number = number;
|
||||
}
|
||||
|
||||
public int getSeatsAvailable() {
|
||||
return seatsAvailable;
|
||||
}
|
||||
public int getSeatsAvailable() {
|
||||
return seatsAvailable;
|
||||
}
|
||||
|
||||
public void setSeatsAvailable(int seatsAvailable) {
|
||||
this.seatsAvailable = seatsAvailable;
|
||||
}
|
||||
public void setSeatsAvailable(int seatsAvailable) {
|
||||
this.seatsAvailable = seatsAvailable;
|
||||
}
|
||||
|
||||
public ServiceClass getServiceClass() {
|
||||
return serviceClass;
|
||||
}
|
||||
public ServiceClass getServiceClass() {
|
||||
return serviceClass;
|
||||
}
|
||||
|
||||
public void setServiceClass(ServiceClass serviceClass) {
|
||||
this.serviceClass = serviceClass;
|
||||
}
|
||||
public void setServiceClass(ServiceClass serviceClass) {
|
||||
this.serviceClass = serviceClass;
|
||||
}
|
||||
|
||||
public Airport getTo() {
|
||||
return to;
|
||||
}
|
||||
public Airport getTo() {
|
||||
return to;
|
||||
}
|
||||
|
||||
public void setTo(Airport to) {
|
||||
this.to = to;
|
||||
}
|
||||
public void setTo(Airport to) {
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
public void substractSeats(int count) {
|
||||
seatsAvailable -= count;
|
||||
}
|
||||
public void substractSeats(int count) {
|
||||
seatsAvailable -= count;
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Flight flight = (Flight) o;
|
||||
final Flight flight = (Flight) o;
|
||||
|
||||
if (!departureTime.equals(flight.departureTime)) {
|
||||
return false;
|
||||
}
|
||||
return number.equals(flight.number);
|
||||
}
|
||||
if (!departureTime.equals(flight.departureTime)) {
|
||||
return false;
|
||||
}
|
||||
return number.equals(flight.number);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
int result = number.hashCode();
|
||||
result = 29 * result + departureTime.hashCode();
|
||||
return result;
|
||||
}
|
||||
public int hashCode() {
|
||||
int result = number.hashCode();
|
||||
result = 29 * result + departureTime.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append(getNumber());
|
||||
buffer.append(' ');
|
||||
buffer.append(getDepartureTime().toString());
|
||||
return buffer.toString();
|
||||
}
|
||||
public String toString() {
|
||||
return getNumber() + " " + getDepartureTime();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,72 +26,70 @@ import javax.persistence.Table;
|
||||
@PrimaryKeyJoinColumn(name = "PASSENGER_ID")
|
||||
public class FrequentFlyer extends Passenger {
|
||||
|
||||
@Column(name = "USERNAME")
|
||||
private String username;
|
||||
@Column(name = "USERNAME") private String username;
|
||||
|
||||
@Column(name = "PASSWORD")
|
||||
private String password;
|
||||
@Column(name = "PASSWORD") private String password;
|
||||
|
||||
@Column(name = "MILES")
|
||||
private int miles;
|
||||
@Column(name = "MILES") private int miles;
|
||||
|
||||
public FrequentFlyer() {
|
||||
}
|
||||
public FrequentFlyer() {}
|
||||
|
||||
public FrequentFlyer(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
public FrequentFlyer(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public FrequentFlyer(String firstName, String lastName, String username, String password) {
|
||||
super(firstName, lastName);
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
}
|
||||
public FrequentFlyer(String firstName, String lastName, String username, String password) {
|
||||
|
||||
public int getMiles() {
|
||||
return miles;
|
||||
}
|
||||
super(firstName, lastName);
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public void setMiles(int miles) {
|
||||
this.miles = miles;
|
||||
}
|
||||
public int getMiles() {
|
||||
return miles;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
public void setMiles(int miles) {
|
||||
this.miles = miles;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof FrequentFlyer)) {
|
||||
return false;
|
||||
}
|
||||
final FrequentFlyer that = (FrequentFlyer) other;
|
||||
return username.equals(that.username);
|
||||
}
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return username.hashCode();
|
||||
}
|
||||
public boolean equals(Object other) {
|
||||
|
||||
public String toString() {
|
||||
return username;
|
||||
}
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof FrequentFlyer)) {
|
||||
return false;
|
||||
}
|
||||
final FrequentFlyer that = (FrequentFlyer) other;
|
||||
return username.equals(that.username);
|
||||
}
|
||||
|
||||
public void addMiles(int miles) {
|
||||
this.miles += miles;
|
||||
}
|
||||
public int hashCode() {
|
||||
return username.hashCode();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void addMiles(int miles) {
|
||||
this.miles += miles;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package org.springframework.ws.samples.airline.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.ws.samples.airline.domain;
|
||||
import java.io.Serializable;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
@@ -31,67 +32,67 @@ import javax.persistence.ManyToMany;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.apache.openjpa.persistence.Persistent;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.springframework.data.annotation.Persistent;
|
||||
|
||||
@Entity
|
||||
@Table(name = "TICKET")
|
||||
public class Ticket implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "ISSUE_DATE")
|
||||
@Persistent
|
||||
private LocalDate issueDate;
|
||||
@Column(name = "ISSUE_DATE")
|
||||
@Persistent
|
||||
private LocalDate issueDate;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "FLIGHT_ID", nullable = false)
|
||||
private Flight flight;
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "FLIGHT_ID", nullable = false)
|
||||
private Flight flight;
|
||||
|
||||
@ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
|
||||
@JoinTable(name = "PASSENGER_TICKET",
|
||||
joinColumns = @JoinColumn(name = "TICKET_ID"),
|
||||
inverseJoinColumns = @JoinColumn(name = "PASSENGER_ID"))
|
||||
private Set<Passenger> passengers = new HashSet<Passenger>();
|
||||
@ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
|
||||
@JoinTable(name = "PASSENGER_TICKET",
|
||||
joinColumns = @JoinColumn(name = "TICKET_ID"),
|
||||
inverseJoinColumns = @JoinColumn(name = "PASSENGER_ID"))
|
||||
private Set<Passenger> passengers = new HashSet<Passenger>();
|
||||
|
||||
public Ticket() {
|
||||
}
|
||||
public Ticket() {
|
||||
}
|
||||
|
||||
public Ticket(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
public Ticket(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Flight getFlight() {
|
||||
return flight;
|
||||
}
|
||||
public Flight getFlight() {
|
||||
return flight;
|
||||
}
|
||||
|
||||
public void setFlight(Flight flight) {
|
||||
this.flight = flight;
|
||||
}
|
||||
public void setFlight(Flight flight) {
|
||||
this.flight = flight;
|
||||
}
|
||||
|
||||
public LocalDate getIssueDate() {
|
||||
return issueDate;
|
||||
}
|
||||
public LocalDate getIssueDate() {
|
||||
return issueDate;
|
||||
}
|
||||
|
||||
public void setIssueDate(LocalDate issueDate) {
|
||||
this.issueDate = issueDate;
|
||||
}
|
||||
public void setIssueDate(LocalDate issueDate) {
|
||||
this.issueDate = issueDate;
|
||||
}
|
||||
|
||||
public Set<Passenger> getPassengers() {
|
||||
return passengers;
|
||||
}
|
||||
public Set<Passenger> getPassengers() {
|
||||
return passengers;
|
||||
}
|
||||
|
||||
public void setPassengers(Set<Passenger> passengers) {
|
||||
this.passengers = passengers;
|
||||
}
|
||||
public void setPassengers(Set<Passenger> passengers) {
|
||||
this.passengers = passengers;
|
||||
}
|
||||
|
||||
public void addPassenger(Passenger passenger) {
|
||||
passengers.add(passenger);
|
||||
}
|
||||
public void addPassenger(Passenger passenger) {
|
||||
passengers.add(passenger);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright 2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.samples.airline.domain.openjpa;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
import org.apache.openjpa.jdbc.kernel.JDBCStore;
|
||||
import org.apache.openjpa.jdbc.meta.JavaSQLTypes;
|
||||
import org.apache.openjpa.jdbc.meta.ValueMapping;
|
||||
import org.apache.openjpa.jdbc.meta.strats.AbstractValueHandler;
|
||||
import org.apache.openjpa.jdbc.schema.Column;
|
||||
import org.apache.openjpa.jdbc.schema.ColumnIO;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class DateTimeValueHandler extends AbstractValueHandler {
|
||||
|
||||
private static final DateTimeValueHandler instance = new DateTimeValueHandler();
|
||||
|
||||
public static DateTimeValueHandler getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public Column[] map(ValueMapping vm, String name, ColumnIO io, boolean adapt) {
|
||||
Column col = new Column();
|
||||
col.setName(name);
|
||||
col.setJavaType(JavaSQLTypes.TIMESTAMP);
|
||||
return new Column[]{col};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toDataStoreValue(ValueMapping valueMapping, Object val, JDBCStore jdbcStore) {
|
||||
return val == null ? null : new Timestamp(((DateTime) val).getMillis());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toObjectValue(ValueMapping valueMapping, Object val) {
|
||||
return val == null ? null : new DateTime(val);
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Copyright 2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.samples.airline.domain.openjpa;
|
||||
|
||||
import java.sql.Date;
|
||||
|
||||
import org.apache.openjpa.jdbc.kernel.JDBCStore;
|
||||
import org.apache.openjpa.jdbc.meta.JavaSQLTypes;
|
||||
import org.apache.openjpa.jdbc.meta.ValueMapping;
|
||||
import org.apache.openjpa.jdbc.meta.strats.AbstractValueHandler;
|
||||
import org.apache.openjpa.jdbc.schema.Column;
|
||||
import org.apache.openjpa.jdbc.schema.ColumnIO;
|
||||
import org.joda.time.LocalDate;
|
||||
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class LocalDateValueHandler extends AbstractValueHandler {
|
||||
|
||||
public Column[] map(ValueMapping vm, String name, ColumnIO io, boolean adapt) {
|
||||
Column col = new Column();
|
||||
col.setName(name);
|
||||
col.setJavaType(JavaSQLTypes.DATE);
|
||||
return new Column[]{col};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toDataStoreValue(ValueMapping valueMapping, Object val, JDBCStore jdbcStore) {
|
||||
return val == null ? null : new Date(((LocalDate) val).toDateMidnight().getMillis());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toObjectValue(ValueMapping valueMapping, Object val) {
|
||||
return val == null ? null : new LocalDate(val);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package org.springframework.ws.samples.airline.jms;
|
||||
|
||||
import javax.jms.ConnectionFactory;
|
||||
|
||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.broker.BrokerFactory;
|
||||
import org.apache.activemq.broker.BrokerService;
|
||||
import org.apache.activemq.command.ActiveMQQueue;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.jms.listener.DefaultMessageListenerContainer;
|
||||
import org.springframework.ws.WebServiceMessageFactory;
|
||||
import org.springframework.ws.transport.WebServiceMessageReceiver;
|
||||
import org.springframework.ws.transport.jms.WebServiceMessageListener;
|
||||
|
||||
@Configuration
|
||||
public class JmsConfiguration {
|
||||
|
||||
@Bean(initMethod = "start")
|
||||
BrokerService broker() throws Exception {
|
||||
return BrokerFactory.createBroker("broker:tcp://localhost:61616?persistent=false");
|
||||
}
|
||||
|
||||
@Bean
|
||||
ActiveMQConnectionFactory connectionFactory() {
|
||||
|
||||
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
|
||||
connectionFactory.setBrokerURL("tcp://localhost:61616");
|
||||
return connectionFactory;
|
||||
}
|
||||
|
||||
@Bean
|
||||
DefaultMessageListenerContainer containerFactory(ConnectionFactory connectionFactory,
|
||||
WebServiceMessageListener messageListener) {
|
||||
|
||||
DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
|
||||
container.setConnectionFactory(connectionFactory);
|
||||
container.setDestination(new ActiveMQQueue("RequestQueue"));
|
||||
container.setMessageListener(messageListener);
|
||||
return container;
|
||||
}
|
||||
|
||||
@Bean
|
||||
WebServiceMessageListener messageListener(WebServiceMessageFactory messageFactory,
|
||||
WebServiceMessageReceiver messageReceiver) {
|
||||
|
||||
WebServiceMessageListener messageListener = new WebServiceMessageListener();
|
||||
messageListener.setMessageFactory(messageFactory);
|
||||
messageListener.setMessageReceiver(messageReceiver);
|
||||
return messageListener;
|
||||
}
|
||||
}
|
||||
@@ -16,15 +16,16 @@
|
||||
|
||||
package org.springframework.ws.samples.airline.schema.support;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.xml.datatype.DatatypeConfigurationException;
|
||||
import javax.xml.datatype.DatatypeConstants;
|
||||
import javax.xml.datatype.DatatypeFactory;
|
||||
import javax.xml.datatype.XMLGregorianCalendar;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.DateTimeZone;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.springframework.ws.samples.airline.domain.Passenger;
|
||||
import org.springframework.ws.samples.airline.schema.Airport;
|
||||
@@ -36,112 +37,119 @@ import org.springframework.ws.samples.airline.schema.Ticket;
|
||||
/** @author Arjen Poutsma */
|
||||
public abstract class SchemaConversionUtils {
|
||||
|
||||
private SchemaConversionUtils() {
|
||||
}
|
||||
private SchemaConversionUtils() {}
|
||||
|
||||
public static Flight toSchemaType(org.springframework.ws.samples.airline.domain.Flight domainFlight)
|
||||
throws DatatypeConfigurationException {
|
||||
Flight schemaFlight = new Flight();
|
||||
schemaFlight.setNumber(domainFlight.getNumber());
|
||||
schemaFlight.setDepartureTime(toXMLGregorianCalendar(domainFlight.getDepartureTime()));
|
||||
schemaFlight.setFrom(toSchemaType(domainFlight.getFrom()));
|
||||
schemaFlight.setArrivalTime(toXMLGregorianCalendar(domainFlight.getArrivalTime()));
|
||||
schemaFlight.setTo(toSchemaType(domainFlight.getTo()));
|
||||
schemaFlight.setServiceClass(toSchemaType(domainFlight.getServiceClass()));
|
||||
return schemaFlight;
|
||||
}
|
||||
public static Flight toSchemaType(org.springframework.ws.samples.airline.domain.Flight domainFlight)
|
||||
throws DatatypeConfigurationException {
|
||||
|
||||
public static List<Flight> toSchemaType(List<org.springframework.ws.samples.airline.domain.Flight> domainFlights)
|
||||
throws DatatypeConfigurationException {
|
||||
List<Flight> schemaFlights = new ArrayList<Flight>(domainFlights.size());
|
||||
for (org.springframework.ws.samples.airline.domain.Flight domainFlight : domainFlights) {
|
||||
schemaFlights.add(toSchemaType(domainFlight));
|
||||
}
|
||||
return schemaFlights;
|
||||
}
|
||||
Flight schemaFlight = new Flight();
|
||||
schemaFlight.setNumber(domainFlight.getNumber());
|
||||
schemaFlight.setDepartureTime(toXMLGregorianCalendar(domainFlight.getDepartureTime()));
|
||||
schemaFlight.setFrom(toSchemaType(domainFlight.getFrom()));
|
||||
schemaFlight.setArrivalTime(toXMLGregorianCalendar(domainFlight.getArrivalTime()));
|
||||
schemaFlight.setTo(toSchemaType(domainFlight.getTo()));
|
||||
schemaFlight.setServiceClass(toSchemaType(domainFlight.getServiceClass()));
|
||||
return schemaFlight;
|
||||
}
|
||||
|
||||
public static XMLGregorianCalendar toXMLGregorianCalendar(DateTime dateTime) throws DatatypeConfigurationException {
|
||||
DatatypeFactory factory = DatatypeFactory.newInstance();
|
||||
return factory.newXMLGregorianCalendar(dateTime.toGregorianCalendar());
|
||||
}
|
||||
public static List<Flight> toSchemaType(List<org.springframework.ws.samples.airline.domain.Flight> domainFlights) {
|
||||
|
||||
public static DateTime toDateTime(XMLGregorianCalendar calendar) {
|
||||
int timeZoneMinutes = calendar.getTimezone();
|
||||
DateTimeZone timeZone = DateTimeZone.forOffsetHoursMinutes(timeZoneMinutes / 60, timeZoneMinutes % 60);
|
||||
return new DateTime(calendar.getYear(), calendar.getMonth(), calendar.getDay(), calendar.getHour(),
|
||||
calendar.getMinute(), calendar.getSecond(), calendar.getMillisecond(), timeZone);
|
||||
}
|
||||
return domainFlights.stream() //
|
||||
.map(flight -> {
|
||||
try {
|
||||
return toSchemaType(flight);
|
||||
} catch (DatatypeConfigurationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}) //
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static XMLGregorianCalendar toXMLGregorianCalendar(LocalDate localDate)
|
||||
throws DatatypeConfigurationException {
|
||||
DatatypeFactory factory = DatatypeFactory.newInstance();
|
||||
return factory.newXMLGregorianCalendarDate(localDate.getYear(), localDate.getMonthOfYear(),
|
||||
localDate.getDayOfMonth(), DatatypeConstants.FIELD_UNDEFINED);
|
||||
}
|
||||
public static XMLGregorianCalendar toXMLGregorianCalendar(ZonedDateTime dateTime)
|
||||
throws DatatypeConfigurationException {
|
||||
|
||||
public static LocalDate toLocalDate(XMLGregorianCalendar calendar) {
|
||||
return new LocalDate(calendar.getYear(), calendar.getMonth(), calendar.getDay());
|
||||
}
|
||||
DatatypeFactory factory = DatatypeFactory.newInstance();
|
||||
return factory.newXMLGregorianCalendar(GregorianCalendar.from(dateTime));
|
||||
}
|
||||
|
||||
public static Airport toSchemaType(org.springframework.ws.samples.airline.domain.Airport domainAirport) {
|
||||
if (domainAirport == null) {
|
||||
return null;
|
||||
}
|
||||
Airport schemaAirport = new Airport();
|
||||
schemaAirport.setCode(domainAirport.getCode());
|
||||
schemaAirport.setName(domainAirport.getName());
|
||||
schemaAirport.setCity(domainAirport.getCity());
|
||||
return schemaAirport;
|
||||
}
|
||||
public static ZonedDateTime toDateTime(XMLGregorianCalendar calendar) {
|
||||
return calendar.toGregorianCalendar().toZonedDateTime();
|
||||
}
|
||||
|
||||
public static ServiceClass toSchemaType(org.springframework.ws.samples.airline.domain.ServiceClass domainServiceClass) {
|
||||
switch (domainServiceClass) {
|
||||
case BUSINESS:
|
||||
return ServiceClass.BUSINESS;
|
||||
case ECONOMY:
|
||||
return ServiceClass.ECONOMY;
|
||||
case FIRST:
|
||||
return ServiceClass.FIRST;
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid domain service class: [" + domainServiceClass + "]");
|
||||
}
|
||||
}
|
||||
public static XMLGregorianCalendar toXMLGregorianCalendar(LocalDate localDate) throws DatatypeConfigurationException {
|
||||
|
||||
public static org.springframework.ws.samples.airline.domain.ServiceClass toDomainType(ServiceClass schemaServiceClass) {
|
||||
if (schemaServiceClass == null) {
|
||||
return null;
|
||||
}
|
||||
switch (schemaServiceClass) {
|
||||
case BUSINESS:
|
||||
return org.springframework.ws.samples.airline.domain.ServiceClass.BUSINESS;
|
||||
case ECONOMY:
|
||||
return org.springframework.ws.samples.airline.domain.ServiceClass.ECONOMY;
|
||||
case FIRST:
|
||||
return org.springframework.ws.samples.airline.domain.ServiceClass.FIRST;
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid schema service class: [" + schemaServiceClass + "]");
|
||||
}
|
||||
}
|
||||
DatatypeFactory factory = DatatypeFactory.newInstance();
|
||||
return factory.newXMLGregorianCalendarDate(localDate.getYear(), localDate.getMonthOfYear(),
|
||||
localDate.getDayOfMonth(), DatatypeConstants.FIELD_UNDEFINED);
|
||||
}
|
||||
|
||||
public static Name toSchemaType(org.springframework.ws.samples.airline.domain.Passenger passenger) {
|
||||
Name name = new Name();
|
||||
name.setFirst(passenger.getFirstName());
|
||||
name.setLast(passenger.getLastName());
|
||||
return name;
|
||||
}
|
||||
public static LocalDate toLocalDate(XMLGregorianCalendar calendar) {
|
||||
return new LocalDate(calendar.getYear(), calendar.getMonth(), calendar.getDay());
|
||||
}
|
||||
|
||||
public static Ticket toSchemaType(org.springframework.ws.samples.airline.domain.Ticket domainTicket)
|
||||
throws DatatypeConfigurationException {
|
||||
Ticket schemaTicket = new Ticket();
|
||||
schemaTicket.setId(domainTicket.getId());
|
||||
schemaTicket.setFlight(toSchemaType(domainTicket.getFlight()));
|
||||
schemaTicket.setIssueDate(toXMLGregorianCalendar(domainTicket.getIssueDate()));
|
||||
if (!domainTicket.getPassengers().isEmpty()) {
|
||||
schemaTicket.setPassengers(new Ticket.Passengers());
|
||||
}
|
||||
for (Passenger passenger : domainTicket.getPassengers()) {
|
||||
schemaTicket.getPassengers().getPassenger().add(toSchemaType(passenger));
|
||||
}
|
||||
return schemaTicket;
|
||||
}
|
||||
public static Airport toSchemaType(org.springframework.ws.samples.airline.domain.Airport domainAirport) {
|
||||
|
||||
if (domainAirport == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Airport schemaAirport = new Airport();
|
||||
schemaAirport.setCode(domainAirport.getCode());
|
||||
schemaAirport.setName(domainAirport.getName());
|
||||
schemaAirport.setCity(domainAirport.getCity());
|
||||
return schemaAirport;
|
||||
}
|
||||
|
||||
public static ServiceClass toSchemaType(
|
||||
org.springframework.ws.samples.airline.domain.ServiceClass domainServiceClass) {
|
||||
switch (domainServiceClass) {
|
||||
case BUSINESS:
|
||||
return ServiceClass.BUSINESS;
|
||||
case ECONOMY:
|
||||
return ServiceClass.ECONOMY;
|
||||
case FIRST:
|
||||
return ServiceClass.FIRST;
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid domain service class: [" + domainServiceClass + "]");
|
||||
}
|
||||
}
|
||||
|
||||
public static org.springframework.ws.samples.airline.domain.ServiceClass toDomainType(
|
||||
ServiceClass schemaServiceClass) {
|
||||
if (schemaServiceClass == null) {
|
||||
return null;
|
||||
}
|
||||
switch (schemaServiceClass) {
|
||||
case BUSINESS:
|
||||
return org.springframework.ws.samples.airline.domain.ServiceClass.BUSINESS;
|
||||
case ECONOMY:
|
||||
return org.springframework.ws.samples.airline.domain.ServiceClass.ECONOMY;
|
||||
case FIRST:
|
||||
return org.springframework.ws.samples.airline.domain.ServiceClass.FIRST;
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid schema service class: [" + schemaServiceClass + "]");
|
||||
}
|
||||
}
|
||||
|
||||
public static Name toSchemaType(Passenger passenger) {
|
||||
Name name = new Name();
|
||||
name.setFirst(passenger.getFirstName());
|
||||
name.setLast(passenger.getLastName());
|
||||
return name;
|
||||
}
|
||||
|
||||
public static Ticket toSchemaType(org.springframework.ws.samples.airline.domain.Ticket domainTicket)
|
||||
throws DatatypeConfigurationException {
|
||||
Ticket schemaTicket = new Ticket();
|
||||
schemaTicket.setId(domainTicket.getId());
|
||||
schemaTicket.setFlight(toSchemaType(domainTicket.getFlight()));
|
||||
schemaTicket.setIssueDate(toXMLGregorianCalendar(domainTicket.getIssueDate()));
|
||||
if (!domainTicket.getPassengers().isEmpty()) {
|
||||
schemaTicket.setPassengers(new Ticket.Passengers());
|
||||
}
|
||||
for (Passenger passenger : domainTicket.getPassengers()) {
|
||||
schemaTicket.getPassengers().getPassenger().add(toSchemaType(passenger));
|
||||
}
|
||||
return schemaTicket;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.GrantedAuthorityImpl;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.ws.samples.airline.domain.FrequentFlyer;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class FrequentFlyerDetails implements UserDetails {
|
||||
public static final Collection<GrantedAuthority> GRANTED_AUTHORITIES =
|
||||
new ArrayList<GrantedAuthority>();
|
||||
{
|
||||
GRANTED_AUTHORITIES.add(new GrantedAuthorityImpl("ROLE_FREQUENT_FLYER"));
|
||||
GRANTED_AUTHORITIES.add(new SimpleGrantedAuthority("ROLE_FREQUENT_FLYER"));
|
||||
};
|
||||
|
||||
public FrequentFlyerDetails(FrequentFlyer frequentFlyer) {
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package org.springframework.ws.samples.airline.security;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.bytebuddy.build.Plugin;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.authentication.ProviderManager;
|
||||
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||
import org.springframework.security.crypto.password.DelegatingPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.NoOpPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.ws.samples.airline.dao.FrequentFlyerDao;
|
||||
|
||||
@EnableGlobalMethodSecurity(securedEnabled = true)
|
||||
public class SecurityConfiguration /*extends WebSecurityConfigurerAdapter*/ {
|
||||
|
||||
@Bean
|
||||
SpringFrequentFlyerSecurityService securityService(FrequentFlyerDao frequentFlyerDao) {
|
||||
return new SpringFrequentFlyerSecurityService(frequentFlyerDao);
|
||||
}
|
||||
|
||||
@Bean
|
||||
AuthenticationManager authenticationManager(SpringFrequentFlyerSecurityService securityService) {
|
||||
|
||||
DaoAuthenticationProvider authenticationProvider = new DaoAuthenticationProvider();
|
||||
authenticationProvider.setUserDetailsService(securityService);
|
||||
return new ProviderManager(authenticationProvider);
|
||||
}
|
||||
|
||||
@Bean
|
||||
PasswordEncoder passwordEncoder() {
|
||||
return NoOpPasswordEncoder.getInstance();
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.ws.samples.airline.security;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContext;
|
||||
@@ -36,51 +35,48 @@ import org.springframework.ws.samples.airline.service.NoSuchFrequentFlyerExcepti
|
||||
*/
|
||||
public class SpringFrequentFlyerSecurityService implements FrequentFlyerSecurityService, UserDetailsService {
|
||||
|
||||
private FrequentFlyerDao frequentFlyerDao;
|
||||
private FrequentFlyerDao frequentFlyerDao;
|
||||
|
||||
@Autowired
|
||||
public SpringFrequentFlyerSecurityService(FrequentFlyerDao frequentFlyerDao) {
|
||||
this.frequentFlyerDao = frequentFlyerDao;
|
||||
}
|
||||
public SpringFrequentFlyerSecurityService(FrequentFlyerDao frequentFlyerDao) {
|
||||
this.frequentFlyerDao = frequentFlyerDao;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public FrequentFlyer getCurrentlyAuthenticatedFrequentFlyer() {
|
||||
SecurityContext context = SecurityContextHolder.getContext();
|
||||
Authentication authentication = context.getAuthentication();
|
||||
if (authentication != null) {
|
||||
if (authentication.getPrincipal() instanceof FrequentFlyerDetails) {
|
||||
FrequentFlyerDetails details = (FrequentFlyerDetails) authentication.getPrincipal();
|
||||
return details.getFrequentFlyer();
|
||||
}
|
||||
else {
|
||||
return (FrequentFlyer) authentication.getPrincipal();
|
||||
}
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Transactional
|
||||
public FrequentFlyer getCurrentlyAuthenticatedFrequentFlyer() {
|
||||
|
||||
@Transactional
|
||||
public FrequentFlyer getFrequentFlyer(String username) throws NoSuchFrequentFlyerException {
|
||||
FrequentFlyer frequentFlyer = frequentFlyerDao.get(username);
|
||||
if (frequentFlyer != null) {
|
||||
return frequentFlyer;
|
||||
}
|
||||
else {
|
||||
throw new NoSuchFrequentFlyerException(username);
|
||||
}
|
||||
}
|
||||
SecurityContext context = SecurityContextHolder.getContext();
|
||||
Authentication authentication = context.getAuthentication();
|
||||
if (authentication != null) {
|
||||
if (authentication.getPrincipal() instanceof FrequentFlyerDetails) {
|
||||
FrequentFlyerDetails details = (FrequentFlyerDetails) authentication.getPrincipal();
|
||||
return details.getFrequentFlyer();
|
||||
} else {
|
||||
return (FrequentFlyer) authentication.getPrincipal();
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
|
||||
FrequentFlyer frequentFlyer = frequentFlyerDao.get(username);
|
||||
if (frequentFlyer != null) {
|
||||
return new FrequentFlyerDetails(frequentFlyer);
|
||||
}
|
||||
else {
|
||||
throw new UsernameNotFoundException("Frequent flyer '" + username + "' not found");
|
||||
}
|
||||
}
|
||||
@Transactional
|
||||
public FrequentFlyer getFrequentFlyer(String username) throws NoSuchFrequentFlyerException {
|
||||
|
||||
FrequentFlyer frequentFlyer = frequentFlyerDao.get(username);
|
||||
if (frequentFlyer != null) {
|
||||
return frequentFlyer;
|
||||
} else {
|
||||
throw new NoSuchFrequentFlyerException(username);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
|
||||
|
||||
FrequentFlyer frequentFlyer = frequentFlyerDao.get(username);
|
||||
if (frequentFlyer != null) {
|
||||
return new FrequentFlyerDetails(frequentFlyer);
|
||||
} else {
|
||||
throw new UsernameNotFoundException("Frequent flyer '" + username + "' not found");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,11 +15,10 @@
|
||||
*/
|
||||
package org.springframework.ws.samples.airline.service;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.LocalDate;
|
||||
|
||||
import org.springframework.ws.samples.airline.domain.Flight;
|
||||
import org.springframework.ws.samples.airline.domain.FrequentFlyer;
|
||||
import org.springframework.ws.samples.airline.domain.Passenger;
|
||||
@@ -52,9 +51,9 @@ public interface AirlineService {
|
||||
* @return a list of flights
|
||||
*/
|
||||
List<Flight> getFlights(String fromAirportCode,
|
||||
String toAirportCode,
|
||||
LocalDate departureDate,
|
||||
ServiceClass serviceClass);
|
||||
String toAirportCode,
|
||||
LocalDate departureDate,
|
||||
ServiceClass serviceClass);
|
||||
|
||||
/**
|
||||
* Books a single flight for a number of passengers. Passengers can be either specified by name or by frequent flyer
|
||||
@@ -69,10 +68,10 @@ public interface AirlineService {
|
||||
* exist
|
||||
* @throws NoSeatAvailableException if not enough seats are available for the flight
|
||||
* @throws NoSuchFrequentFlyerException if a specified {@link FrequentFlyer} cannot be found
|
||||
* @see org.springframework.ws.samples.airline.domain.Passenger
|
||||
* @see org.springframework.ws.samples.airline.domain.FrequentFlyer
|
||||
* @see Passenger
|
||||
* @see FrequentFlyer
|
||||
*/
|
||||
Ticket bookFlight(String flightNumber, DateTime departureTime, List<Passenger> passengers)
|
||||
Ticket bookFlight(String flightNumber, ZonedDateTime departureTime, List<Passenger> passengers)
|
||||
throws NoSuchFlightException, NoSeatAvailableException, NoSuchFrequentFlyerException;
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
|
||||
package org.springframework.ws.samples.airline.service;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import org.springframework.ws.soap.server.endpoint.annotation.FaultCode;
|
||||
import org.springframework.ws.soap.server.endpoint.annotation.SoapFault;
|
||||
|
||||
@@ -30,9 +31,9 @@ public class NoSuchFlightException extends Exception {
|
||||
|
||||
private String flightNumber;
|
||||
|
||||
private DateTime departureTime;
|
||||
private ZonedDateTime departureTime;
|
||||
|
||||
public NoSuchFlightException(String flightNumber, DateTime departureTime) {
|
||||
public NoSuchFlightException(String flightNumber, ZonedDateTime departureTime) {
|
||||
super("No flight with number [" + flightNumber + "] and departure time [" + departureTime + "]");
|
||||
this.flightNumber = flightNumber;
|
||||
this.departureTime = departureTime;
|
||||
@@ -46,7 +47,7 @@ public class NoSuchFlightException extends Exception {
|
||||
return flightNumber;
|
||||
}
|
||||
|
||||
public DateTime getDepartureTime() {
|
||||
public ZonedDateTime getDepartureTime() {
|
||||
return departureTime;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,12 @@
|
||||
*/
|
||||
package org.springframework.ws.samples.airline.service.impl;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.annotation.Secured;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -36,11 +40,6 @@ import org.springframework.ws.samples.airline.service.NoSeatAvailableException;
|
||||
import org.springframework.ws.samples.airline.service.NoSuchFlightException;
|
||||
import org.springframework.ws.samples.airline.service.NoSuchFrequentFlyerException;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.LocalDate;
|
||||
|
||||
/**
|
||||
* Default implementation of the <code>AirlineService</code> interface.
|
||||
*
|
||||
@@ -50,97 +49,96 @@ import org.joda.time.LocalDate;
|
||||
@Transactional(readOnly = true)
|
||||
public class AirlineServiceImpl implements AirlineService {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(AirlineServiceImpl.class);
|
||||
private static final Log logger = LogFactory.getLog(AirlineServiceImpl.class);
|
||||
|
||||
private FlightDao flightDao;
|
||||
private FlightDao flightDao;
|
||||
|
||||
private TicketDao ticketDao;
|
||||
private TicketDao ticketDao;
|
||||
|
||||
private FrequentFlyerSecurityService frequentFlyerSecurityService = new StubFrequentFlyerSecurityService();
|
||||
private FrequentFlyerSecurityService frequentFlyerSecurityService = new StubFrequentFlyerSecurityService();
|
||||
|
||||
@Autowired
|
||||
public AirlineServiceImpl(FlightDao flightDao, TicketDao ticketDao) {
|
||||
this.flightDao = flightDao;
|
||||
this.ticketDao = ticketDao;
|
||||
}
|
||||
@Autowired
|
||||
public AirlineServiceImpl(FlightDao flightDao, TicketDao ticketDao) {
|
||||
|
||||
@Autowired(required = false)
|
||||
public void setFrequentFlyerSecurityService(FrequentFlyerSecurityService frequentFlyerSecurityService) {
|
||||
this.frequentFlyerSecurityService = frequentFlyerSecurityService;
|
||||
}
|
||||
this.flightDao = flightDao;
|
||||
this.ticketDao = ticketDao;
|
||||
}
|
||||
|
||||
@Transactional(readOnly = false,
|
||||
rollbackFor = {NoSuchFlightException.class, NoSeatAvailableException.class, NoSuchFrequentFlyerException.class})
|
||||
public Ticket bookFlight(String flightNumber, DateTime departureTime, List<Passenger> passengers)
|
||||
throws NoSuchFlightException, NoSeatAvailableException, NoSuchFrequentFlyerException {
|
||||
Assert.notEmpty(passengers, "No passengers given");
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Booking flight '" + flightNumber + "' on '" + departureTime + "' for " + passengers);
|
||||
}
|
||||
Flight flight = flightDao.getFlight(flightNumber, departureTime);
|
||||
if (flight == null) {
|
||||
throw new NoSuchFlightException(flightNumber, departureTime);
|
||||
}
|
||||
else if (flight.getSeatsAvailable() < passengers.size()) {
|
||||
throw new NoSeatAvailableException(flight);
|
||||
}
|
||||
Ticket ticket = new Ticket();
|
||||
ticket.setIssueDate(new LocalDate());
|
||||
ticket.setFlight(flight);
|
||||
for (Passenger passenger : passengers) {
|
||||
// frequent flyer service is not required
|
||||
if (passenger instanceof FrequentFlyer && frequentFlyerSecurityService != null) {
|
||||
String username = ((FrequentFlyer) passenger).getUsername();
|
||||
Assert.hasLength(username, "No username specified");
|
||||
FrequentFlyer frequentFlyer = frequentFlyerSecurityService.getFrequentFlyer(username);
|
||||
frequentFlyer.addMiles(flight.getMiles());
|
||||
ticket.addPassenger(frequentFlyer);
|
||||
}
|
||||
else {
|
||||
ticket.addPassenger(passenger);
|
||||
}
|
||||
}
|
||||
flight.substractSeats(passengers.size());
|
||||
flightDao.update(flight);
|
||||
ticketDao.save(ticket);
|
||||
return ticket;
|
||||
}
|
||||
@Autowired(required = false)
|
||||
public void setFrequentFlyerSecurityService(FrequentFlyerSecurityService frequentFlyerSecurityService) {
|
||||
this.frequentFlyerSecurityService = frequentFlyerSecurityService;
|
||||
}
|
||||
|
||||
public Flight getFlight(Long id) throws NoSuchFlightException {
|
||||
Flight flight = flightDao.getFlight(id);
|
||||
if (flight != null) {
|
||||
return flight;
|
||||
}
|
||||
else {
|
||||
throw new NoSuchFlightException(id);
|
||||
}
|
||||
}
|
||||
@Transactional(readOnly = false,
|
||||
rollbackFor = { NoSuchFlightException.class, NoSeatAvailableException.class, NoSuchFrequentFlyerException.class })
|
||||
public Ticket bookFlight(String flightNumber, ZonedDateTime departureTime, List<Passenger> passengers)
|
||||
throws NoSuchFlightException, NoSeatAvailableException, NoSuchFrequentFlyerException {
|
||||
|
||||
public List<Flight> getFlights(String fromAirportCode,
|
||||
String toAirportCode,
|
||||
LocalDate departureDate,
|
||||
ServiceClass serviceClass) {
|
||||
if (serviceClass == null) {
|
||||
serviceClass = ServiceClass.ECONOMY;
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(
|
||||
"Getting flights from '" + fromAirportCode + "' to '" + toAirportCode + "' on " + departureDate);
|
||||
}
|
||||
List<Flight> flights =
|
||||
flightDao.findFlights(fromAirportCode, toAirportCode, departureDate.toInterval(), serviceClass);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Returning " + flights.size() + " flights");
|
||||
}
|
||||
return flights;
|
||||
}
|
||||
Assert.notEmpty(passengers, "No passengers given");
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Booking flight '" + flightNumber + "' on '" + departureTime + "' for " + passengers);
|
||||
}
|
||||
Flight flight = flightDao.getFlight(flightNumber, departureTime);
|
||||
if (flight == null) {
|
||||
throw new NoSuchFlightException(flightNumber, departureTime);
|
||||
} else if (flight.getSeatsAvailable() < passengers.size()) {
|
||||
throw new NoSeatAvailableException(flight);
|
||||
}
|
||||
Ticket ticket = new Ticket();
|
||||
ticket.setIssueDate(new LocalDate());
|
||||
ticket.setFlight(flight);
|
||||
for (Passenger passenger : passengers) {
|
||||
// frequent flyer service is not required
|
||||
if (passenger instanceof FrequentFlyer && frequentFlyerSecurityService != null) {
|
||||
String username = ((FrequentFlyer) passenger).getUsername();
|
||||
Assert.hasLength(username, "No username specified");
|
||||
FrequentFlyer frequentFlyer = frequentFlyerSecurityService.getFrequentFlyer(username);
|
||||
frequentFlyer.addMiles(flight.getMiles());
|
||||
ticket.addPassenger(frequentFlyer);
|
||||
} else {
|
||||
ticket.addPassenger(passenger);
|
||||
}
|
||||
}
|
||||
flight.substractSeats(passengers.size());
|
||||
flightDao.update(flight);
|
||||
ticketDao.save(ticket);
|
||||
return ticket;
|
||||
}
|
||||
|
||||
@Secured({"ROLE_FREQUENT_FLYER"})
|
||||
public int getFrequentFlyerMileage() {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Using " + frequentFlyerSecurityService + " for security");
|
||||
}
|
||||
FrequentFlyer frequentFlyer = frequentFlyerSecurityService.getCurrentlyAuthenticatedFrequentFlyer();
|
||||
return frequentFlyer != null ? frequentFlyer.getMiles() : 0;
|
||||
}
|
||||
public Flight getFlight(Long id) throws NoSuchFlightException {
|
||||
|
||||
Flight flight = flightDao.getFlight(id);
|
||||
if (flight != null) {
|
||||
return flight;
|
||||
} else {
|
||||
throw new NoSuchFlightException(id);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Flight> getFlights(String fromAirportCode, String toAirportCode, LocalDate departureDate,
|
||||
ServiceClass serviceClass) {
|
||||
|
||||
if (serviceClass == null) {
|
||||
serviceClass = ServiceClass.ECONOMY;
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Getting flights from '" + fromAirportCode + "' to '" + toAirportCode + "' on " + departureDate);
|
||||
}
|
||||
List<Flight> flights = flightDao.findFlights(fromAirportCode, toAirportCode, departureDate.toInterval(),
|
||||
serviceClass);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Returning " + flights.size() + " flights");
|
||||
}
|
||||
return flights;
|
||||
}
|
||||
|
||||
@Secured({ "ROLE_FREQUENT_FLYER" })
|
||||
public int getFrequentFlyerMileage() {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Using " + frequentFlyerSecurityService + " for security");
|
||||
}
|
||||
FrequentFlyer frequentFlyer = frequentFlyerSecurityService.getCurrentlyAuthenticatedFrequentFlyer();
|
||||
return frequentFlyer != null ? frequentFlyer.getMiles() : 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,65 +16,63 @@
|
||||
|
||||
package org.springframework.ws.samples.airline.web;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.ws.samples.airline.domain.Flight;
|
||||
import org.springframework.ws.samples.airline.domain.ServiceClass;
|
||||
import org.springframework.ws.samples.airline.service.AirlineService;
|
||||
import org.springframework.ws.samples.airline.service.NoSuchFlightException;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
|
||||
/** @author Arjen Poutsma */
|
||||
@Controller
|
||||
@RequestMapping("/flights")
|
||||
public class FlightsController {
|
||||
|
||||
private AirlineService airlineService;
|
||||
private AirlineService airlineService;
|
||||
|
||||
@Autowired
|
||||
public FlightsController(AirlineService airlineService) {
|
||||
Assert.notNull(airlineService, "'airlineService' must not be null");
|
||||
this.airlineService = airlineService;
|
||||
}
|
||||
public FlightsController(AirlineService airlineService) {
|
||||
|
||||
@RequestMapping
|
||||
public String flightList(@RequestParam(value = "from", required = false)String fromAirportCode,
|
||||
@RequestParam(value = "to", required = false)String toAirportCode,
|
||||
@RequestParam(value = "departureDate", required = false)String departureDateString,
|
||||
@RequestParam(value = "serviceClass", required = false)String serviceClassString,
|
||||
ModelMap model) {
|
||||
if (!StringUtils.hasLength(departureDateString)) {
|
||||
departureDateString = new LocalDate().toString();
|
||||
}
|
||||
if (!StringUtils.hasLength(serviceClassString)) {
|
||||
serviceClassString = "ECONOMY";
|
||||
}
|
||||
ServiceClass serviceClass = ServiceClass.valueOf(serviceClassString);
|
||||
LocalDate departureDate = new LocalDate(departureDateString);
|
||||
Assert.notNull(airlineService, "'airlineService' must not be null");
|
||||
this.airlineService = airlineService;
|
||||
}
|
||||
|
||||
if (StringUtils.hasLength(fromAirportCode) && StringUtils.hasLength(toAirportCode)) {
|
||||
model.addAttribute("from", fromAirportCode);
|
||||
model.addAttribute("to", toAirportCode);
|
||||
model.addAttribute("departureDate", departureDateString);
|
||||
model.addAttribute("serviceClass", serviceClassString);
|
||||
model.addAttribute("flights",
|
||||
airlineService.getFlights(fromAirportCode, toAirportCode, departureDate, serviceClass));
|
||||
}
|
||||
return "flights";
|
||||
}
|
||||
@GetMapping
|
||||
public String flightList(@RequestParam(value = "from", required = false) String fromAirportCode,
|
||||
@RequestParam(value = "to", required = false) String toAirportCode,
|
||||
@RequestParam(value = "departureDate", required = false) String departureDateString,
|
||||
@RequestParam(value = "serviceClass", required = false) String serviceClassString, ModelMap model) {
|
||||
|
||||
@RequestMapping(value = "{id}")
|
||||
public String singleFlight(@PathVariable("id") long id, ModelMap model) throws NoSuchFlightException {
|
||||
Flight flight = airlineService.getFlight(id);
|
||||
model.addAttribute(flight);
|
||||
return "flight";
|
||||
}
|
||||
if (StringUtils.isEmpty(departureDateString)) {
|
||||
departureDateString = new LocalDate().toString();
|
||||
}
|
||||
if (StringUtils.isEmpty(serviceClassString)) {
|
||||
serviceClassString = "ECONOMY";
|
||||
}
|
||||
ServiceClass serviceClass = ServiceClass.valueOf(serviceClassString);
|
||||
LocalDate departureDate = new LocalDate(departureDateString);
|
||||
|
||||
if (StringUtils.hasLength(fromAirportCode) && StringUtils.hasLength(toAirportCode)) {
|
||||
model.addAttribute("from", fromAirportCode);
|
||||
model.addAttribute("to", toAirportCode);
|
||||
model.addAttribute("departureDate", departureDateString);
|
||||
model.addAttribute("serviceClass", serviceClassString);
|
||||
model.addAttribute("flights",
|
||||
airlineService.getFlights(fromAirportCode, toAirportCode, departureDate, serviceClass));
|
||||
}
|
||||
return "flights";
|
||||
}
|
||||
|
||||
@GetMapping(value = "{id}")
|
||||
public String singleFlight(@PathVariable("id") long id, ModelMap model) throws NoSuchFlightException {
|
||||
|
||||
model.addAttribute(airlineService.getFlight(id));
|
||||
return "flight";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,15 +16,22 @@
|
||||
|
||||
package org.springframework.ws.samples.airline.ws;
|
||||
|
||||
import static org.springframework.ws.samples.airline.ws.AirlineWebServiceConstants.*;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import javax.xml.datatype.DatatypeConfigurationException;
|
||||
import javax.xml.datatype.XMLGregorianCalendar;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.ws.samples.airline.domain.FrequentFlyer;
|
||||
@@ -46,16 +53,9 @@ import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
|
||||
import org.springframework.ws.server.endpoint.annotation.RequestPayload;
|
||||
import org.springframework.ws.server.endpoint.annotation.ResponsePayload;
|
||||
import org.springframework.ws.server.endpoint.annotation.XPathParam;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import static org.springframework.ws.samples.airline.ws.AirlineWebServiceConstants.*;
|
||||
|
||||
/**
|
||||
* Endpoint that handles the Airline Web Service messages using a combination of JAXB2 marshalling and XPath
|
||||
* expressions.
|
||||
@@ -65,115 +65,122 @@ import static org.springframework.ws.samples.airline.ws.AirlineWebServiceConstan
|
||||
@Endpoint
|
||||
public class AirlineEndpoint {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(AirlineEndpoint.class);
|
||||
private static final Log logger = LogFactory.getLog(AirlineEndpoint.class);
|
||||
|
||||
private final ObjectFactory objectFactory = new ObjectFactory();
|
||||
private final ObjectFactory objectFactory = new ObjectFactory();
|
||||
|
||||
private final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
|
||||
private final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
|
||||
|
||||
private final AirlineService airlineService;
|
||||
private final AirlineService airlineService;
|
||||
|
||||
@Autowired
|
||||
public AirlineEndpoint(AirlineService airlineService) {
|
||||
this.airlineService = airlineService;
|
||||
}
|
||||
@Autowired
|
||||
public AirlineEndpoint(AirlineService airlineService) {
|
||||
this.airlineService = airlineService;
|
||||
}
|
||||
|
||||
/**
|
||||
* This endpoint method uses a combination of XPath expressions and marshalling to handle message with a
|
||||
* <code><GetFlightsRequest></code> payload.
|
||||
*
|
||||
* @param from the from airport
|
||||
* @param to the to airport
|
||||
* @param departureDateString the string representation of the departure date
|
||||
* @param serviceClassString the string representation of the service class
|
||||
* @return the JAXB2 representation of a <code><GetFlightsResponse></code>
|
||||
*/
|
||||
@PayloadRoot(localPart = GET_FLIGHTS_REQUEST, namespace = MESSAGES_NAMESPACE)
|
||||
@Namespace(prefix = "m", uri = MESSAGES_NAMESPACE)
|
||||
@ResponsePayload
|
||||
public GetFlightsResponse getFlights(@XPathParam("//m:from") String from,
|
||||
@XPathParam("//m:to") String to,
|
||||
@XPathParam("//m:departureDate") String departureDateString,
|
||||
@XPathParam("//m:serviceClass") String serviceClassString)
|
||||
throws DatatypeConfigurationException {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Received GetFlightsRequest '" + from + "' to '" + to + "' on " + departureDateString);
|
||||
}
|
||||
LocalDate departureDate = new LocalDate(departureDateString);
|
||||
ServiceClass serviceClass = null;
|
||||
if (StringUtils.hasLength(serviceClassString)) {
|
||||
serviceClass = ServiceClass.valueOf(serviceClassString.toUpperCase());
|
||||
}
|
||||
List<org.springframework.ws.samples.airline.domain.Flight> flights =
|
||||
airlineService.getFlights(from, to, departureDate, serviceClass);
|
||||
/**
|
||||
* This endpoint method uses a combination of XPath expressions and marshalling to handle message with a
|
||||
* <code><GetFlightsRequest></code> payload.
|
||||
*
|
||||
* @param from the from airport
|
||||
* @param to the to airport
|
||||
* @param departureDateString the string representation of the departure date
|
||||
* @param serviceClassString the string representation of the service class
|
||||
* @return the JAXB2 representation of a <code><GetFlightsResponse></code>
|
||||
*/
|
||||
@PayloadRoot(localPart = GET_FLIGHTS_REQUEST, namespace = MESSAGES_NAMESPACE)
|
||||
@Namespace(prefix = "m", uri = MESSAGES_NAMESPACE)
|
||||
@ResponsePayload
|
||||
public GetFlightsResponse getFlights(@XPathParam("//m:from") String from, @XPathParam("//m:to") String to,
|
||||
@XPathParam("//m:departureDate") String departureDateString,
|
||||
@XPathParam("//m:serviceClass") String serviceClassString) throws DatatypeConfigurationException {
|
||||
|
||||
GetFlightsResponse response = objectFactory.createGetFlightsResponse();
|
||||
for (org.springframework.ws.samples.airline.domain.Flight domainFlight : flights) {
|
||||
response.getFlight().add(SchemaConversionUtils.toSchemaType(domainFlight));
|
||||
}
|
||||
return response;
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Received GetFlightsRequest '" + from + "' to '" + to + "' on " + departureDateString);
|
||||
}
|
||||
|
||||
/**
|
||||
* This endpoint method uses marshalling to handle message with a <code><BookFlightRequest></code> payload.
|
||||
*
|
||||
* @param request the JAXB2 representation of a <code><BookFlightRequest></code>
|
||||
* @return the JAXB2 representation of a <code><BookFlightResponse></code>
|
||||
*/
|
||||
@PayloadRoot(localPart = BOOK_FLIGHT_REQUEST, namespace = MESSAGES_NAMESPACE)
|
||||
@ResponsePayload
|
||||
public JAXBElement<Ticket> bookFlight(@RequestPayload BookFlightRequest request)
|
||||
throws NoSeatAvailableException, DatatypeConfigurationException, NoSuchFlightException,
|
||||
NoSuchFrequentFlyerException {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Received BookingFlightRequest '" + request.getFlightNumber() + "' on '" +
|
||||
request.getDepartureTime() + "' for " + request.getPassengers().getPassengerOrUsername());
|
||||
}
|
||||
Ticket ticket = bookSchemaFlight(request.getFlightNumber(), request.getDepartureTime(),
|
||||
request.getPassengers().getPassengerOrUsername());
|
||||
return objectFactory.createBookFlightResponse(ticket);
|
||||
}
|
||||
LocalDate departureDate = new LocalDate(departureDateString);
|
||||
ServiceClass serviceClass = null;
|
||||
|
||||
/**
|
||||
* Converts between the domain and schema types.
|
||||
*/
|
||||
private Ticket bookSchemaFlight(String flightNumber,
|
||||
XMLGregorianCalendar xmlDepartureTime,
|
||||
List<Object> passengerOrUsernameList)
|
||||
throws NoSeatAvailableException, NoSuchFlightException, NoSuchFrequentFlyerException,
|
||||
DatatypeConfigurationException {
|
||||
DateTime departureTime = SchemaConversionUtils.toDateTime(xmlDepartureTime);
|
||||
List<Passenger> passengers = new ArrayList<Passenger>(passengerOrUsernameList.size());
|
||||
for (Iterator<Object> iterator = passengerOrUsernameList.iterator(); iterator.hasNext();) {
|
||||
Object passengerOrUsername = iterator.next();
|
||||
if (passengerOrUsername instanceof Name) {
|
||||
Name passengerName = (Name) passengerOrUsername;
|
||||
Passenger passenger = new Passenger(passengerName.getFirst(), passengerName.getLast());
|
||||
passengers.add(passenger);
|
||||
}
|
||||
else if (passengerOrUsername instanceof String) {
|
||||
String frequentFlyerUsername = (String) passengerOrUsername;
|
||||
FrequentFlyer frequentFlyer = new FrequentFlyer(frequentFlyerUsername);
|
||||
passengers.add(frequentFlyer);
|
||||
}
|
||||
}
|
||||
org.springframework.ws.samples.airline.domain.Ticket domainTicket =
|
||||
airlineService.bookFlight(flightNumber, departureTime, passengers);
|
||||
return SchemaConversionUtils.toSchemaType(domainTicket);
|
||||
}
|
||||
if (StringUtils.hasLength(serviceClassString)) {
|
||||
serviceClass = ServiceClass.valueOf(serviceClassString.toUpperCase());
|
||||
}
|
||||
List<org.springframework.ws.samples.airline.domain.Flight> flights = airlineService.getFlights(from, to,
|
||||
departureDate, serviceClass);
|
||||
|
||||
@PayloadRoot(localPart = GET_FREQUENT_FLYER_MILEAGE_REQUEST, namespace = MESSAGES_NAMESPACE)
|
||||
@ResponsePayload
|
||||
public Element getFrequentFlyerMileage() throws Exception {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Received GetFrequentFlyerMileageRequest");
|
||||
}
|
||||
int mileage = airlineService.getFrequentFlyerMileage();
|
||||
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
|
||||
Document document = documentBuilder.newDocument();
|
||||
Element response = document.createElementNS(MESSAGES_NAMESPACE, GET_FREQUENT_FLYER_MILEAGE_RESPONSE);
|
||||
response.setTextContent(Integer.toString(mileage));
|
||||
return response;
|
||||
}
|
||||
GetFlightsResponse response = objectFactory.createGetFlightsResponse();
|
||||
for (org.springframework.ws.samples.airline.domain.Flight domainFlight : flights) {
|
||||
response.getFlight().add(SchemaConversionUtils.toSchemaType(domainFlight));
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* This endpoint method uses marshalling to handle message with a <code><BookFlightRequest></code> payload.
|
||||
*
|
||||
* @param request the JAXB2 representation of a <code><BookFlightRequest></code>
|
||||
* @return the JAXB2 representation of a <code><BookFlightResponse></code>
|
||||
*/
|
||||
@PayloadRoot(localPart = BOOK_FLIGHT_REQUEST, namespace = MESSAGES_NAMESPACE)
|
||||
@ResponsePayload
|
||||
public JAXBElement<Ticket> bookFlight(@RequestPayload BookFlightRequest request) throws NoSeatAvailableException,
|
||||
DatatypeConfigurationException, NoSuchFlightException, NoSuchFrequentFlyerException {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Received BookingFlightRequest '" + request.getFlightNumber() + "' on '" + request.getDepartureTime()
|
||||
+ "' for " + request.getPassengers().getPassengerOrUsername());
|
||||
}
|
||||
|
||||
Ticket ticket = bookSchemaFlight(request.getFlightNumber(), request.getDepartureTime(),
|
||||
request.getPassengers().getPassengerOrUsername());
|
||||
|
||||
return objectFactory.createBookFlightResponse(ticket);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts between the domain and schema types.
|
||||
*/
|
||||
private Ticket bookSchemaFlight(String flightNumber, XMLGregorianCalendar xmlDepartureTime,
|
||||
List<Object> passengerOrUsernameList) throws NoSeatAvailableException, NoSuchFlightException,
|
||||
NoSuchFrequentFlyerException, DatatypeConfigurationException {
|
||||
|
||||
ZonedDateTime departureTime = SchemaConversionUtils.toDateTime(xmlDepartureTime);
|
||||
List<Passenger> passengers = new ArrayList<Passenger>(passengerOrUsernameList.size());
|
||||
|
||||
for (Iterator<Object> iterator = passengerOrUsernameList.iterator(); iterator.hasNext();) {
|
||||
Object passengerOrUsername = iterator.next();
|
||||
if (passengerOrUsername instanceof Name) {
|
||||
Name passengerName = (Name) passengerOrUsername;
|
||||
Passenger passenger = new Passenger(passengerName.getFirst(), passengerName.getLast());
|
||||
passengers.add(passenger);
|
||||
} else if (passengerOrUsername instanceof String) {
|
||||
String frequentFlyerUsername = (String) passengerOrUsername;
|
||||
FrequentFlyer frequentFlyer = new FrequentFlyer(frequentFlyerUsername);
|
||||
passengers.add(frequentFlyer);
|
||||
}
|
||||
}
|
||||
org.springframework.ws.samples.airline.domain.Ticket domainTicket = airlineService.bookFlight(flightNumber,
|
||||
departureTime, passengers);
|
||||
|
||||
return SchemaConversionUtils.toSchemaType(domainTicket);
|
||||
}
|
||||
|
||||
@PayloadRoot(localPart = GET_FREQUENT_FLYER_MILEAGE_REQUEST, namespace = MESSAGES_NAMESPACE)
|
||||
@ResponsePayload
|
||||
public Element getFrequentFlyerMileage() throws Exception {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Received GetFrequentFlyerMileageRequest");
|
||||
}
|
||||
|
||||
int mileage = airlineService.getFrequentFlyerMileage();
|
||||
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
|
||||
Document document = documentBuilder.newDocument();
|
||||
Element response = document.createElementNS(MESSAGES_NAMESPACE, GET_FREQUENT_FLYER_MILEAGE_RESPONSE);
|
||||
response.setTextContent(Integer.toString(mileage));
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
package org.springframework.ws.samples.airline.ws;
|
||||
|
||||
import org.springframework.boot.web.server.MimeMappings;
|
||||
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
|
||||
import org.springframework.boot.web.servlet.ServletRegistrationBean;
|
||||
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.util.MimeTypeUtils;
|
||||
import org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor;
|
||||
import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;
|
||||
import org.springframework.ws.soap.security.xwss.XwsSecurityInterceptor;
|
||||
import org.springframework.ws.soap.security.xwss.callback.SpringDigestPasswordValidationCallbackHandler;
|
||||
import org.springframework.ws.soap.server.SoapMessageDispatcher;
|
||||
import org.springframework.ws.soap.server.endpoint.interceptor.PayloadRootSmartSoapEndpointInterceptor;
|
||||
import org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor;
|
||||
import org.springframework.ws.transport.http.MessageDispatcherServlet;
|
||||
import org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition;
|
||||
import org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection;
|
||||
|
||||
@Configuration
|
||||
public class WebServicesConfiguration {
|
||||
|
||||
@Bean
|
||||
WebServerFactoryCustomizer<ConfigurableServletWebServerFactory> wsMimeMappings() {
|
||||
|
||||
return factory -> {
|
||||
MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
|
||||
mappings.add("xsd", MimeTypeUtils.TEXT_XML_VALUE);
|
||||
factory.setMimeMappings(mappings);
|
||||
};
|
||||
}
|
||||
|
||||
@Bean
|
||||
ServletRegistrationBean<?> webServicesRegistration(ApplicationContext ctx) {
|
||||
|
||||
MessageDispatcherServlet messageDispatcherServlet = new MessageDispatcherServlet();
|
||||
messageDispatcherServlet.setApplicationContext(ctx);
|
||||
messageDispatcherServlet.setTransformWsdlLocations(true);
|
||||
|
||||
return new ServletRegistrationBean<>(messageDispatcherServlet, "/airline-server/*", "*.wsdl");
|
||||
}
|
||||
|
||||
@Bean
|
||||
PayloadLoggingInterceptor payloadLoggingInterceptor() {
|
||||
return new PayloadLoggingInterceptor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
PayloadValidatingInterceptor payloadValidatingInterceptor(CommonsXsdSchemaCollection xsdSchemaCollection) {
|
||||
|
||||
PayloadValidatingInterceptor payloadValidatingInterceptor = new PayloadValidatingInterceptor();
|
||||
payloadValidatingInterceptor.setXsdSchemaCollection(xsdSchemaCollection);
|
||||
payloadValidatingInterceptor.setValidateRequest(true);
|
||||
payloadValidatingInterceptor.setValidateResponse(true);
|
||||
|
||||
return payloadValidatingInterceptor;
|
||||
}
|
||||
|
||||
@Bean
|
||||
XwsSecurityInterceptor securityInterceptor(UserDetailsService securityService) {
|
||||
|
||||
XwsSecurityInterceptor securityInterceptor = new XwsSecurityInterceptor();
|
||||
securityInterceptor.setSecureResponse(false);
|
||||
securityInterceptor.setPolicyConfiguration(
|
||||
new ClassPathResource("org/springframework/ws/samples/airline/security/securityPolicy.xml"));
|
||||
securityInterceptor.setCallbackHandler(springDigestPasswordValidationCallbackHandler(securityService));
|
||||
|
||||
return securityInterceptor;
|
||||
}
|
||||
|
||||
@Bean
|
||||
PayloadRootSmartSoapEndpointInterceptor smartSoapEndpointInterceptor(XwsSecurityInterceptor securityInterceptor) {
|
||||
|
||||
return new PayloadRootSmartSoapEndpointInterceptor(securityInterceptor,
|
||||
"http://www.springframework.org/spring-ws/samples/airline/schemas/messages", "GetFrequentFlyerMileageRequest");
|
||||
}
|
||||
|
||||
@Bean
|
||||
SpringDigestPasswordValidationCallbackHandler springDigestPasswordValidationCallbackHandler(
|
||||
UserDetailsService securityService) {
|
||||
|
||||
SpringDigestPasswordValidationCallbackHandler handler = new SpringDigestPasswordValidationCallbackHandler();
|
||||
handler.setUserDetailsService(securityService);
|
||||
return handler;
|
||||
}
|
||||
|
||||
@Bean
|
||||
SaajSoapMessageFactory messageFactory() {
|
||||
return new SaajSoapMessageFactory();
|
||||
}
|
||||
|
||||
@Bean
|
||||
SoapMessageDispatcher dispatcher() {
|
||||
return new SoapMessageDispatcher();
|
||||
}
|
||||
|
||||
@Bean
|
||||
CommonsXsdSchemaCollection commonsXsdSchemaCollection() {
|
||||
|
||||
CommonsXsdSchemaCollection commonsXsdSchemaCollection = new CommonsXsdSchemaCollection();
|
||||
commonsXsdSchemaCollection.setXsds(new ClassPathResource("messages.xsd"));
|
||||
commonsXsdSchemaCollection.setInline(true);
|
||||
return commonsXsdSchemaCollection;
|
||||
}
|
||||
|
||||
@Bean("services")
|
||||
DefaultWsdl11Definition airline(CommonsXsdSchemaCollection schemaCollection) {
|
||||
|
||||
DefaultWsdl11Definition definition = new DefaultWsdl11Definition();
|
||||
definition.setSchemaCollection(schemaCollection);
|
||||
definition.setPortTypeName("Airline");
|
||||
definition.setLocationUri("http://localhost:8080/airline-server/services");
|
||||
definition.setTargetNamespace("http://www.springframework.org/spring-ws/samples/airline/definitions");
|
||||
return definition;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence https://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
|
||||
version="1.0">
|
||||
<persistence-unit name="airline">
|
||||
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
|
||||
<class>org.springframework.ws.samples.airline.domain.Airport</class>
|
||||
<class>org.springframework.ws.samples.airline.domain.Flight</class>
|
||||
<class>org.springframework.ws.samples.airline.domain.FrequentFlyer</class>
|
||||
<class>org.springframework.ws.samples.airline.domain.Passenger</class>
|
||||
<class>org.springframework.ws.samples.airline.domain.Ticket</class>
|
||||
</persistence-unit>
|
||||
|
||||
</persistence>
|
||||
3
airline/server/src/main/resources/application.properties
Normal file
3
airline/server/src/main/resources/application.properties
Normal file
@@ -0,0 +1,3 @@
|
||||
logging.level.org.springframework.data=DEBUG
|
||||
logging.level.org.springframework.ws=DEBUG
|
||||
logging.level.org.springframework.web=DEBUG
|
||||
@@ -1,8 +0,0 @@
|
||||
log4j.rootLogger=WARN, stdout
|
||||
log4j.logger.org.springframework.ws=DEBUG
|
||||
log4j.logger.org.springframework.xml=DEBUG
|
||||
log4j.logger.openjpa=INFO
|
||||
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n
|
||||
@@ -1,42 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-3.1.xsd
|
||||
http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context-3.1.xsd">
|
||||
|
||||
<context:component-scan base-package="org.springframework.ws.samples.airline.dao.jpa"/>
|
||||
|
||||
<context:annotation-config/>
|
||||
|
||||
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
|
||||
<property name="persistenceUnitName" value="airline"/>
|
||||
<property name="dataSource" ref="dataSource"/>
|
||||
<property name="jpaDialect">
|
||||
<bean class="org.springframework.orm.jpa.vendor.OpenJpaDialect"/>
|
||||
</property>
|
||||
<property name="jpaProperties">
|
||||
<props>
|
||||
<prop key="openjpa.Log">commons</prop>
|
||||
<prop key="openjpa.jdbc.SynchronizeMappings">buildSchema</prop>
|
||||
<prop key="openjpa.jdbc.MappingDefaults">
|
||||
FieldStrategies='org.joda.time.DateTime=org.springframework.ws.samples.airline.domain.openjpa.DateTimeValueHandler,
|
||||
org.joda.time.LocalDate=org.springframework.ws.samples.airline.domain.openjpa.LocalDateValueHandler'
|
||||
</prop>
|
||||
<prop key="openjpa.jdbc.DBDictionary">org.apache.openjpa.jdbc.sql.HSQLDictionary</prop>
|
||||
</props>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
|
||||
<property name="entityManagerFactory" ref="entityManagerFactory"/>
|
||||
</bean>
|
||||
|
||||
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
|
||||
<property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
|
||||
<property name="url" value="jdbc:hsqldb:mem:airline"/>
|
||||
<property name="username" value="sa"/>
|
||||
<property name="password" value=""/>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@@ -1,28 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:jms="http://www.springframework.org/schema/jms"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-3.1.xsd
|
||||
http://www.springframework.org/schema/jms https://www.springframework.org/schema/jms/spring-jms-3.1.xsd">
|
||||
|
||||
<!-- ===================== JMS TRANSPORT ===================================== -->
|
||||
|
||||
<bean id="broker" class="org.apache.activemq.broker.BrokerFactory" factory-method="createBroker"
|
||||
init-method="start">
|
||||
<constructor-arg value="broker:tcp://localhost:61616?persistent=false"/>
|
||||
</bean>
|
||||
|
||||
<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
|
||||
<property name="brokerURL" value="tcp://localhost:61616"/>
|
||||
</bean>
|
||||
|
||||
<jms:listener-container connection-factory="connectionFactory">
|
||||
<jms:listener destination="RequestQueue" ref="messageListener"/>
|
||||
</jms:listener-container>
|
||||
|
||||
<bean id="messageListener" class="org.springframework.ws.transport.jms.WebServiceMessageListener">
|
||||
<property name="messageFactory" ref="messageFactory"/>
|
||||
<property name="messageReceiver" ref="messageReceiver"/>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:security="http://www.springframework.org/schema/security"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-3.1.xsd
|
||||
http://www.springframework.org/schema/security https://www.springframework.org/schema/security/spring-security-3.1.xsd">
|
||||
|
||||
<description>
|
||||
This application context contains the WS-Security and Spring Security beans.
|
||||
</description>
|
||||
|
||||
<security:global-method-security secured-annotations="enabled"/>
|
||||
|
||||
<security:authentication-manager>
|
||||
<security:authentication-provider user-service-ref="securityService"/>
|
||||
</security:authentication-manager>
|
||||
|
||||
<bean id="securityService"
|
||||
class="org.springframework.ws.samples.airline.security.SpringFrequentFlyerSecurityService">
|
||||
<description>
|
||||
A security service used to obtain Frequent Flyer information.
|
||||
</description>
|
||||
</bean>
|
||||
|
||||
|
||||
</beans>
|
||||
@@ -1,3 +1,3 @@
|
||||
<xwss:SecurityConfiguration dumpMessages="false" xmlns:xwss="https://java.sun.com/xml/ns/xwss/config">
|
||||
<xwss:SecurityConfiguration dumpMessages="false" xmlns:xwss="http://java.sun.com/xml/ns/xwss/config">
|
||||
<xwss:RequireUsernameToken passwordDigestRequired="true" nonceRequired="true"/>
|
||||
</xwss:SecurityConfiguration>
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-3.1.xsd
|
||||
http://www.springframework.org/schema/tx https://www.springframework.org/schema/tx/spring-tx-3.1.xsd
|
||||
http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context-3.1.xsd">
|
||||
|
||||
<tx:annotation-driven/>
|
||||
|
||||
<context:annotation-config/>
|
||||
|
||||
<context:component-scan base-package="org.springframework.ws.samples.airline.service"/>
|
||||
|
||||
</beans>
|
||||
@@ -1,47 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:sws="http://www.springframework.org/schema/web-services"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-3.1.xsd
|
||||
http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context-3.1.xsd
|
||||
http://www.springframework.org/schema/web-services https://www.springframework.org/schema/web-services/web-services-2.0.xsd">
|
||||
|
||||
<sws:annotation-driven />
|
||||
|
||||
<sws:interceptors>
|
||||
<bean class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor"/>
|
||||
<bean class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor">
|
||||
<property name="xsdSchemaCollection" ref="schemaCollection"/>
|
||||
<property name="validateRequest" value="true"/>
|
||||
<property name="validateResponse" value="true"/>
|
||||
</bean>
|
||||
<sws:payloadRoot localPart="GetFrequentFlyerMileageRequest" namespaceUri="http://www.springframework.org/spring-ws/samples/airline/schemas/messages">
|
||||
<bean class="org.springframework.ws.soap.security.xwss.XwsSecurityInterceptor">
|
||||
<property name="secureResponse" value="false"/>
|
||||
<property name="policyConfiguration"
|
||||
value="classpath:org/springframework/ws/samples/airline/security/securityPolicy.xml"/>
|
||||
<property name="callbackHandler">
|
||||
<bean class="org.springframework.ws.soap.security.xwss.callback.SpringDigestPasswordValidationCallbackHandler">
|
||||
<property name="userDetailsService" ref="securityService"/>
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
</sws:payloadRoot>
|
||||
</sws:interceptors>
|
||||
|
||||
<context:component-scan base-package="org.springframework.ws.samples.airline.ws"/>
|
||||
|
||||
<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory"/>
|
||||
|
||||
<bean id="messageReceiver" class="org.springframework.ws.soap.server.SoapMessageDispatcher"/>
|
||||
|
||||
<bean id="schemaCollection" class="org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection">
|
||||
<description>
|
||||
This bean wrap the messages.xsd (which imports types.xsd), and inlines them as a one.
|
||||
</description>
|
||||
<property name="xsds" value="/messages.xsd"/>
|
||||
<property name="inline" value="true"/>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
41
airline/server/src/main/resources/templates/flight.html
Normal file
41
airline/server/src/main/resources/templates/flight.html
Normal file
@@ -0,0 +1,41 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head><title>Flights</title></head>
|
||||
<body>
|
||||
<table>
|
||||
<tr>
|
||||
<td>Number:</td>
|
||||
<td>
|
||||
<span th:text="${flight.number}"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>From:</td>
|
||||
<td>
|
||||
<span th:text="${flight.from.city}"/>
|
||||
(<span th:text="${flight.from.code}"/>)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Departure:</td>
|
||||
<td>
|
||||
<span th:text="${flight.departureTime}"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>To:</td>
|
||||
<td>
|
||||
<span th:text="${flight.to.city}"/>
|
||||
(<span th:text="${flight.to.code}"/>)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Departure:</td>
|
||||
<td>
|
||||
<span th:text="${flight.arrivalTime}"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<a th:href="@{/flights}">Flights</a>
|
||||
</body>
|
||||
</html>
|
||||
62
airline/server/src/main/resources/templates/flights.html
Normal file
62
airline/server/src/main/resources/templates/flights.html
Normal file
@@ -0,0 +1,62 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head><title>Flights</title></head>
|
||||
<body>
|
||||
<form method="GET" th:action="@{/flights}">
|
||||
<table>
|
||||
<tr>
|
||||
<td>From:</td>
|
||||
<td><input type="text" name="from" th:value="*{from}" th:default="AMS"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>To:</td>
|
||||
<td><input type="text" name="to" th:value="*{to}" th:default="VCE"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Departure Date:</td>
|
||||
<td><input type="text" name="departureDate" th:value="*{departureDate}" th:default="2006-01-31"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Service Class:</td>
|
||||
<td>
|
||||
<select name="serviceClass">
|
||||
<option value="ECONOMY" selected="selected">Economy</option>
|
||||
<option value="BUSINESS">Business</option>
|
||||
<option value="FIRST">First</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input type="submit" value="Submit"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div th:unless="${#lists.isEmpty(flights)}">
|
||||
|
||||
<table border="1px">
|
||||
<tr>
|
||||
<th>Number</th>
|
||||
<th>Departs</th>
|
||||
<th>Arrives</th>
|
||||
</tr>
|
||||
<tr th:each="flight : ${flights}">
|
||||
<td>
|
||||
<a th:href="@{'/flights/' + ${flight.id}}" th:text="${flight.number}"></a>
|
||||
</td>
|
||||
<td>
|
||||
<span th:text="${flight.from.city}"/>
|
||||
(<span th:text="${flight.from.code}"/>)
|
||||
<span th:text="${flight.departureTime}"/>
|
||||
</td>
|
||||
<td>
|
||||
<span th:text="${flight.to.city}"/>
|
||||
(<span th:text="${flight.to.code}"/>)
|
||||
<span th:text="${flight.arrivalTime}"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,12 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head><title>No Such Flight</title></head>
|
||||
<body>
|
||||
|
||||
<p th:text="${ex}"></p>
|
||||
|
||||
<h2>No such flight: <span th:text="${ex.message}"/></h2>
|
||||
<a th:href="@{/flights}">Flights</a>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,13 +0,0 @@
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<html>
|
||||
<%
|
||||
Exception ex = (Exception) request.getAttribute("exception");
|
||||
%>
|
||||
<head><title><%= ex.getMessage() %>
|
||||
</title></head>
|
||||
<body>
|
||||
<h2><%= ex.getMessage() %>
|
||||
</h2>
|
||||
<a href='<c:url value="/flights"/>'>Flights</a>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,47 +0,0 @@
|
||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="joda" uri="http://www.joda.org/joda/time/tags" %>
|
||||
<html>
|
||||
<head><title>Flights</title></head>
|
||||
<body>
|
||||
<table>
|
||||
<tr>
|
||||
<td>Number:</td>
|
||||
<td>
|
||||
<c:out value="${flight.number}"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>From:</td>
|
||||
<td>
|
||||
<c:out value="${flight.from.city}"/>
|
||||
(
|
||||
<c:out value="${flight.from.code}"/>
|
||||
)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Departure:</td>
|
||||
<td>
|
||||
<joda:format value="${flight.departureTime}" style="MM"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>To:</td>
|
||||
<td>
|
||||
<c:out value="${flight.to.city}"/>
|
||||
(
|
||||
<c:out value="${flight.to.code}"/>
|
||||
)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Departure:</td>
|
||||
<td>
|
||||
<joda:format value="${flight.arrivalTime}" style="MM"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<a href='<c:url value="/flights.html"/>'>Flights</a>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,73 +0,0 @@
|
||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||
<%@ taglib prefix="joda" uri="http://www.joda.org/joda/time/tags" %>
|
||||
<html>
|
||||
<head><title>Flights</title></head>
|
||||
<body>
|
||||
<form a method="get" action='<c:url value="/flights.html"/>'>
|
||||
<table>
|
||||
<tr>
|
||||
<td>From:</td>
|
||||
<td><input name="from" value='<c:out value="${from}" default="AMS"/>'/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>To:</td>
|
||||
<td><input name="to" value="<c:out value="${to}" default="VCE"/>"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Departure Date:</td>
|
||||
<td><input name="departureDate" value="<c:out value="${departureDate}" default="2006-01-31"/>"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Service Class:</td>
|
||||
<td>
|
||||
<select name="serviceClass">
|
||||
<option value="ECONOMY" selected="selected">Economy</option>
|
||||
<option value="BUSINESS">Business</option>
|
||||
<option value="FIRST">First</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input type="submit" value="Submit"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<c:if test="${!empty flights}">
|
||||
<table border="1px">
|
||||
<tr>
|
||||
<th>Number</th>
|
||||
<th>Departs</th>
|
||||
<th>Arrives</th>
|
||||
</tr>
|
||||
<c:forEach var="flight" items="${flights}">
|
||||
<tr>
|
||||
<td>
|
||||
<spring:url var="flightUrl" value="flights/{id}.html">
|
||||
<spring:param name="id" value="${flight.id}"/>
|
||||
</spring:url>
|
||||
<a href='<c:out value="${flightUrl}"/>'><c:out value="${flight.number}"/></a>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${flight.from.city}"/>
|
||||
(
|
||||
<c:out value="${flight.from.code}"/>
|
||||
)
|
||||
<joda:format value="${flight.departureTime}" style="SS"/>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${flight.to.city}"/>
|
||||
(
|
||||
<c:out value="${flight.to.code}"/>
|
||||
)
|
||||
<joda:format value="${flight.arrivalTime}" style="SS"/>
|
||||
</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</table>
|
||||
</c:if>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,13 +0,0 @@
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<html>
|
||||
<head><title>No Such Flight</title></head>
|
||||
<body>
|
||||
<%
|
||||
Exception ex = (Exception) request.getAttribute("exception");
|
||||
%>
|
||||
<h2>No such flight: <%= ex.getMessage() %>
|
||||
</h2>
|
||||
<a href='<c:url value="/flights.html"/>'>Flights</a>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,33 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context-2.5.xsd">
|
||||
|
||||
<description>
|
||||
This web application context contains a simple Spring Web MVC web application that shows flights
|
||||
</description>
|
||||
|
||||
<context:component-scan base-package="org.springframework.ws.samples.airline.web"/>
|
||||
|
||||
<!-- ===================== HANDLERS ===================================== -->
|
||||
|
||||
|
||||
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
|
||||
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
|
||||
<property name="prefix" value="/WEB-INF/jsp/"/>
|
||||
<property name="suffix" value=".jsp"/>
|
||||
</bean>
|
||||
|
||||
<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
|
||||
<property name="defaultErrorView" value="error"/>
|
||||
<property name="exceptionMappings">
|
||||
<props>
|
||||
<prop key="org.springframework.ws.samples.airline.service.NoSuchFlightException">noSuchFlight</prop>
|
||||
</props>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
|
||||
</beans>
|
||||
@@ -1,48 +0,0 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
|
||||
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee https://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
|
||||
version="2.4">
|
||||
<display-name>Spring-WS Airline Sample</display-name>
|
||||
<context-param>
|
||||
<param-name>contextConfigLocation</param-name>
|
||||
<param-value>
|
||||
classpath:org/springframework/ws/samples/airline/dao/jpa/applicationContext-jpa.xml
|
||||
classpath:org/springframework/ws/samples/airline/service/applicationContext.xml
|
||||
classpath:org/springframework/ws/samples/airline/security/applicationContext-security.xml
|
||||
classpath:org/springframework/ws/samples/airline/ws/applicationContext-ws.xml
|
||||
classpath:org/springframework/ws/samples/airline/jms/applicationContext-jms.xml
|
||||
</param-value>
|
||||
</context-param>
|
||||
<listener>
|
||||
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
|
||||
</listener>
|
||||
<servlet>
|
||||
<servlet-name>ws</servlet-name>
|
||||
<servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>ws</servlet-name>
|
||||
<url-pattern>/services</url-pattern>
|
||||
</servlet-mapping>
|
||||
<servlet-mapping>
|
||||
<servlet-name>ws</servlet-name>
|
||||
<url-pattern>*.wsdl</url-pattern>
|
||||
</servlet-mapping>
|
||||
<servlet>
|
||||
<servlet-name>mvc</servlet-name>
|
||||
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>mvc</servlet-name>
|
||||
<url-pattern>*.html</url-pattern>
|
||||
</servlet-mapping>
|
||||
<mime-mapping>
|
||||
<extension>xsd</extension>
|
||||
<mime-type>text/xml</mime-type>
|
||||
</mime-mapping>
|
||||
<welcome-file-list>
|
||||
<welcome-file>index.jsp</welcome-file>
|
||||
</welcome-file-list>
|
||||
</web-app>
|
||||
@@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
|
||||
|
||||
|
||||
<!-- ===================== WSDL DEFINITION ============================== -->
|
||||
|
||||
<bean id="airline" class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition">
|
||||
<description>
|
||||
Builds a WSDL from the airline.xsd.This bean definition represents the airline.wsdl file found
|
||||
in the root of the web application.
|
||||
</description>
|
||||
<property name="schemaCollection" ref="schemaCollection"/>
|
||||
<property name="portTypeName" value="Airline"/>
|
||||
<property name="locationUri" value="http://localhost:8080/airline-server/services"/>
|
||||
<property name="targetNamespace"
|
||||
value="http://www.springframework.org/spring-ws/samples/airline/definitions"/>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@@ -1,3 +0,0 @@
|
||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<c:redirect url="/flights.html"/>
|
||||
@@ -1,124 +0,0 @@
|
||||
/*
|
||||
* Copyright 2005-2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.samples.airline.dao.jpa;
|
||||
|
||||
import java.util.List;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.transaction.BeforeTransaction;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.ws.samples.airline.dao.FlightDao;
|
||||
import org.springframework.ws.samples.airline.domain.Airport;
|
||||
import org.springframework.ws.samples.airline.domain.Flight;
|
||||
import org.springframework.ws.samples.airline.domain.ServiceClass;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Interval;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("applicationContext-jpa.xml")
|
||||
@Transactional
|
||||
public class JpaFlightDaoTest {
|
||||
|
||||
private DateTime departureTime;
|
||||
|
||||
private DateTime arrivalTime;
|
||||
|
||||
private Interval interval;
|
||||
|
||||
private Airport fromAirport;
|
||||
|
||||
private Airport toAirport;
|
||||
|
||||
@Autowired
|
||||
private FlightDao flightDao;
|
||||
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Autowired
|
||||
public void setDataSource(DataSource dataSource) {
|
||||
jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
@BeforeTransaction
|
||||
public void createTestData() {
|
||||
departureTime = new DateTime(2006, 1, 31, 10, 5, 0, 0);
|
||||
arrivalTime = new DateTime(2006, 1, 31, 12, 25, 0, 0);
|
||||
interval = departureTime.toLocalDate().toInterval();
|
||||
fromAirport = new Airport("RTM", "Rotterdam Airport", "Rotterdam");
|
||||
toAirport = new Airport("OSL", "Gardermoen", "Oslo");
|
||||
}
|
||||
|
||||
@Before
|
||||
public void insertTestData() {
|
||||
jdbcTemplate.update("INSERT INTO AIRPORT(CODE, NAME, CITY) VALUES('RTM', 'Rotterdam Airport', 'Rotterdam')");
|
||||
jdbcTemplate.update("INSERT INTO AIRPORT(CODE, NAME, CITY) VALUES('OSL', 'Gardermoen', 'Oslo')");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getFlightsInPeriod() throws Exception {
|
||||
jdbcTemplate
|
||||
.update("INSERT INTO FLIGHT(NUMBER, DEPARTURE_TIME, FROM_AIRPORT_CODE, ARRIVAL_TIME, TO_AIRPORT_CODE, SERVICE_CLASS, SEATS_AVAILABLE, MILES) " +
|
||||
"VALUES ('KL020','2006-01-31 10:05:00', 'RTM', '2006-01-31 12:25:00', 'OSL', 'BUSINESS', 90, 10)");
|
||||
List<Flight> flights = flightDao.findFlights("RTM", "OSL", interval, ServiceClass.BUSINESS);
|
||||
assertNotNull("Invalid result", flights);
|
||||
assertEquals("Invalid amount of flights", 1, flights.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getFlightsOutOfPeriod() throws Exception {
|
||||
jdbcTemplate
|
||||
.update("INSERT INTO FLIGHT(NUMBER, DEPARTURE_TIME, FROM_AIRPORT_CODE, ARRIVAL_TIME, TO_AIRPORT_CODE, SERVICE_CLASS, SEATS_AVAILABLE, MILES) " +
|
||||
"VALUES ('KL020','2006-01-31 10:05:00', 'RTM', '2006-01-31 12:25:00', 'OSL', 'BUSINESS', 90, 10)");
|
||||
DateTime dateTime = new DateTime(2006, 6, 1, 0, 0, 0, 0);
|
||||
List flights = flightDao.findFlights("RTM", "OSL", new Interval(dateTime, dateTime), ServiceClass.BUSINESS);
|
||||
assertNotNull("Invalid result", flights);
|
||||
assertEquals("Invalid amount of flights", 0, flights.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getFlightByNumberDepartureTime() throws Exception {
|
||||
jdbcTemplate
|
||||
.update("INSERT INTO FLIGHT(NUMBER, DEPARTURE_TIME, FROM_AIRPORT_CODE, ARRIVAL_TIME, TO_AIRPORT_CODE, SERVICE_CLASS, SEATS_AVAILABLE, MILES) " +
|
||||
"VALUES ('KL020','2006-01-31 10:05:00', 'RTM', '2006-01-31 12:25:00', 'OSL', 'BUSINESS', 90, 10)");
|
||||
Flight flight = flightDao.getFlight("KL020", departureTime);
|
||||
assertNotNull("No flight returned", flight);
|
||||
assertNotNull("Invalid flight id", flight.getId());
|
||||
assertEquals("Invalid flight number", "KL020", flight.getNumber());
|
||||
assertEquals("Invalid flight departure time", departureTime, flight.getDepartureTime());
|
||||
assertEquals("Invalid flight arrival time", arrivalTime, flight.getArrivalTime());
|
||||
assertEquals("Invalid flight from airport", fromAirport, flight.getFrom());
|
||||
assertEquals("Invalid flight to airport", toAirport, flight.getTo());
|
||||
assertEquals("Invalid flight service class", ServiceClass.BUSINESS, flight.getServiceClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noSuchFlight() {
|
||||
Flight flight = flightDao.getFlight("INVALID", departureTime);
|
||||
assertNull("Flight returned", flight);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* Copyright 2005-2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.samples.airline.dao.jpa;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.ws.samples.airline.domain.FrequentFlyer;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("applicationContext-jpa.xml")
|
||||
@Transactional
|
||||
public class JpaFrequentFlyerDaoTest {
|
||||
|
||||
@Autowired
|
||||
private JpaFrequentFlyerDao frequentFlyerDao;
|
||||
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Autowired
|
||||
public void setDataSource(DataSource dataSource) {
|
||||
jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void insertTestData() {
|
||||
jdbcTemplate
|
||||
.update("INSERT INTO PASSENGER(ID, FIRST_NAME, LAST_NAME) " + "VALUES (42, 'Arjen', 'Poutsma')");
|
||||
jdbcTemplate
|
||||
.update("INSERT INTO FREQUENT_FLYER(PASSENGER_ID, USERNAME, PASSWORD, MILES) " +
|
||||
"VALUES (42, 'arjen', 'changeme', 0)");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getByUsername() throws Exception {
|
||||
FrequentFlyer flyer = frequentFlyerDao.get("arjen");
|
||||
assertNotNull("No frequent flyer returned", flyer);
|
||||
assertEquals("Invalid username", "arjen", flyer.getUsername());
|
||||
assertEquals("Invalid password", "changeme", flyer.getPassword());
|
||||
assertEquals("Invalid first name", "Arjen", flyer.getFirstName());
|
||||
assertEquals("Invalid last name", "Poutsma", flyer.getLastName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noSuchUsername() {
|
||||
FrequentFlyer flyer = frequentFlyerDao.get("invalid");
|
||||
assertNull("FrequentFlyer returned", flyer);
|
||||
}
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
/*
|
||||
* Copyright 2005-2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.samples.airline.dao.jpa;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.ws.samples.airline.domain.Flight;
|
||||
import org.springframework.ws.samples.airline.domain.Passenger;
|
||||
import org.springframework.ws.samples.airline.domain.Ticket;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("applicationContext-jpa.xml")
|
||||
@Transactional
|
||||
public class JpaTicketDaoTest {
|
||||
|
||||
@Autowired
|
||||
private JpaTicketDao ticketDao;
|
||||
|
||||
@Autowired
|
||||
private JpaFlightDao flightDao;
|
||||
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Autowired
|
||||
public void setDataSource(DataSource dataSource) {
|
||||
jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void insertTestData() {
|
||||
jdbcTemplate.update("INSERT INTO AIRPORT(CODE, NAME, CITY) VALUES('RTM', 'Rotterdam Airport', 'Rotterdam')");
|
||||
jdbcTemplate.update("INSERT INTO AIRPORT(CODE, NAME, CITY) VALUES('OSL', 'Gardermoen', 'Oslo')");
|
||||
jdbcTemplate
|
||||
.update("INSERT INTO FLIGHT(ID, NUMBER, DEPARTURE_TIME, FROM_AIRPORT_CODE, ARRIVAL_TIME, TO_AIRPORT_CODE, SERVICE_CLASS, SEATS_AVAILABLE, MILES) " +
|
||||
"VALUES (42, 'KL020','2006-01-31 10:05:00', 'RTM', '2006-01-31 12:25:00', 'OSL', 'BUSINESS', 90, 10)");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void save() throws Exception {
|
||||
Passenger passenger = new Passenger("Arjen", "Poutsma");
|
||||
Flight flight = flightDao.getFlight(42L);
|
||||
Ticket ticket = new Ticket();
|
||||
ticket.addPassenger(passenger);
|
||||
ticket.setFlight(flight);
|
||||
ticket.setIssueDate(new LocalDate());
|
||||
int startTicketCount = jdbcTemplate.queryForInt("SELECT COUNT(0) FROM TICKET");
|
||||
int startPassengerCount = jdbcTemplate.queryForInt("SELECT COUNT(0) FROM PASSENGER");
|
||||
ticketDao.save(ticket);
|
||||
assertNotNull("No Id generated", ticket.getId());
|
||||
int endTicketCount = jdbcTemplate.queryForInt("SELECT COUNT(0) FROM TICKET");
|
||||
int endPassengerCount = jdbcTemplate.queryForInt("SELECT COUNT(0) FROM PASSENGER");
|
||||
assertEquals("Flight not inserted", 1, endTicketCount - startTicketCount);
|
||||
assertEquals("Passenger not inserted", 1, endPassengerCount - startPassengerCount);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Copyright 2005-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.samples.airline.security;
|
||||
|
||||
import org.springframework.security.authentication.TestingAuthenticationToken;
|
||||
import org.springframework.security.core.context.SecurityContext;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.core.context.SecurityContextImpl;
|
||||
import org.springframework.ws.samples.airline.dao.FrequentFlyerDao;
|
||||
import org.springframework.ws.samples.airline.domain.FrequentFlyer;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import static org.easymock.EasyMock.*;
|
||||
|
||||
public class SpringFrequentFlyerSecurityServiceTest extends TestCase {
|
||||
|
||||
private SpringFrequentFlyerSecurityService securityService;
|
||||
|
||||
private FrequentFlyerDao flyerDaoMock;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
flyerDaoMock = createMock(FrequentFlyerDao.class);
|
||||
securityService = new SpringFrequentFlyerSecurityService(flyerDaoMock);
|
||||
}
|
||||
|
||||
public void testGetCurrentlyAuthenticatedFrequentFlyer() throws Exception {
|
||||
FrequentFlyer frequentFlyer = new FrequentFlyer("john");
|
||||
FrequentFlyerDetails detail = new FrequentFlyerDetails(frequentFlyer);
|
||||
TestingAuthenticationToken token = new TestingAuthenticationToken(detail, null);
|
||||
SecurityContext context = new SecurityContextImpl();
|
||||
context.setAuthentication(token);
|
||||
SecurityContextHolder.setContext(context);
|
||||
replay(flyerDaoMock);
|
||||
FrequentFlyer result = securityService.getCurrentlyAuthenticatedFrequentFlyer();
|
||||
assertEquals("Invalid result", frequentFlyer, result);
|
||||
verify(flyerDaoMock);
|
||||
}
|
||||
|
||||
public void testGetFrequentFlyer() throws Exception {
|
||||
FrequentFlyer frequentFlyer = new FrequentFlyer("john");
|
||||
expect(flyerDaoMock.get("john")).andReturn(frequentFlyer);
|
||||
replay(flyerDaoMock);
|
||||
FrequentFlyer result = securityService.getFrequentFlyer("john");
|
||||
assertEquals("Invalid result", frequentFlyer, result);
|
||||
verify(flyerDaoMock);
|
||||
}
|
||||
}
|
||||
@@ -1,184 +0,0 @@
|
||||
/*
|
||||
* Copyright 2005-2010 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.samples.airline.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import static org.easymock.EasyMock.*;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.springframework.ws.samples.airline.dao.FlightDao;
|
||||
import org.springframework.ws.samples.airline.dao.TicketDao;
|
||||
import org.springframework.ws.samples.airline.domain.Flight;
|
||||
import org.springframework.ws.samples.airline.domain.FrequentFlyer;
|
||||
import org.springframework.ws.samples.airline.domain.Passenger;
|
||||
import org.springframework.ws.samples.airline.domain.ServiceClass;
|
||||
import org.springframework.ws.samples.airline.domain.Ticket;
|
||||
import org.springframework.ws.samples.airline.security.FrequentFlyerSecurityService;
|
||||
import org.springframework.ws.samples.airline.service.NoSeatAvailableException;
|
||||
import org.springframework.ws.samples.airline.service.NoSuchFlightException;
|
||||
|
||||
public class AirlineServiceImplTest extends TestCase {
|
||||
|
||||
private AirlineServiceImpl airlineService;
|
||||
|
||||
private FlightDao flightDaoMock;
|
||||
|
||||
private TicketDao ticketDaoMock;
|
||||
|
||||
private FrequentFlyerSecurityService securityServiceMock;
|
||||
|
||||
private String flightNumber;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
flightDaoMock = createMock(FlightDao.class);
|
||||
ticketDaoMock = createMock(TicketDao.class);
|
||||
airlineService = new AirlineServiceImpl(flightDaoMock, ticketDaoMock);
|
||||
securityServiceMock = createMock(FrequentFlyerSecurityService.class);
|
||||
airlineService.setFrequentFlyerSecurityService(securityServiceMock);
|
||||
flightNumber = "AB1234";
|
||||
}
|
||||
|
||||
public void testBookFlight() throws Exception {
|
||||
DateTime departureTime = new DateTime();
|
||||
Passenger passenger = new Passenger("John", "Doe");
|
||||
List<Passenger> passengers = new ArrayList<Passenger>();
|
||||
passengers.add(passenger);
|
||||
Flight flight = new Flight();
|
||||
flight.setNumber(flightNumber);
|
||||
flight.setSeatsAvailable(10);
|
||||
expect(flightDaoMock.getFlight(flightNumber, departureTime)).andReturn(flight);
|
||||
expect(flightDaoMock.update(flight)).andReturn(flight);
|
||||
Ticket ticket = new Ticket();
|
||||
ticket.setFlight(flight);
|
||||
ticketDaoMock.save(isA(Ticket.class));
|
||||
|
||||
replay(flightDaoMock, ticketDaoMock, securityServiceMock);
|
||||
|
||||
ticket = airlineService.bookFlight(flightNumber, departureTime, passengers);
|
||||
assertNotNull("Invalid ticket", ticket);
|
||||
assertEquals("Invalid flight", flight, ticket.getFlight());
|
||||
assertEquals("Invalid seats available", 9, flight.getSeatsAvailable());
|
||||
assertEquals("Invalid passengers count", 1, ticket.getPassengers().size());
|
||||
|
||||
verify(flightDaoMock, ticketDaoMock, securityServiceMock);
|
||||
}
|
||||
|
||||
public void testBookFlightFrequentFlyer() throws Exception {
|
||||
DateTime departureTime = new DateTime();
|
||||
FrequentFlyer frequentFlyer = new FrequentFlyer("John", "Doe", "john", "changeme");
|
||||
List<Passenger> passengers = new ArrayList<Passenger>();
|
||||
passengers.add(frequentFlyer);
|
||||
Flight flight = new Flight();
|
||||
flight.setNumber(flightNumber);
|
||||
flight.setSeatsAvailable(1);
|
||||
flight.setMiles(10);
|
||||
expect(securityServiceMock.getFrequentFlyer("john")).andReturn(frequentFlyer);
|
||||
expect(flightDaoMock.getFlight(flightNumber, departureTime)).andReturn(flight);
|
||||
expect(flightDaoMock.update(flight)).andReturn(flight);
|
||||
ticketDaoMock.save(isA(Ticket.class));
|
||||
|
||||
replay(flightDaoMock, ticketDaoMock, securityServiceMock);
|
||||
|
||||
Ticket ticket = airlineService.bookFlight(flightNumber, departureTime, passengers);
|
||||
assertNotNull("Invalid ticket", ticket);
|
||||
assertEquals("Invalid flight", flight, ticket.getFlight());
|
||||
assertEquals("Invalid amount of miles", 10, frequentFlyer.getMiles());
|
||||
|
||||
verify(flightDaoMock, ticketDaoMock, securityServiceMock);
|
||||
}
|
||||
|
||||
public void testBookFlightNoSeatAvailable() throws Exception {
|
||||
DateTime departureTime = new DateTime();
|
||||
List<Passenger> passengers = Collections.singletonList(new Passenger());
|
||||
Flight flight = new Flight();
|
||||
flight.setNumber("AB1234");
|
||||
flight.setDepartureTime(new DateTime());
|
||||
expect(flightDaoMock.getFlight(flightNumber, departureTime)).andReturn(flight);
|
||||
|
||||
replay(flightDaoMock, ticketDaoMock, securityServiceMock);
|
||||
|
||||
try {
|
||||
airlineService.bookFlight(flightNumber, departureTime, passengers);
|
||||
fail("Should have thrown an NoSeatAvailableException");
|
||||
}
|
||||
catch (NoSeatAvailableException ex) {
|
||||
}
|
||||
|
||||
verify(flightDaoMock, ticketDaoMock, securityServiceMock);
|
||||
}
|
||||
|
||||
public void testBookFlightNoSuchFlight() throws Exception {
|
||||
String flightNumber = "AB1234";
|
||||
DateTime departureTime = new DateTime();
|
||||
List<Passenger> passengers = Collections.singletonList(new Passenger());
|
||||
expect(flightDaoMock.getFlight(flightNumber, departureTime)).andReturn(null);
|
||||
|
||||
replay(flightDaoMock, ticketDaoMock, securityServiceMock);
|
||||
try {
|
||||
airlineService.bookFlight(flightNumber, departureTime, passengers);
|
||||
fail("Should have thrown an NoSuchFlightException");
|
||||
}
|
||||
catch (NoSuchFlightException ex) {
|
||||
}
|
||||
|
||||
verify(flightDaoMock, ticketDaoMock, securityServiceMock);
|
||||
}
|
||||
|
||||
public void testGetFlights() throws Exception {
|
||||
LocalDate departureDate = new LocalDate(2006, 1, 31);
|
||||
Flight flight = new Flight();
|
||||
List<Flight> flights = new ArrayList<Flight>();
|
||||
flights.add(flight);
|
||||
String toCode = "to";
|
||||
String fromCode = "from";
|
||||
|
||||
expect(flightDaoMock.findFlights(fromCode, toCode, departureDate.toInterval(), ServiceClass.ECONOMY))
|
||||
.andReturn(flights);
|
||||
|
||||
replay(flightDaoMock, ticketDaoMock, securityServiceMock);
|
||||
|
||||
List<Flight> result = airlineService.getFlights(fromCode, toCode, departureDate, ServiceClass.ECONOMY);
|
||||
assertEquals("Invalid result", flights, result);
|
||||
|
||||
verify(flightDaoMock, ticketDaoMock, securityServiceMock);
|
||||
}
|
||||
|
||||
public void testGetFlightsDefaultServiceClass() throws Exception {
|
||||
LocalDate departureDate = new LocalDate(2006, 1, 31);
|
||||
Flight flight = new Flight();
|
||||
List<Flight> flights = new ArrayList<Flight>();
|
||||
flights.add(flight);
|
||||
String toCode = "to";
|
||||
String fromCode = "from";
|
||||
|
||||
expect(flightDaoMock.findFlights(fromCode, toCode, departureDate.toInterval(), ServiceClass.ECONOMY))
|
||||
.andReturn(flights);
|
||||
|
||||
replay(flightDaoMock, ticketDaoMock, securityServiceMock);
|
||||
|
||||
List<Flight> result = airlineService.getFlights(fromCode, toCode, departureDate, null);
|
||||
assertEquals("Invalid result", flights, result);
|
||||
|
||||
verify(flightDaoMock, ticketDaoMock, securityServiceMock);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Copyright 2005-2010 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.samples.airline.web;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import static org.easymock.EasyMock.*;
|
||||
import org.joda.time.LocalDate;
|
||||
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.ws.samples.airline.domain.Flight;
|
||||
import org.springframework.ws.samples.airline.domain.ServiceClass;
|
||||
import org.springframework.ws.samples.airline.service.AirlineService;
|
||||
|
||||
public class FlightsControllerTest extends TestCase {
|
||||
|
||||
private FlightsController flightsController;
|
||||
|
||||
private AirlineService airlineServiceMock;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
airlineServiceMock = createMock(AirlineService.class);
|
||||
flightsController = new FlightsController(airlineServiceMock);
|
||||
}
|
||||
|
||||
public void testFlightList() throws Exception {
|
||||
String from = "AMS";
|
||||
String to = "VCE";
|
||||
LocalDate departureDate = new LocalDate();
|
||||
ServiceClass serviceClass = ServiceClass.FIRST;
|
||||
List<Flight> flights = new ArrayList<Flight>();
|
||||
flights.add(new Flight());
|
||||
expect(airlineServiceMock.getFlights(from, to, departureDate, serviceClass)).andReturn(flights);
|
||||
|
||||
replay(airlineServiceMock);
|
||||
|
||||
ModelMap model = new ModelMap();
|
||||
String view = flightsController
|
||||
.flightList(from, to, departureDate.toString(), serviceClass.toString(), model);
|
||||
assertNotNull("No view returned", view);
|
||||
assertEquals("Invalid view name", "flights", view);
|
||||
assertTrue("No flights in ModelAndView", model.containsAttribute("flights"));
|
||||
verify(airlineServiceMock);
|
||||
}
|
||||
}
|
||||
@@ -1,207 +0,0 @@
|
||||
/*
|
||||
* Copyright 2005-2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.samples.airline.ws;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import javax.xml.datatype.DatatypeConstants;
|
||||
import javax.xml.datatype.DatatypeFactory;
|
||||
|
||||
import org.springframework.ws.samples.airline.domain.Airport;
|
||||
import org.springframework.ws.samples.airline.domain.FrequentFlyer;
|
||||
import org.springframework.ws.samples.airline.domain.Passenger;
|
||||
import org.springframework.ws.samples.airline.schema.BookFlightRequest;
|
||||
import org.springframework.ws.samples.airline.schema.Flight;
|
||||
import org.springframework.ws.samples.airline.schema.GetFlightsResponse;
|
||||
import org.springframework.ws.samples.airline.schema.Name;
|
||||
import org.springframework.ws.samples.airline.schema.ObjectFactory;
|
||||
import org.springframework.ws.samples.airline.schema.ServiceClass;
|
||||
import org.springframework.ws.samples.airline.schema.Ticket;
|
||||
import org.springframework.ws.samples.airline.service.AirlineService;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.DateTimeZone;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import static org.easymock.EasyMock.*;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
public class AirlineEndpointTest {
|
||||
|
||||
private AirlineEndpoint endpoint;
|
||||
|
||||
private AirlineService airlineServiceMock;
|
||||
|
||||
private DatatypeFactory datatypeFactory;
|
||||
|
||||
private ObjectFactory objectFactory;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
airlineServiceMock = createMock(AirlineService.class);
|
||||
endpoint = new AirlineEndpoint(airlineServiceMock);
|
||||
datatypeFactory = DatatypeFactory.newInstance();
|
||||
objectFactory = new ObjectFactory();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetFlights() throws Exception {
|
||||
org.springframework.ws.samples.airline.domain.Flight domainFlight = createDomainFlight();
|
||||
|
||||
expect(airlineServiceMock.getFlights("ABC", "DEF", new LocalDate(2007, 6, 13),
|
||||
org.springframework.ws.samples.airline.domain.ServiceClass.FIRST))
|
||||
.andReturn(Collections.singletonList(domainFlight));
|
||||
|
||||
replay(airlineServiceMock);
|
||||
|
||||
GetFlightsResponse response = endpoint.getFlights("ABC", "DEF", "2007-06-13", "first");
|
||||
Assert.assertEquals("Invalid amount of flights received", 1, response.getFlight().size());
|
||||
Flight schemaFlight = response.getFlight().get(0);
|
||||
verifySchemaFlight(schemaFlight);
|
||||
|
||||
verify(airlineServiceMock);
|
||||
}
|
||||
|
||||
private void verifySchemaFlight(Flight schemaFlight) {
|
||||
Assert.assertEquals("Invalid number", "ABC1234", schemaFlight.getNumber());
|
||||
Assert.assertEquals("Invalid departure time",
|
||||
datatypeFactory.newXMLGregorianCalendar(2007, 6, 13, 12, 0, 0, 0, 0), schemaFlight.getDepartureTime());
|
||||
Assert.assertEquals("Invalid from code", "ABC", schemaFlight.getFrom().getCode());
|
||||
Assert.assertEquals("Invalid from name", "ABC Airport", schemaFlight.getFrom().getName());
|
||||
Assert.assertEquals("Invalid from city", "ABC City", schemaFlight.getFrom().getCity());
|
||||
Assert.assertEquals("Invalid arrival time",
|
||||
datatypeFactory.newXMLGregorianCalendar(2007, 6, 13, 14, 0, 0, 0, 0), schemaFlight.getArrivalTime());
|
||||
Assert.assertEquals("Invalid to code", "DEF", schemaFlight.getTo().getCode());
|
||||
Assert.assertEquals("Invalid to name", "DEF Airport", schemaFlight.getTo().getName());
|
||||
Assert.assertEquals("Invalid to city", "DEF City", schemaFlight.getTo().getCity());
|
||||
Assert.assertEquals("Invalid service class", ServiceClass.FIRST, schemaFlight.getServiceClass());
|
||||
}
|
||||
|
||||
private org.springframework.ws.samples.airline.domain.Flight createDomainFlight() {
|
||||
org.springframework.ws.samples.airline.domain.Flight domainFlight =
|
||||
new org.springframework.ws.samples.airline.domain.Flight();
|
||||
domainFlight.setNumber("ABC1234");
|
||||
domainFlight.setDepartureTime(new DateTime(2007, 6, 13, 12, 0, 0, 0, DateTimeZone.UTC));
|
||||
domainFlight.setFrom(new Airport("ABC", "ABC Airport", "ABC City"));
|
||||
domainFlight.setArrivalTime(new DateTime(2007, 6, 13, 14, 0, 0, 0, DateTimeZone.UTC));
|
||||
domainFlight.setTo(new Airport("DEF", "DEF Airport", "DEF City"));
|
||||
domainFlight.setServiceClass(org.springframework.ws.samples.airline.domain.ServiceClass.FIRST);
|
||||
return domainFlight;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bookFlightPassenger() throws Exception {
|
||||
BookFlightRequest request = objectFactory.createBookFlightRequest();
|
||||
request.setDepartureTime(datatypeFactory.newXMLGregorianCalendar(2007, 6, 13, 12, 0, 0, 0, 0));
|
||||
request.setFlightNumber("ABC1234");
|
||||
Name passengerName = new Name();
|
||||
passengerName.setFirst("John");
|
||||
passengerName.setLast("Doe");
|
||||
BookFlightRequest.Passengers passengers = new BookFlightRequest.Passengers();
|
||||
passengers.getPassengerOrUsername().add(passengerName);
|
||||
request.setPassengers(passengers);
|
||||
|
||||
Passenger domainPassenger = new Passenger("John", "Doe");
|
||||
|
||||
org.springframework.ws.samples.airline.domain.Ticket domainTicket =
|
||||
new org.springframework.ws.samples.airline.domain.Ticket(42L);
|
||||
domainTicket.setFlight(createDomainFlight());
|
||||
domainTicket.setIssueDate(new LocalDate(2007, 6, 13));
|
||||
domainTicket.setPassengers(Collections.singleton(domainPassenger));
|
||||
|
||||
expect(airlineServiceMock.bookFlight("ABC1234", new DateTime(2007, 6, 13, 12, 0, 0, 0, DateTimeZone.UTC),
|
||||
Collections.singletonList(domainPassenger))).andReturn(domainTicket);
|
||||
|
||||
replay(airlineServiceMock);
|
||||
|
||||
JAXBElement<Ticket> response = endpoint.bookFlight(request);
|
||||
Ticket schemaTicket = response.getValue();
|
||||
Assert.assertEquals("Invalid id", 42L, schemaTicket.getId());
|
||||
Assert.assertEquals("Invalid issue date",
|
||||
datatypeFactory.newXMLGregorianCalendarDate(2007, 6, 13, DatatypeConstants.FIELD_UNDEFINED),
|
||||
schemaTicket.getIssueDate());
|
||||
Assert.assertEquals("Invalid amount of passengers", 1, schemaTicket.getPassengers().getPassenger().size());
|
||||
Name schemaPassenger = schemaTicket.getPassengers().getPassenger().get(0);
|
||||
Assert.assertEquals("Invalid passenger first name", "John", schemaPassenger.getFirst());
|
||||
Assert.assertEquals("Invalid passenger first name", "Doe", schemaPassenger.getLast());
|
||||
verifySchemaFlight(schemaTicket.getFlight());
|
||||
|
||||
verify(airlineServiceMock);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBookFlightFrequentFlyer() throws Exception {
|
||||
BookFlightRequest request = objectFactory.createBookFlightRequest();
|
||||
request.setDepartureTime(datatypeFactory.newXMLGregorianCalendar(2007, 6, 13, 12, 0, 0, 0, 0));
|
||||
request.setFlightNumber("ABC1234");
|
||||
BookFlightRequest.Passengers passengers = new BookFlightRequest.Passengers();
|
||||
passengers.getPassengerOrUsername().add("john");
|
||||
request.setPassengers(passengers);
|
||||
|
||||
FrequentFlyer domainFrequentFlyer = new FrequentFlyer("John", "Doe", "john", "changeme");
|
||||
Set<Passenger> domainPassengers = new HashSet<Passenger>();
|
||||
domainPassengers.add(domainFrequentFlyer);
|
||||
|
||||
org.springframework.ws.samples.airline.domain.Ticket domainTicket =
|
||||
new org.springframework.ws.samples.airline.domain.Ticket(42L);
|
||||
domainTicket.setFlight(createDomainFlight());
|
||||
domainTicket.setIssueDate(new LocalDate(2007, 6, 13));
|
||||
domainTicket.setPassengers(domainPassengers);
|
||||
|
||||
List<Passenger> domainPassengerList = new ArrayList<Passenger>(domainPassengers);
|
||||
expect(airlineServiceMock
|
||||
.bookFlight("ABC1234", new DateTime(2007, 6, 13, 12, 0, 0, 0, DateTimeZone.UTC), domainPassengerList))
|
||||
.andReturn(domainTicket);
|
||||
|
||||
replay(airlineServiceMock);
|
||||
|
||||
JAXBElement<Ticket> response = endpoint.bookFlight(request);
|
||||
Ticket schemaTicket = response.getValue();
|
||||
Assert.assertEquals("Invalid id", 42L, schemaTicket.getId());
|
||||
Assert.assertEquals("Invalid issue date",
|
||||
datatypeFactory.newXMLGregorianCalendarDate(2007, 6, 13, DatatypeConstants.FIELD_UNDEFINED),
|
||||
schemaTicket.getIssueDate());
|
||||
Assert.assertEquals("Invalid amount of passengers", 1, schemaTicket.getPassengers().getPassenger().size());
|
||||
Name schemaPassenger = schemaTicket.getPassengers().getPassenger().get(0);
|
||||
Assert.assertEquals("Invalid passenger first name", "John", schemaPassenger.getFirst());
|
||||
Assert.assertEquals("Invalid passenger first name", "Doe", schemaPassenger.getLast());
|
||||
verifySchemaFlight(schemaTicket.getFlight());
|
||||
|
||||
verify(airlineServiceMock);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetFrequentFlyerMileage() throws Exception {
|
||||
expect(airlineServiceMock.getFrequentFlyerMileage()).andReturn(42);
|
||||
|
||||
replay(airlineServiceMock);
|
||||
|
||||
Element response = endpoint.getFrequentFlyerMileage();
|
||||
assertNotNull("Invalid response", response);
|
||||
|
||||
verify(airlineServiceMock);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
|
||||
include "server", "client:axis1", "client:jax-ws", "client:jms", "client:saaj", "client:spring-ws"
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user