commit 680eab32eda0d6cd9c44fab96e43f95962733579 Author: Victor Bellavin Date: Sun Mar 1 22:17:02 2015 +0300 initial diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..0b22297 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.bat text eol=crlf \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2eda6cf --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +.gradle +build +logs +gen +.idea/libraries/Gradle__*.xml +.idea/workspace.xml +.idea/misc.xml +ncore-properties-local.xml +*.iml \ No newline at end of file diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..eed7e79 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +sample \ No newline at end of file diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml new file mode 100644 index 0000000..ca5c3e5 --- /dev/null +++ b/.idea/codeStyleSettings.xml @@ -0,0 +1,62 @@ + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..9a8b7e5 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,22 @@ + + + + + \ No newline at end of file diff --git a/.idea/copyright/RedSoft.xml b/.idea/copyright/RedSoft.xml new file mode 100644 index 0000000..6b6903f --- /dev/null +++ b/.idea/copyright/RedSoft.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..b46759e --- /dev/null +++ b/.idea/copyright/profiles_settings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..bec327e --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/findbugs-idea.xml b/.idea/findbugs-idea.xml new file mode 100644 index 0000000..f1310af --- /dev/null +++ b/.idea/findbugs-idea.xml @@ -0,0 +1,220 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..ba1ec5c --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..ce01c72 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/scopes/scope_settings.xml b/.idea/scopes/scope_settings.xml new file mode 100644 index 0000000..922003b --- /dev/null +++ b/.idea/scopes/scope_settings.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.java-version b/.java-version new file mode 100644 index 0000000..5c9ad5f --- /dev/null +++ b/.java-version @@ -0,0 +1 @@ +1.6.0.45 diff --git a/README.md b/README.md new file mode 100644 index 0000000..7759f4e --- /dev/null +++ b/README.md @@ -0,0 +1,42 @@ +Пример проекта на платформе ncore +==================== + +Здесь представлена стандартная структура проекта с основными конфигурационными +файлами и классами, а также настройки IDE (Intellij Idea) и настройки SCM (git). + + + +Для данного проекта можно использовать базу ядра. + +Таски запускаются с помощью gradle wrapper. Версия Gradle - 2.2.1. + +Nix +```bash +./gradlew build + +``` +Win +``` +gradlew.bat build + +``` + +__Основные таски__ + +* ncoreLoadPatches - загрузка патчей +* ncoreApplyPatches - применение патчей +* ncoreUpdateDb - загрузка и применение патчей +* generateSources - генерация исходников +* classes - компиляция +* build - компиляция, выполнение проверок (тесты) +* distZip - генерация zip-архива дистрибутива толстого клиента (build/distributions) +* war - генерация war-архива тонкого клиента (build/libs) +* release - выпуск сборки + + +Если нужно выполнить компиляцию классов, но при этом не запускать генерацию кода, можно воспользоваться ключом -x. +```bash +./gradlew classes -x generateSources +``` + +Названия тасков можно сокращать. Например, вместо generateSources можно указать gS, вместо ncoreLoadPatches nLP и т.д. \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..72cc44d --- /dev/null +++ b/build.gradle @@ -0,0 +1,76 @@ +buildscript { + repositories { + maven { url 'http://nexus.red-soft.biz/nexus/content/groups/public' } + } + dependencies { + classpath 'biz.redsoft.gradle.ncore:gradle-ncore:+' + } +} + +group = 'biz.redsoft.sample' + +apply plugin: 'application' +apply plugin: 'war' +apply plugin: 'ncore' +apply plugin: 'maven-publish' + + +targetCompatibility = 1.6 + +ncore { + coreVersion = '1.2.18.1' + coreJarsigned = true + sourceEncoding = 'UTF-8' +} + +dependencies { + provided 'javax.servlet:javax.servlet-api:3.0.1' + + testCompile 'junit:junit:4.+' +} + + +publishing { + repositories { + project.hasProperty('biz.redsoft.repo.user') && project.hasProperty('biz.redsoft.repo.password') && maven { + credentials { + username project.'biz.redsoft.repo.user' + password project.'biz.redsoft.repo.password' + } + def suffix = project.version.toString().endsWith('SNAPSHOT') ? 'snapshots' : 'releases' + url "http://nexus.red-soft.biz/nexus/content/repositories/${suffix}" + } + } + publications { + mavenJava(MavenPublication) { + from components.java + + artifact sourceJar + artifact updatesJar + } + mavenJavaGen(MavenPublication) { + artifactId "${genJar.baseName}-${genJar.appendix}" + artifact genJar + artifact genSourceJar + } + } +} + +task copyDist(type: Copy) { + from distZip + from war + def releaseDir + if (project.hasProperty('biz.redsoft.release.dir') && project.getProperty('biz.redsoft.release.dir')) + releaseDir = "${project.getProperty('biz.redsoft.release.dir')}" + else + releaseDir = "$projectDir/../releases" + into "$releaseDir/$project.name/$version" +} + +release { + tagPrefix = 'v' +} + +task buildRelease(type: GradleBuild) { + tasks = ['clean', 'writeVersion', 'nbackup', 'build', 'copyDist', 'publish'] +} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..c97a8bd Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..39b3f0c --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Sun Mar 01 21:29:45 MSK 2015 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..91a7e26 --- /dev/null +++ b/gradlew @@ -0,0 +1,164 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# For Cygwin, ensure paths are in UNIX format before anything is touched. +if $cygwin ; then + [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` +fi + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +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 +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >&- +APP_HOME="`pwd -P`" +cd "$SAVED" >&- + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +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 + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..8a0b282 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/log4j.properties b/log4j.properties new file mode 100644 index 0000000..b6a4444 --- /dev/null +++ b/log4j.properties @@ -0,0 +1,26 @@ +log4j.rootLogger=DEBUG, file, stdout +log4j.logger.biz.redsoft.ncore.docflow.Log4jDocFlowLogger=INFO, biz.redsoft.ncore.docflow.Log4jDocFlowLogger + +log4j.appender.biz.redsoft.ncore.docflow.Log4jDocFlowLogger=org.apache.log4j.FileAppender +log4j.appender.biz.redsoft.ncore.docflow.Log4jDocFlowLogger.layout=org.apache.log4j.PatternLayout +log4j.appender.biz.redsoft.ncore.docflow.Log4jDocFlowLogger.layout.ConversionPattern=%d{dd.MM.yy HH:mm:ss.SSS},%t,%p,%c{1},%m%n +#log4j.appender.biz.redsoft.ncore.docflow.Log4jDocFlowLogger.encoding=UTF-8 +log4j.appender.biz.redsoft.ncore.docflow.Log4jDocFlowLogger.File=logs/docflow.log + +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{dd.MM.yy HH:mm:ss.SSS},%t,%p,%c{1},%m%n +#log4j.appender.stdout.encoding=UTF-8 + +log4j.appender.stdout.Threshold=DEBUG + +log4j.appender.file=org.apache.log4j.FileAppender +log4j.appender.file.layout=org.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern=%d{dd.MM.yy HH:mm:ss.SSS},%t,%p,%c{1},%m%n +log4j.appender.file.encoding=UTF-8 +log4j.appender.file.Threshold=INFO + + +log4j.appender.file.File=logs/stat.log +log4j.appender.file.Append=true + \ No newline at end of file diff --git a/ncore-properties-template.xml b/ncore-properties-template.xml new file mode 100644 index 0000000..b5743ca --- /dev/null +++ b/ncore-properties-template.xml @@ -0,0 +1,5 @@ + + + + true + diff --git a/ncore-properties.xml b/ncore-properties.xml new file mode 100644 index 0000000..347333f --- /dev/null +++ b/ncore-properties.xml @@ -0,0 +1,16 @@ + + + + Configuration settings for ncore platform + + + sample + Sample ncore project + + + org.firebirdsql.jdbc.FBDriver + jdbc:firebirdsql:localhost:ncore-sample-dev?lc_ctype=WIN1251 + SYSDBA + masterkey + + \ No newline at end of file diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..e3718fc --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'sample' \ No newline at end of file diff --git a/src/dist/bin/start-client b/src/dist/bin/start-client new file mode 100755 index 0000000..8204d9d --- /dev/null +++ b/src/dist/bin/start-client @@ -0,0 +1,3 @@ +#!/bin/bash + +$(dirname $0)/starter client \ No newline at end of file diff --git a/src/dist/bin/start-client.bat b/src/dist/bin/start-client.bat new file mode 100755 index 0000000..e6b911a --- /dev/null +++ b/src/dist/bin/start-client.bat @@ -0,0 +1,3 @@ +@echo off + +"%~dp0\..\starter.bat" client \ No newline at end of file diff --git a/src/dist/bin/starter b/src/dist/bin/starter new file mode 100755 index 0000000..5b7a3df --- /dev/null +++ b/src/dist/bin/starter @@ -0,0 +1,5 @@ +#!/bin/bash + +cd $(dirname $0)/.. +bin/sample $1 -config config/ncore-properties.xml -logconfig config/log4j.properties $2 $3 $4 $5 +cd $OLDPWD \ No newline at end of file diff --git a/src/dist/bin/starter.bat b/src/dist/bin/starter.bat new file mode 100755 index 0000000..50aeea3 --- /dev/null +++ b/src/dist/bin/starter.bat @@ -0,0 +1,5 @@ +@echo off + +pushd "%~dp0\.." +bin\sample.bat %1 -config config\ncore-properties.xml -logconfig config\log4j.properties %2 %3 %4 %5 +popd \ No newline at end of file diff --git a/src/dist/config/log4j.properties b/src/dist/config/log4j.properties new file mode 100644 index 0000000..77df3a2 --- /dev/null +++ b/src/dist/config/log4j.properties @@ -0,0 +1,24 @@ +log4j.rootLogger=ERROR, file, stdout +log4j.logger.biz.redsoft.ncore.docflow.Log4jDocFlowLogger=ERROR, biz.redsoft.ncore.docflow.Log4jDocFlowLogger + +log4j.appender.biz.redsoft.ncore.docflow.Log4jDocFlowLogger=org.apache.log4j.FileAppender +log4j.appender.biz.redsoft.ncore.docflow.Log4jDocFlowLogger.layout=org.apache.log4j.PatternLayout +log4j.appender.biz.redsoft.ncore.docflow.Log4jDocFlowLogger.layout.ConversionPattern=%d{dd.MM.yy HH:mm:ss.SSS},%t,%p,%c{1},%m%n +log4j.appender.biz.redsoft.ncore.docflow.Log4jDocFlowLogger.encoding=UTF-8 +log4j.appender.biz.redsoft.ncore.docflow.Log4jDocFlowLogger.File=${server.home}/logs/sample-docflow.log + +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{dd.MM.yy HH:mm:ss.SSS},%t,%p,%c{1},%m%n +log4j.appender.stdout.encoding=UTF-8 + +log4j.appender.stdout.Threshold=ERROR + +log4j.appender.file=org.apache.log4j.FileAppender +log4j.appender.file.layout=org.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern=%d{dd.MM.yy HH:mm:ss.SSS},%t,%p,%c{1},%m%n +log4j.appender.file.encoding=UTF-8 +log4j.appender.file.Threshold=ERROR + +log4j.appender.file.File=${server.home}/logs/ncore-sample.log +log4j.appender.file.Append=true \ No newline at end of file diff --git a/src/dist/config/ncore-properties.xml b/src/dist/config/ncore-properties.xml new file mode 100644 index 0000000..c105852 --- /dev/null +++ b/src/dist/config/ncore-properties.xml @@ -0,0 +1,16 @@ + + + + Configuration settings for ncore platform + + + sample + Sample ncore project + + + org.firebirdsql.jdbc.FBDriver + jdbc:firebirdsql:localhost:ncore-sample?lc_ctype=WIN1251 + SYSDBA + masterkey + + \ No newline at end of file diff --git a/src/main/java/biz/redsoft/sample/Product.java b/src/main/java/biz/redsoft/sample/Product.java new file mode 100644 index 0000000..74c12f1 --- /dev/null +++ b/src/main/java/biz/redsoft/sample/Product.java @@ -0,0 +1,26 @@ +package biz.redsoft.sample; + +import biz.redsoft.ncore.system.application.Application; + +import java.util.Map; + +/** + * @author Victor Bellavin + */ +public class Product implements biz.redsoft.ncore.product.Product { + @Override + public void init(Map properties) { + } + + @Override + public void init(Application application) { + } + + @Override + public void destroy(Application application) { + } + + @Override + public void destroy() { + } +} diff --git a/src/main/java/biz/redsoft/sample/Version.java b/src/main/java/biz/redsoft/sample/Version.java new file mode 100644 index 0000000..117374a --- /dev/null +++ b/src/main/java/biz/redsoft/sample/Version.java @@ -0,0 +1,68 @@ +package biz.redsoft.sample; + +import biz.redsoft.util.IncorrectVersionFormat; +import biz.redsoft.util.VersionUtils; +import org.apache.log4j.Logger; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +/** + * @author Victor Bellavin + */ +public class Version { + public static final Logger LOGGER = Logger.getLogger(Version.class); + + public static final String VERSION_FILE = "version.properties"; + public static final String VERSION_PROP_NAME = "version"; + + private static final VersionUtils.Version version = readVersion(); + + public static VersionUtils.Version getInstance() { + return getVersion(); + } + + public static VersionUtils.Version getVersion() { + return version; + } + + private static VersionUtils.Version readVersion() { + final VersionUtils.Version version = new VersionUtils.Version(); + final String packageName = Version.class.getPackage().getName(); + final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); + final String versionPath = "META-INF/ncore-product/" + packageName + "/" + VERSION_FILE; + final InputStream is = classLoader.getResourceAsStream(versionPath); + if (is != null) { + loadVersion(version, is); + } else { + LOGGER.warn("No version resource at " + versionPath + " Trying to load it from the main package..."); + final InputStream oldStream = Version.class.getResourceAsStream(VERSION_FILE); + if (oldStream != null) + loadVersion(version, oldStream); + else + LOGGER.error("No version resource in classpath"); + } + return version; + } + + private static void loadVersion(VersionUtils.Version version, InputStream is) { + try { + try { + final Properties props = new Properties(); + props.load(is); + final String moduleVersion = props.getProperty(VERSION_PROP_NAME); + if (moduleVersion != null) + version.setVersion(moduleVersion); + else + LOGGER.error("No module.version key in version properties"); + } catch (IncorrectVersionFormat e) { + LOGGER.error("Error reading version", e); + } finally { + is.close(); + } + }catch (IOException e) { + LOGGER.error("Error reading version", e); + } + } +} \ No newline at end of file diff --git a/src/main/resources/META-INF/ncore-product/biz.redsoft.sample/register.json b/src/main/resources/META-INF/ncore-product/biz.redsoft.sample/register.json new file mode 100644 index 0000000..7b492c4 --- /dev/null +++ b/src/main/resources/META-INF/ncore-product/biz.redsoft.sample/register.json @@ -0,0 +1,4 @@ +{ + "dependencies": [], + "register": {} +} diff --git a/src/main/resources/META-INF/ncore-product/biz.redsoft.sample/version.properties b/src/main/resources/META-INF/ncore-product/biz.redsoft.sample/version.properties new file mode 100644 index 0000000..08dc019 --- /dev/null +++ b/src/main/resources/META-INF/ncore-product/biz.redsoft.sample/version.properties @@ -0,0 +1,3 @@ +version=1.1.1.1-SNAPSHOT +# release | build | patchset +type=release \ No newline at end of file diff --git a/src/main/webapp/META-INF/context.xml b/src/main/webapp/META-INF/context.xml new file mode 100644 index 0000000..cc88a12 --- /dev/null +++ b/src/main/webapp/META-INF/context.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/log4j.properties b/src/main/webapp/WEB-INF/log4j.properties new file mode 100644 index 0000000..77df3a2 --- /dev/null +++ b/src/main/webapp/WEB-INF/log4j.properties @@ -0,0 +1,24 @@ +log4j.rootLogger=ERROR, file, stdout +log4j.logger.biz.redsoft.ncore.docflow.Log4jDocFlowLogger=ERROR, biz.redsoft.ncore.docflow.Log4jDocFlowLogger + +log4j.appender.biz.redsoft.ncore.docflow.Log4jDocFlowLogger=org.apache.log4j.FileAppender +log4j.appender.biz.redsoft.ncore.docflow.Log4jDocFlowLogger.layout=org.apache.log4j.PatternLayout +log4j.appender.biz.redsoft.ncore.docflow.Log4jDocFlowLogger.layout.ConversionPattern=%d{dd.MM.yy HH:mm:ss.SSS},%t,%p,%c{1},%m%n +log4j.appender.biz.redsoft.ncore.docflow.Log4jDocFlowLogger.encoding=UTF-8 +log4j.appender.biz.redsoft.ncore.docflow.Log4jDocFlowLogger.File=${server.home}/logs/sample-docflow.log + +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{dd.MM.yy HH:mm:ss.SSS},%t,%p,%c{1},%m%n +log4j.appender.stdout.encoding=UTF-8 + +log4j.appender.stdout.Threshold=ERROR + +log4j.appender.file=org.apache.log4j.FileAppender +log4j.appender.file.layout=org.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern=%d{dd.MM.yy HH:mm:ss.SSS},%t,%p,%c{1},%m%n +log4j.appender.file.encoding=UTF-8 +log4j.appender.file.Threshold=ERROR + +log4j.appender.file.File=${server.home}/logs/ncore-sample.log +log4j.appender.file.Append=true \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/ncore-properties.xml b/src/main/webapp/WEB-INF/ncore-properties.xml new file mode 100644 index 0000000..c105852 --- /dev/null +++ b/src/main/webapp/WEB-INF/ncore-properties.xml @@ -0,0 +1,16 @@ + + + + Configuration settings for ncore platform + + + sample + Sample ncore project + + + org.firebirdsql.jdbc.FBDriver + jdbc:firebirdsql:localhost:ncore-sample?lc_ctype=WIN1251 + SYSDBA + masterkey + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..93ec55a --- /dev/null +++ b/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,51 @@ + + + + 30 + + Sample server + + productionMode + true + + + A list of ncore config files + ncoreConfigFiles + + ncore-properties.xml + ncore-properties-local.xml + + + + ncore + biz.redsoft.ncore.server.NcoreApplicationServlet + + Vaadin application class to start + application + biz.redsoft.ncore.client.vaadin.WebApplication + + + Application widgetset + widgetset + biz.redsoft.ncore.client.vaadin.NcoreWidgetset + + + + ncore + /client/* + + + ncore + /VAADIN/* + + + biz.redsoft.ncore.dx.init.DxInitializationListener + + + client + + diff --git a/src/test/java/biz/redsoft/sample/SampleTests.java b/src/test/java/biz/redsoft/sample/SampleTests.java new file mode 100644 index 0000000..53866da --- /dev/null +++ b/src/test/java/biz/redsoft/sample/SampleTests.java @@ -0,0 +1,22 @@ +package biz.redsoft.sample; + +import biz.redsoft.ncore.util.Misc; + +import java.io.IOException; +import java.util.Arrays; +import java.util.Properties; + +import org.junit.Assert; +import org.junit.Test; + +/** + * @author Victor Bellavin + */ +public class SampleTests { + @Test + public void testProductName() throws IOException { + final Properties props = new Properties(System.getProperties()); + Misc.loadProperties(props, Arrays.asList("ncore-properties.xml", "ncore-properties-local.xml")); + Assert.assertEquals(props.getProperty("product.name"), "sample"); + } +} diff --git a/updates/SAMPLE-0000001.xml b/updates/SAMPLE-0000001.xml new file mode 100644 index 0000000..7b7c580 --- /dev/null +++ b/updates/SAMPLE-0000001.xml @@ -0,0 +1,25 @@ + + + + + +