Initial migrating to gradle, had to remove javafx files as the dependency was not working.
This commit is contained in:
parent
71344e931e
commit
defd9430cc
25 changed files with 311 additions and 1185 deletions
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
5
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
5
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
185
gradlew
vendored
Normal file
185
gradlew
vendored
Normal file
|
|
@ -0,0 +1,185 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright 2015 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
|
||||||
|
#
|
||||||
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
##
|
||||||
|
## Gradle start up script for UN*X
|
||||||
|
##
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# 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\"`/" >/dev/null
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
|
APP_NAME="Gradle"
|
||||||
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
|
# 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
|
||||||
|
nonstop=false
|
||||||
|
case "`uname`" in
|
||||||
|
CYGWIN* )
|
||||||
|
cygwin=true
|
||||||
|
;;
|
||||||
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
NONSTOP* )
|
||||||
|
nonstop=true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
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" -a "$nonstop" = "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 or MSYS, switch paths to Windows format before running java
|
||||||
|
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||||
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
|
||||||
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
|
# 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=`expr $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
|
||||||
|
|
||||||
|
# Escape application args
|
||||||
|
save () {
|
||||||
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
|
echo " "
|
||||||
|
}
|
||||||
|
APP_ARGS=`save "$@"`
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
||||||
104
gradlew.bat
vendored
Normal file
104
gradlew.bat
vendored
Normal file
|
|
@ -0,0 +1,104 @@
|
||||||
|
@rem
|
||||||
|
@rem Copyright 2015 the original author or authors.
|
||||||
|
@rem
|
||||||
|
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@rem you may not use this file except in compliance with the License.
|
||||||
|
@rem You may obtain a copy of the License at
|
||||||
|
@rem
|
||||||
|
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@rem
|
||||||
|
@rem Unless required by applicable law or agreed to in writing, software
|
||||||
|
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@rem See the License for the specific language governing permissions and
|
||||||
|
@rem limitations under the License.
|
||||||
|
@rem
|
||||||
|
|
||||||
|
@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
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||||
|
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||||
|
|
||||||
|
@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="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
|
@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 Windows variants
|
||||||
|
|
||||||
|
if not "%OS%" == "Windows_NT" goto win9xME_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=%*
|
||||||
|
|
||||||
|
: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
|
||||||
|
|
@ -38,9 +38,6 @@ import java.util.LinkedList;
|
||||||
*/
|
*/
|
||||||
public class EuclideansAlgo {
|
public class EuclideansAlgo {
|
||||||
|
|
||||||
/**
|
|
||||||
* Simple Test
|
|
||||||
*/
|
|
||||||
public static void main(String[] args){
|
public static void main(String[] args){
|
||||||
MultiPrintStream.out.println("*** Correct Answer: ");
|
MultiPrintStream.out.println("*** Correct Answer: ");
|
||||||
MultiPrintStream.out.println("java.util.LinkedList{0, 2, 1, 1, 1, 4, 12, 102, 1, 1, 2, 3, 2, 2, 36}");
|
MultiPrintStream.out.println("java.util.LinkedList{0, 2, 1, 1, 1, 4, 12, 102, 1, 1, 2, 3, 2, 2, 36}");
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ public class SQLQuery {
|
||||||
//*******************************************
|
//*******************************************
|
||||||
// Main Types
|
// Main Types
|
||||||
/**
|
/**
|
||||||
* <XMP>
|
* <pre>
|
||||||
* SELECT
|
* SELECT
|
||||||
* [ALL | DISTINCT | DISTINCTROW ]
|
* [ALL | DISTINCT | DISTINCTROW ]
|
||||||
* [FROM table_references
|
* [FROM table_references
|
||||||
|
|
@ -65,7 +65,7 @@ public class SQLQuery {
|
||||||
* [ORDER BY {col_name | expr | position}
|
* [ORDER BY {col_name | expr | position}
|
||||||
* [ASC | DESC], ...]
|
* [ASC | DESC], ...]
|
||||||
* [LIMIT {[offset,] row_count | row_count OFFSET offset}]
|
* [LIMIT {[offset,] row_count | row_count OFFSET offset}]
|
||||||
* </XMP>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
public static class SQLSelect extends SQLQueryItem{
|
public static class SQLSelect extends SQLQueryItem{
|
||||||
String[] params;
|
String[] params;
|
||||||
|
|
|
||||||
|
|
@ -1,65 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<!--
|
|
||||||
~ The MIT License (MIT)
|
|
||||||
~
|
|
||||||
~ Copyright (c) 2015 Ziver Koc
|
|
||||||
~
|
|
||||||
~ Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
~ of this software and associated documentation files (the "Software"), to deal
|
|
||||||
~ in the Software without restriction, including without limitation the rights
|
|
||||||
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
~ copies of the Software, and to permit persons to whom the Software is
|
|
||||||
~ furnished to do so, subject to the following conditions:
|
|
||||||
~
|
|
||||||
~ The above copyright notice and this permission notice shall be included in
|
|
||||||
~ all copies or substantial portions of the Software.
|
|
||||||
~
|
|
||||||
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
~ THE SOFTWARE.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<?import javafx.scene.control.*?>
|
|
||||||
<?import javafx.scene.layout.*?>
|
|
||||||
<AnchorPane id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity"
|
|
||||||
prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml"
|
|
||||||
fx:controller="zutil.log.net.NetLogGuiClient">
|
|
||||||
<MenuBar prefWidth="598.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
|
||||||
<menus>
|
|
||||||
<Menu mnemonicParsing="false" text="File">
|
|
||||||
<items>
|
|
||||||
<MenuItem mnemonicParsing="false" text="Open File"/>
|
|
||||||
<MenuItem mnemonicParsing="false" onAction="#handleConnectAction" text="Connect"/>
|
|
||||||
<Menu mnemonicParsing="false" text="Previous">
|
|
||||||
<items>
|
|
||||||
<MenuItem mnemonicParsing="false" text="Koc.se:8080"/>
|
|
||||||
<MenuItem mnemonicParsing="false" text="localhost:8080"/>
|
|
||||||
</items>
|
|
||||||
</Menu>
|
|
||||||
<SeparatorMenuItem mnemonicParsing="false"/>
|
|
||||||
<MenuItem mnemonicParsing="false" text="Export"/>
|
|
||||||
<SeparatorMenuItem disable="true" mnemonicParsing="false"/>
|
|
||||||
<MenuItem mnemonicParsing="false" onAction="#handleExitAction" text="Exit"/>
|
|
||||||
</items>
|
|
||||||
</Menu>
|
|
||||||
<Menu mnemonicParsing="false" text="Edit">
|
|
||||||
<items>
|
|
||||||
<MenuItem disable="true" mnemonicParsing="false" text="Copy"/>
|
|
||||||
</items>
|
|
||||||
</Menu>
|
|
||||||
<Menu mnemonicParsing="false" text="Help">
|
|
||||||
<items>
|
|
||||||
<MenuItem mnemonicParsing="false" onAction="#handleAboutAction" text="About"/>
|
|
||||||
</items>
|
|
||||||
</Menu>
|
|
||||||
</menus>
|
|
||||||
</MenuBar>
|
|
||||||
<TabPane fx:id="tabPane" prefHeight="364.0" prefWidth="586.0" tabClosingPolicy="ALL_TABS"
|
|
||||||
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"
|
|
||||||
AnchorPane.topAnchor="22.0"/>
|
|
||||||
</AnchorPane>
|
|
||||||
|
|
@ -1,89 +0,0 @@
|
||||||
/*
|
|
||||||
* The MIT License (MIT)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2015 Ziver Koc
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package zutil.log.net;
|
|
||||||
|
|
||||||
import zutil.log.LogUtil;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.ObjectInputStream;
|
|
||||||
import java.io.ObjectOutputStream;
|
|
||||||
import java.net.Socket;
|
|
||||||
import java.net.UnknownHostException;
|
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
|
|
||||||
public class NetLogClient extends Thread{
|
|
||||||
private static final Logger logger = LogUtil.getLogger();
|
|
||||||
|
|
||||||
private ConcurrentLinkedQueue<NetLogListener> listeners;
|
|
||||||
private Socket s;
|
|
||||||
|
|
||||||
public NetLogClient(String host, int port) throws IOException{
|
|
||||||
s = new Socket(host, port);
|
|
||||||
listeners = new ConcurrentLinkedQueue<>();
|
|
||||||
this.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addListener(NetLogListener listener){
|
|
||||||
logger.info("Registering new NetLogListener: "+listener.getClass().getName());
|
|
||||||
listeners.add( listener );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void run(){
|
|
||||||
try{
|
|
||||||
ObjectInputStream in = new ObjectInputStream(s.getInputStream());
|
|
||||||
while( true ){
|
|
||||||
Object o = in.readObject();
|
|
||||||
|
|
||||||
for( NetLogListener listener : listeners ){
|
|
||||||
if( o instanceof NetLogMessage )
|
|
||||||
listener.handleLogMessage((NetLogMessage)o);
|
|
||||||
else if( o instanceof NetLogExceptionMessage )
|
|
||||||
listener.handleExceptionMessage((NetLogExceptionMessage)o);
|
|
||||||
else if( o instanceof NetLogStatusMessage )
|
|
||||||
listener.handleStatusMessage((NetLogStatusMessage)o);
|
|
||||||
else
|
|
||||||
logger.warning("Received unknown message: "+o.getClass().getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch( Exception e ){
|
|
||||||
logger.log(Level.SEVERE, null, e);
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void close(){
|
|
||||||
try{
|
|
||||||
this.interrupt();
|
|
||||||
s.close();
|
|
||||||
} catch (Exception e){
|
|
||||||
logger.log(Level.SEVERE, "Unable to close Client Socket.", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
/* LOG LEVELS */
|
|
||||||
.SEVERE {
|
|
||||||
-fx-control-inner-background: palevioletred;
|
|
||||||
-fx-accent: derive(-fx-control-inner-background, -40%);
|
|
||||||
-fx-cell-hover-color: derive(-fx-control-inner-background, -20%);
|
|
||||||
}
|
|
||||||
.WARNING {
|
|
||||||
-fx-control-inner-background: yellow;
|
|
||||||
-fx-accent: derive(-fx-control-inner-background, -40%);
|
|
||||||
-fx-cell-hover-color: derive(-fx-control-inner-background, -20%);
|
|
||||||
}
|
|
||||||
.INFO { }
|
|
||||||
.FINE {
|
|
||||||
-fx-control-inner-background: lavender;
|
|
||||||
-fx-accent: derive(-fx-control-inner-background, -40%);
|
|
||||||
-fx-cell-hover-color: derive(-fx-control-inner-background, -20%);
|
|
||||||
}
|
|
||||||
.FINER {
|
|
||||||
-fx-control-inner-background: lightblue ;
|
|
||||||
-fx-accent: derive(-fx-control-inner-background, -40%);
|
|
||||||
-fx-cell-hover-color: derive(-fx-control-inner-background, -20%);
|
|
||||||
}
|
|
||||||
.FINEST {
|
|
||||||
-fx-control-inner-background: skyblue;
|
|
||||||
-fx-accent: derive(-fx-control-inner-background, -40%);
|
|
||||||
-fx-cell-hover-color: derive(-fx-control-inner-background, -20%);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Clear empty rows */
|
|
||||||
.table-row-cell:empty {
|
|
||||||
-fx-background-color: null;
|
|
||||||
}
|
|
||||||
.table-row-cell:empty .table-cell {
|
|
||||||
-fx-border-width: 0px;
|
|
||||||
}
|
|
||||||
|
|
@ -1,135 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<!--
|
|
||||||
~ The MIT License (MIT)
|
|
||||||
~
|
|
||||||
~ Copyright (c) 2015 Ziver Koc
|
|
||||||
~
|
|
||||||
~ Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
~ of this software and associated documentation files (the "Software"), to deal
|
|
||||||
~ in the Software without restriction, including without limitation the rights
|
|
||||||
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
~ copies of the Software, and to permit persons to whom the Software is
|
|
||||||
~ furnished to do so, subject to the following conditions:
|
|
||||||
~
|
|
||||||
~ The above copyright notice and this permission notice shall be included in
|
|
||||||
~ all copies or substantial portions of the Software.
|
|
||||||
~
|
|
||||||
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
~ THE SOFTWARE.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<?import javafx.collections.FXCollections?>
|
|
||||||
<?import javafx.scene.control.*?>
|
|
||||||
<?import javafx.scene.Group?>
|
|
||||||
<?import javafx.scene.layout.*?>
|
|
||||||
<?import javafx.scene.text.Font?>
|
|
||||||
<?import java.lang.*?>
|
|
||||||
<?import java.net.URL?>
|
|
||||||
<BorderPane xmlns:fx="http://javafx.com/fxml" fx:controller="zutil.log.net.NetLogGuiClientInstance">
|
|
||||||
<stylesheets>
|
|
||||||
<URL value="@NetLogClientInstance.css" />
|
|
||||||
</stylesheets>
|
|
||||||
<bottom>
|
|
||||||
<ToolBar maxHeight="22.0" minHeight="19.0" prefHeight="22.0" prefWidth="839.0">
|
|
||||||
<ProgressBar fx:id="progressBar" prefWidth="200.0" progress="0.0"/>
|
|
||||||
<Label fx:id="errorLabel" textFill="RED">
|
|
||||||
<font>
|
|
||||||
<Font size="11.0"/>
|
|
||||||
</font>
|
|
||||||
</Label>
|
|
||||||
<Region HBox.Hgrow="ALWAYS"/>
|
|
||||||
<Separator orientation="VERTICAL" prefHeight="200.0"/>
|
|
||||||
<Label fx:id="logCountLabel" text="0">
|
|
||||||
<graphic>
|
|
||||||
<Label text="Log Count:"/>
|
|
||||||
</graphic>
|
|
||||||
</Label>
|
|
||||||
</ToolBar>
|
|
||||||
</bottom>
|
|
||||||
<center>
|
|
||||||
<SplitPane dividerPositions="0.7491525423728813" focusTraversable="true" orientation="VERTICAL" prefHeight="297.0"
|
|
||||||
prefWidth="600.0">
|
|
||||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0">
|
|
||||||
<children>
|
|
||||||
<TableView fx:id="logTable" prefHeight="146.0" prefWidth="598.0" tableMenuButtonVisible="true"
|
|
||||||
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"
|
|
||||||
AnchorPane.topAnchor="0.0">
|
|
||||||
<columns>
|
|
||||||
<TableColumn editable="false" prefWidth="130.0" sortable="false" text="Timestamp"
|
|
||||||
fx:id="logTimestampColumn"/>
|
|
||||||
<TableColumn editable="false" prefWidth="75.0" sortable="false" text="Level"
|
|
||||||
fx:id="logLevelColumn"/>
|
|
||||||
<TableColumn editable="false" prefWidth="400.0" sortable="false" text="Log"
|
|
||||||
fx:id="logColumn"/>
|
|
||||||
</columns>
|
|
||||||
</TableView>
|
|
||||||
</children>
|
|
||||||
</AnchorPane>
|
|
||||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0">
|
|
||||||
<children>
|
|
||||||
<TableView fx:id="exceptionTable" prefHeight="147.0" prefWidth="598.0" tableMenuButtonVisible="true"
|
|
||||||
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"
|
|
||||||
AnchorPane.topAnchor="0.0">
|
|
||||||
<columns>
|
|
||||||
<TableColumn editable="false" prefWidth="45.0" style="-fx-alignment: TOP_CENTER;" text="#"
|
|
||||||
fx:id="exCountColumn"/>
|
|
||||||
<TableColumn editable="false" prefWidth="250.0"
|
|
||||||
style="-fx-alignment: TOP_LEFT; -fx-font-weight: bold;" text="Exception"
|
|
||||||
fx:id="exNameColumn"/>
|
|
||||||
<TableColumn editable="false" prefWidth="300.0" style="-fx-alignment: TOP_LEFT;"
|
|
||||||
text="Message" fx:id="exMessageColumn"/>
|
|
||||||
<TableColumn editable="false" prefWidth="450.0" text="StackTrace" fx:id="exStackTraceColumn"/>
|
|
||||||
</columns>
|
|
||||||
</TableView>
|
|
||||||
</children>
|
|
||||||
</AnchorPane>
|
|
||||||
</SplitPane>
|
|
||||||
</center>
|
|
||||||
<top>
|
|
||||||
<ToolBar maxHeight="30.0" minHeight="22.0" prefHeight="30.0" prefWidth="839.0">
|
|
||||||
<ToggleButton fx:id="pauseButton" mnemonicParsing="false" onAction="#handlePauseAction" text="Pause"/>
|
|
||||||
<Region HBox.Hgrow="ALWAYS"/>
|
|
||||||
<Group id="Group">
|
|
||||||
<children>
|
|
||||||
<Label fx:id="levelLabel" layoutY="-7.0" text="Log Level: "/>
|
|
||||||
<ComboBox fx:id="levelComboBox" layoutX="60.0" layoutY="-9.0" onAction="#handleLevelChanged">
|
|
||||||
<items>
|
|
||||||
<FXCollections fx:factory="observableArrayList">
|
|
||||||
<String fx:value="01 - ERROR"/>
|
|
||||||
<String fx:value="02 - WARNING"/>
|
|
||||||
<String fx:value="03 - INFO"/>
|
|
||||||
<String fx:value="04 - FINE"/>
|
|
||||||
<String fx:value="05 - FINER"/>
|
|
||||||
<String fx:value="06 - FINEST"/>
|
|
||||||
</FXCollections>
|
|
||||||
</items>
|
|
||||||
</ComboBox>
|
|
||||||
</children>
|
|
||||||
</Group>
|
|
||||||
<Group id="Group">
|
|
||||||
<children>
|
|
||||||
<Label fx:id="intervalLabel" alignment="CENTER_RIGHT" layoutY="-7.0" prefWidth="60.0"
|
|
||||||
text="Interval: "/>
|
|
||||||
<ComboBox fx:id="intervalComboBox" layoutX="65.0" layoutY="-9.0" onAction="#handleIntervalChanged">
|
|
||||||
<items>
|
|
||||||
<FXCollections fx:factory="observableArrayList">
|
|
||||||
<String fx:value="Instant"/>
|
|
||||||
<String fx:value="3 sec"/>
|
|
||||||
<String fx:value="5 sec"/>
|
|
||||||
<String fx:value="10 sec"/>
|
|
||||||
<String fx:value="30 sec"/>
|
|
||||||
<String fx:value="60 sec"/>
|
|
||||||
</FXCollections>
|
|
||||||
</items>
|
|
||||||
</ComboBox>
|
|
||||||
</children>
|
|
||||||
</Group>
|
|
||||||
</ToolBar>
|
|
||||||
</top>
|
|
||||||
</BorderPane>
|
|
||||||
|
|
@ -1,107 +0,0 @@
|
||||||
/*
|
|
||||||
* The MIT License (MIT)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2015 Ziver Koc
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package zutil.log.net;
|
|
||||||
|
|
||||||
import zutil.net.nio.message.Message;
|
|
||||||
|
|
||||||
import java.util.logging.LogRecord;
|
|
||||||
|
|
||||||
public class NetLogExceptionMessage implements Message {
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private int count;
|
|
||||||
private String name;
|
|
||||||
private String message;
|
|
||||||
private String stackTrace;
|
|
||||||
|
|
||||||
NetLogExceptionMessage(String name, String message, String stackTrace){
|
|
||||||
this.count = 1;
|
|
||||||
this.name = name;
|
|
||||||
this.message = message;
|
|
||||||
this.stackTrace = stackTrace;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NetLogExceptionMessage(LogRecord record) {
|
|
||||||
Throwable exception = record.getThrown();
|
|
||||||
|
|
||||||
this.count = 1;
|
|
||||||
this.name = exception.getClass().getName();
|
|
||||||
this.message = exception.getMessage();
|
|
||||||
|
|
||||||
StringBuilder str = new StringBuilder();
|
|
||||||
for(int i=0; i<exception.getStackTrace().length; i++){
|
|
||||||
str.append(exception.getStackTrace()[i].toString());
|
|
||||||
}
|
|
||||||
this.stackTrace = str.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
final int prime = 31;
|
|
||||||
int result = 1;
|
|
||||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
|
||||||
result = prime * result + ((message == null) ? 0 : message.hashCode());
|
|
||||||
result = prime * result
|
|
||||||
+ ((stackTrace == null) ? 0 : stackTrace.hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (this == obj)
|
|
||||||
return true;
|
|
||||||
if (obj == null || getClass() != obj.getClass())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
NetLogExceptionMessage other = (NetLogExceptionMessage) obj;
|
|
||||||
if (name.equals(other.name) && message.equals(other.message) &&
|
|
||||||
stackTrace.equals(other.stackTrace)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addCount(int add){
|
|
||||||
count += add;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCount() {
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMessage() {
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getStackTrace() {
|
|
||||||
return stackTrace;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,95 +0,0 @@
|
||||||
/*
|
|
||||||
* The MIT License (MIT)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2015 Ziver Koc
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package zutil.log.net;
|
|
||||||
|
|
||||||
import javafx.application.Application;
|
|
||||||
import javafx.event.ActionEvent;
|
|
||||||
import javafx.fxml.FXML;
|
|
||||||
import javafx.fxml.FXMLLoader;
|
|
||||||
import javafx.scene.Parent;
|
|
||||||
import javafx.scene.Scene;
|
|
||||||
import javafx.scene.control.Tab;
|
|
||||||
import javafx.scene.control.TabPane;
|
|
||||||
import javafx.scene.layout.AnchorPane;
|
|
||||||
import javafx.stage.Stage;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class NetLogGuiClient extends Application{
|
|
||||||
public static final String VERSION = "0.1";
|
|
||||||
|
|
||||||
// UI elements
|
|
||||||
@FXML
|
|
||||||
private TabPane tabPane;
|
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
Application.launch(NetLogGuiClient.class, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void start(Stage stage) throws Exception {
|
|
||||||
Parent root = FXMLLoader.load(getClass().getResource("NetLogClient.fxml"));
|
|
||||||
|
|
||||||
stage.setTitle("NetLoggerClient ("+VERSION+")");
|
|
||||||
stage.setScene(new Scene(root));
|
|
||||||
stage.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Menu Actions
|
|
||||||
@FXML
|
|
||||||
protected void handleConnectAction(ActionEvent event) {
|
|
||||||
try{
|
|
||||||
tabPane.getTabs().add(new NetLoggerClientTab("koc.se", 8080));
|
|
||||||
}catch(Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
protected void handleExitAction(ActionEvent event) {
|
|
||||||
System.exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
protected void handleAboutAction(ActionEvent event) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class NetLoggerClientTab extends Tab{
|
|
||||||
public NetLoggerClientTab(String host, int port) throws IOException{
|
|
||||||
this.setText( host+":"+port );
|
|
||||||
|
|
||||||
Parent tabRoot = FXMLLoader.load(getClass().getResource("NetLogClientInstance.fxml"));
|
|
||||||
this.setContent(tabRoot);
|
|
||||||
AnchorPane.setRightAnchor(tabRoot, 0.0);
|
|
||||||
//this.setOnClosed(new EventHandler<Event>() {
|
|
||||||
// public void handle(Event e) {
|
|
||||||
// handleDisconnectAction(e);
|
|
||||||
// }
|
|
||||||
//});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,222 +0,0 @@
|
||||||
/*
|
|
||||||
* The MIT License (MIT)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2015 Ziver Koc
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package zutil.log.net;
|
|
||||||
|
|
||||||
import javafx.application.Platform;
|
|
||||||
import javafx.event.ActionEvent;
|
|
||||||
import javafx.event.Event;
|
|
||||||
import javafx.fxml.FXML;
|
|
||||||
import javafx.fxml.Initializable;
|
|
||||||
import javafx.scene.control.*;
|
|
||||||
import javafx.scene.control.cell.PropertyValueFactory;
|
|
||||||
import javafx.util.Callback;
|
|
||||||
import zutil.log.LogUtil;
|
|
||||||
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.ResourceBundle;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
public class NetLogGuiClientInstance implements Initializable, NetLogListener {
|
|
||||||
private static final Logger logger = LogUtil.getLogger();
|
|
||||||
private enum Status{RUNNING, PAUSED, DISCONNECTED}
|
|
||||||
|
|
||||||
// Logic variables
|
|
||||||
private NetLogClient net;
|
|
||||||
private Status status;
|
|
||||||
|
|
||||||
// UI elements
|
|
||||||
@FXML private ToggleButton pauseButton;
|
|
||||||
@FXML private Label levelLabel;
|
|
||||||
@FXML private ComboBox levelComboBox;
|
|
||||||
@FXML private Label intervalLabel;
|
|
||||||
@FXML private ComboBox intervalComboBox;
|
|
||||||
@FXML private ProgressBar progressBar;
|
|
||||||
@FXML private Label errorLabel;
|
|
||||||
@FXML private Label logCountLabel;
|
|
||||||
|
|
||||||
@FXML private TableView<NetLogMessage> logTable;
|
|
||||||
@FXML private TableColumn<NetLogMessage, Long> logTimestampColumn;
|
|
||||||
@FXML private TableColumn<NetLogMessage, String> logLevelColumn;
|
|
||||||
@FXML private TableColumn<NetLogMessage, String> logColumn;
|
|
||||||
|
|
||||||
@FXML private TableView<NetLogExceptionMessage> exceptionTable;
|
|
||||||
@FXML private TableColumn<NetLogExceptionMessage, Long> exCountColumn;
|
|
||||||
@FXML private TableColumn<NetLogExceptionMessage, String> exNameColumn;
|
|
||||||
@FXML private TableColumn<NetLogExceptionMessage, String> exMessageColumn;
|
|
||||||
@FXML private TableColumn<NetLogExceptionMessage, String> exStackTraceColumn;
|
|
||||||
|
|
||||||
|
|
||||||
public void initialize(URL arg0, ResourceBundle arg1) {
|
|
||||||
// Connect to Server
|
|
||||||
try{
|
|
||||||
net = new NetLogClient("127.0.0.1", 5050);
|
|
||||||
net.addListener( this );
|
|
||||||
status = Status.RUNNING;
|
|
||||||
}catch(Exception e){
|
|
||||||
logger.log(Level.SEVERE, null, e);
|
|
||||||
status = Status.DISCONNECTED;
|
|
||||||
errorLabel.setText(e.getMessage());
|
|
||||||
}
|
|
||||||
updateStatus();
|
|
||||||
|
|
||||||
// Setup Gui
|
|
||||||
logTimestampColumn.setCellValueFactory(new PropertyValueFactory<>("timestamp"));
|
|
||||||
logLevelColumn.setCellValueFactory(new PropertyValueFactory<>("level"));
|
|
||||||
logLevelColumn.setCellFactory(new RowCssCellFactory<NetLogMessage,String>(){
|
|
||||||
public String getStyleName(String item){
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
logColumn.setCellValueFactory(new PropertyValueFactory<>("log"));
|
|
||||||
|
|
||||||
exCountColumn.setCellValueFactory(new PropertyValueFactory<>("count"));
|
|
||||||
exNameColumn.setCellValueFactory(new PropertyValueFactory<>("name"));
|
|
||||||
exMessageColumn.setCellValueFactory(new PropertyValueFactory<>("message"));
|
|
||||||
exStackTraceColumn.setCellValueFactory(new PropertyValueFactory<>("stackTrace"));
|
|
||||||
}
|
|
||||||
|
|
||||||
/************* NETWORK *****************/
|
|
||||||
public void handleLogMessage(NetLogMessage msg) {
|
|
||||||
if(status == Status.RUNNING){
|
|
||||||
logTable.getItems().add(msg);
|
|
||||||
|
|
||||||
Platform.runLater(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
logCountLabel.setText("" + (Long.parseLong(logCountLabel.getText()) + 1));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handleExceptionMessage(NetLogExceptionMessage msg) {
|
|
||||||
if(status == Status.RUNNING){
|
|
||||||
exceptionTable.getItems().remove(msg);
|
|
||||||
exceptionTable.getItems().add(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handleStatusMessage(NetLogStatusMessage msg) {
|
|
||||||
if(status == Status.RUNNING){
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*************** GUI *******************/
|
|
||||||
@FXML
|
|
||||||
protected void handlePauseAction(ActionEvent event) {
|
|
||||||
if(status == Status.RUNNING){
|
|
||||||
status = Status.PAUSED;
|
|
||||||
logger.info("Logging paused");
|
|
||||||
}
|
|
||||||
else if(status == Status.PAUSED){
|
|
||||||
status = Status.RUNNING;
|
|
||||||
logger.info("Logging Unpaused");
|
|
||||||
}
|
|
||||||
updateStatus();
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
protected void handleDisconnectAction(Event event) {
|
|
||||||
logger.info("Disconnecting from Log Server");
|
|
||||||
net.close();
|
|
||||||
status = Status.DISCONNECTED;
|
|
||||||
updateStatus();
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
protected void handleLevelChanged(ActionEvent event) {
|
|
||||||
logger.info("Updating Log Level");
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
protected void handleIntervalChanged(ActionEvent event) {
|
|
||||||
logger.info("Updating Log Interval");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateStatus(){
|
|
||||||
if(progressBar == null || pauseButton == null){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(status == Status.RUNNING){
|
|
||||||
progressBar.setProgress(-1.0);
|
|
||||||
pauseButton.setText("Pause");
|
|
||||||
}
|
|
||||||
else if(status == Status.PAUSED){
|
|
||||||
progressBar.setProgress(1.0);
|
|
||||||
pauseButton.setText("Unpause");
|
|
||||||
}
|
|
||||||
else if(status == Status.DISCONNECTED){
|
|
||||||
pauseButton.setDisable(true);
|
|
||||||
levelLabel.setDisable(true);
|
|
||||||
levelComboBox.setDisable(true);
|
|
||||||
intervalLabel.setDisable(true);
|
|
||||||
intervalComboBox.setDisable(true);
|
|
||||||
|
|
||||||
logTable.setDisable(true);
|
|
||||||
exceptionTable.setDisable(true);
|
|
||||||
|
|
||||||
progressBar.setProgress(0);
|
|
||||||
logCountLabel.setDisable(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* http://stackoverflow.com/questions/13697115/javafx-tableview-colors
|
|
||||||
*/
|
|
||||||
public abstract class RowCssCellFactory<S,T> implements Callback<TableColumn<S,T>, TableCell<S,T>> {
|
|
||||||
|
|
||||||
public TableCell<S,T> call(TableColumn<S,T> p) {
|
|
||||||
TableCell<S, T> cell = new TableCell<S, T>() {
|
|
||||||
@Override
|
|
||||||
public void updateItem(T item, boolean empty) {
|
|
||||||
super.updateItem(item, empty);
|
|
||||||
setText(empty ? null : getString());
|
|
||||||
setGraphic(null);
|
|
||||||
|
|
||||||
String style = getStyleName(item);
|
|
||||||
if(style != null){
|
|
||||||
TableRow<?> row = getTableRow();
|
|
||||||
row.getStyleClass().add(style);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateSelected(boolean upd){
|
|
||||||
super.updateSelected(upd);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private String getString() {
|
|
||||||
return getItem() == null ? "NULL" : getItem().toString();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return cell;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract String getStyleName(T item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
||||||
/*
|
|
||||||
* The MIT License (MIT)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2015 Ziver Koc
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package zutil.log.net;
|
|
||||||
|
|
||||||
|
|
||||||
public interface NetLogListener {
|
|
||||||
/**
|
|
||||||
* Handle incoming log messages
|
|
||||||
*/
|
|
||||||
void handleLogMessage(NetLogMessage log);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle incoming exception messages
|
|
||||||
*/
|
|
||||||
void handleExceptionMessage(NetLogExceptionMessage exception);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle incoming status messages
|
|
||||||
*/
|
|
||||||
void handleStatusMessage(NetLogStatusMessage status);
|
|
||||||
}
|
|
||||||
|
|
@ -1,112 +0,0 @@
|
||||||
/*
|
|
||||||
* The MIT License (MIT)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2015 Ziver Koc
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package zutil.log.net;
|
|
||||||
|
|
||||||
import zutil.net.nio.message.Message;
|
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.logging.LogRecord;
|
|
||||||
|
|
||||||
public class NetLogMessage implements Message {
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
private static final SimpleDateFormat dataFormat =
|
|
||||||
new SimpleDateFormat("yyyy--MM-dd HH:mm:ss");
|
|
||||||
|
|
||||||
private long timestamp;
|
|
||||||
private String level;
|
|
||||||
private int threadID;
|
|
||||||
private String className;
|
|
||||||
private String methodName;
|
|
||||||
private String log;
|
|
||||||
|
|
||||||
|
|
||||||
public NetLogMessage(String level, long timestamp, String log){
|
|
||||||
this.level = level;
|
|
||||||
this.timestamp = timestamp;
|
|
||||||
this.log = log;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NetLogMessage( LogRecord record ){
|
|
||||||
timestamp = record.getMillis();
|
|
||||||
level = record.getLevel().getName();
|
|
||||||
threadID = record.getThreadID();
|
|
||||||
className = record.getSourceClassName();
|
|
||||||
methodName = record.getSourceMethodName();
|
|
||||||
log = record.getMessage();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public String getTimestamp() {
|
|
||||||
return dataFormat.format(new Date(timestamp));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTimestamp(long timestamp) {
|
|
||||||
this.timestamp = timestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLevel() {
|
|
||||||
return level;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLevel(String level) {
|
|
||||||
this.level = level;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getThreadID() {
|
|
||||||
return threadID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setThreadID(int threadID) {
|
|
||||||
this.threadID = threadID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getClassName() {
|
|
||||||
return className;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setClassName(String className) {
|
|
||||||
this.className = className;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMethodName() {
|
|
||||||
return methodName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMethodName(String methodName) {
|
|
||||||
this.methodName = methodName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLog() {
|
|
||||||
return log;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLog(String log) {
|
|
||||||
this.log = log;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,175 +0,0 @@
|
||||||
/*
|
|
||||||
* The MIT License (MIT)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2015 Ziver Koc
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package zutil.log.net;
|
|
||||||
|
|
||||||
import zutil.log.LogUtil;
|
|
||||||
import zutil.net.nio.message.Message;
|
|
||||||
import zutil.net.threaded.ThreadedTCPNetworkServer;
|
|
||||||
import zutil.net.threaded.ThreadedTCPNetworkServerThread;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.ObjectInputStream;
|
|
||||||
import java.io.ObjectOutputStream;
|
|
||||||
import java.net.Socket;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
|
||||||
import java.util.logging.Handler;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.LogRecord;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
|
|
||||||
public class NetLogServer extends Handler {
|
|
||||||
private static final Logger logger = LogUtil.getLogger();
|
|
||||||
|
|
||||||
private NetLogNetwork net;
|
|
||||||
private ConcurrentHashMap<NetLogExceptionMessage,NetLogExceptionMessage> exceptions;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param port the port the server will listen on
|
|
||||||
*/
|
|
||||||
public NetLogServer(int port) {
|
|
||||||
super();
|
|
||||||
exceptions = new ConcurrentHashMap<>();
|
|
||||||
net = new NetLogNetwork(port);
|
|
||||||
net.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void publish(LogRecord record) {
|
|
||||||
// ensure that this log record should be logged by this Handler
|
|
||||||
if (!isLoggable(record))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Output the formatted data to the file
|
|
||||||
if(record.getThrown() != null){
|
|
||||||
NetLogExceptionMessage exception = new NetLogExceptionMessage(record);
|
|
||||||
if(!exceptions.containsKey(exception)){
|
|
||||||
logger.finest("Received new exception: "+exception);
|
|
||||||
exceptions.put(exception, exception);
|
|
||||||
net.sendMessage( exception );
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
exception = exceptions.get(exception);
|
|
||||||
exception.addCount(1);
|
|
||||||
logger.finest("Received known exception(Count: "+exception.getCount()+"): "+exception);
|
|
||||||
net.sendMessage( exception );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
NetLogMessage log = new NetLogMessage(record);
|
|
||||||
net.sendMessage( log );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void flush() {}
|
|
||||||
|
|
||||||
public void close() {
|
|
||||||
net.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class NetLogNetwork extends ThreadedTCPNetworkServer{
|
|
||||||
private ConcurrentLinkedQueue<NetLogServerThread> threads;
|
|
||||||
|
|
||||||
public NetLogNetwork(int port) {
|
|
||||||
super(port);
|
|
||||||
threads = new ConcurrentLinkedQueue<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendMessage(Message log){
|
|
||||||
for( NetLogServerThread thread : threads ){
|
|
||||||
thread.sendMessage( log );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected ThreadedTCPNetworkServerThread getThreadInstance(Socket s) {
|
|
||||||
try {
|
|
||||||
return new NetLogServerThread(s);
|
|
||||||
} catch (IOException e) {
|
|
||||||
logger.log(Level.SEVERE, "Unable to start Client thread", e);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class NetLogServerThread implements ThreadedTCPNetworkServerThread{
|
|
||||||
private ObjectOutputStream out;
|
|
||||||
private ObjectInputStream in;
|
|
||||||
private Socket s;
|
|
||||||
|
|
||||||
public NetLogServerThread(Socket s) throws IOException{
|
|
||||||
this.s = s;
|
|
||||||
logger.info("Client connected: "+s.getInetAddress());
|
|
||||||
out = new ObjectOutputStream( s.getOutputStream() );
|
|
||||||
in = new ObjectInputStream( s.getInputStream() );
|
|
||||||
|
|
||||||
sendAllExceptions();
|
|
||||||
threads.add( this );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendMessage(Message msg){
|
|
||||||
try {
|
|
||||||
out.writeObject( msg );
|
|
||||||
out.reset();
|
|
||||||
} catch (Exception e) {
|
|
||||||
this.close();
|
|
||||||
logger.log(Level.SEVERE, "Unable to send message to client: "+s.getInetAddress(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendAllExceptions(){
|
|
||||||
logger.fine("Sending all exceptions to client: "+s.getInetAddress());
|
|
||||||
for(NetLogExceptionMessage e : exceptions.values())
|
|
||||||
sendMessage(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
while( true ){
|
|
||||||
in.readObject();
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.log(Level.SEVERE, null, e);
|
|
||||||
} finally {
|
|
||||||
this.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void close(){
|
|
||||||
try {
|
|
||||||
threads.remove(this);
|
|
||||||
logger.info("Client disconnected: "+s.getInetAddress());
|
|
||||||
out.close();
|
|
||||||
s.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
logger.log(Level.SEVERE, "Unable to close Client Socket", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
/*
|
|
||||||
* The MIT License (MIT)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2015 Ziver Koc
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package zutil.log.net;
|
|
||||||
|
|
||||||
import zutil.net.nio.message.Message;
|
|
||||||
|
|
||||||
public class NetLogStatusMessage implements Message{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
public long totalMemory;
|
|
||||||
public long freememory;
|
|
||||||
}
|
|
||||||
|
|
@ -25,7 +25,7 @@ public class LinearRegression {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Linear Regression cost method.
|
* Linear Regression cost method.
|
||||||
* <br /><br />
|
* <p><br>
|
||||||
* <i>
|
* <i>
|
||||||
* J(O) = 1 / (2 * m) * Σ { ( h(Xi) - Yi )^2 }
|
* J(O) = 1 / (2 * m) * Σ { ( h(Xi) - Yi )^2 }
|
||||||
* </i><br>
|
* </i><br>
|
||||||
|
|
@ -65,11 +65,11 @@ public class LinearRegression {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gradient Descent algorithm
|
* Gradient Descent algorithm
|
||||||
* <br /><br />
|
* <p><br>
|
||||||
* <i>
|
* <i>
|
||||||
* Oj = Oj - α * (1 / m) * Σ { ( h(Xi) - Yi ) * Xij }
|
* Oj = Oj - α * (1 / m) * Σ { ( h(Xi) - Yi ) * Xij }
|
||||||
* </i><br />
|
* </i>
|
||||||
*
|
* <br>
|
||||||
* @return the theta that was found to minimize the cost function
|
* @return the theta that was found to minimize the cost function
|
||||||
*/
|
*/
|
||||||
public static double[] gradientDescentIteration(double[][] x, double[] y, double[] theta, double alpha){
|
public static double[] gradientDescentIteration(double[][] x, double[] y, double[] theta, double alpha){
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@ package zutil.ml.neural;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents one "nuron" in a neural network.
|
* This class represents one "nuron" in a neural network.
|
||||||
*
|
* <p>
|
||||||
* <p/><b>From Wikipedia: </b>
|
* <b>From Wikipedia:</b> https://en.wikipedia.org/wiki/Perceptron
|
||||||
* <blockquote cite="https://en.wikipedia.org/wiki/Perceptron">
|
* <blockquote>
|
||||||
* The perceptron is an algorithm for supervised learning of
|
* The perceptron is an algorithm for supervised learning of
|
||||||
* binary classifiers (functions that can decide whether an
|
* binary classifiers (functions that can decide whether an
|
||||||
* input, represented by a vector of numbers, belongs to some
|
* input, represented by a vector of numbers, belongs to some
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ public class MqttPacketConnect extends MqttPacketHeader {
|
||||||
private int protocolNameLength = 4;
|
private int protocolNameLength = 4;
|
||||||
/**
|
/**
|
||||||
* The Protocol Name is a UTF-8 encoded string that represents
|
* The Protocol Name is a UTF-8 encoded string that represents
|
||||||
* the protocol name “MQTT”, capitalized as shown. The string,
|
* the protocol name "MQTT", capitalized as shown. The string,
|
||||||
* its offset and length will not be changed by future versions
|
* its offset and length will not be changed by future versions
|
||||||
* of the MQTT specification.
|
* of the MQTT specification.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ public class BBCodeParser {
|
||||||
* Registers a new BBCode to the parser. Only one type of BBCode allowed.
|
* Registers a new BBCode to the parser. Only one type of BBCode allowed.
|
||||||
*
|
*
|
||||||
* @param bbcode is the BBCode e.g. "b" or "url"
|
* @param bbcode is the BBCode e.g. "b" or "url"
|
||||||
* @param html is the corresponding HTML e.g. "<a href='%1'>%2</a>"
|
* @param html is the corresponding HTML e.g. {@code <a href='%1'>%2</a>}
|
||||||
* where the %x corresponds to BBCode like this: [url=%1]%2[/url]
|
* where the %x corresponds to BBCode like this: [url=%1]%2[/url]
|
||||||
*/
|
*/
|
||||||
public void addBBCode(String bbcode, String html){
|
public void addBBCode(String bbcode, String html){
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ import java.util.logging.Logger;
|
||||||
* Class for generating dynamic text/code from set data.
|
* Class for generating dynamic text/code from set data.
|
||||||
* The syntax is similar to the javascript mustache library.
|
* The syntax is similar to the javascript mustache library.
|
||||||
*
|
*
|
||||||
* <br /><br />
|
* <p><br>
|
||||||
* Supported tags:
|
* Supported tags:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li><b> {{key}} </b><br>
|
* <li><b> {{key}} </b><br>
|
||||||
|
|
|
||||||
|
|
@ -47,15 +47,15 @@ import java.util.logging.Logger;
|
||||||
* object the {@link Configurator#setValues(DataNode)} or {@link Configurator#setValues(Map)}
|
* object the {@link Configurator#setValues(DataNode)} or {@link Configurator#setValues(Map)}
|
||||||
* can be used to set the individual fields and finally call {@link Configurator#applyConfiguration()}
|
* can be used to set the individual fields and finally call {@link Configurator#applyConfiguration()}
|
||||||
* to configure the target object.
|
* to configure the target object.
|
||||||
* <br />
|
* <p>
|
||||||
* External listener can be registered to be called before or after configuration changes
|
* External listener can be registered to be called before or after configuration changes
|
||||||
* by implementing {@link PreConfigurationActionListener} or {@link PostConfigurationActionListener}.
|
* by implementing {@link PreConfigurationActionListener} or {@link PostConfigurationActionListener}.
|
||||||
* The configured object will autmatically be registered as a listener if it also implements
|
* The configured object will autmatically be registered as a listener if it also implements
|
||||||
* these interfaces.
|
* these interfaces.
|
||||||
*
|
*
|
||||||
* <br>
|
* <p>
|
||||||
* Supported field types: String, int, boolean, enum
|
* Supported field types: String, int, boolean, enum
|
||||||
* <br>
|
* <p>
|
||||||
* Created by Ziver
|
* Created by Ziver
|
||||||
*/
|
*/
|
||||||
public class Configurator<T> {
|
public class Configurator<T> {
|
||||||
|
|
|
||||||
|
|
@ -1,53 +0,0 @@
|
||||||
/*
|
|
||||||
* The MIT License (MIT)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2015 Ziver Koc
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package zutil.log.net;
|
|
||||||
|
|
||||||
import zutil.log.LogUtil;
|
|
||||||
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
|
|
||||||
public class NetLogServerTest {
|
|
||||||
private static final Logger logger = LogUtil.getLogger();
|
|
||||||
|
|
||||||
public static void main(String[] args){
|
|
||||||
LogUtil.setGlobalLevel(Level.FINEST);
|
|
||||||
LogUtil.addGlobalHandler(new NetLogServer(5050));
|
|
||||||
|
|
||||||
while(true){
|
|
||||||
logger.log(Level.SEVERE, "Test Severe");
|
|
||||||
logger.log(Level.WARNING, "Test Warning");
|
|
||||||
logger.log(Level.INFO, "Test Info");
|
|
||||||
logger.log(Level.FINE, "Test Fine");
|
|
||||||
logger.log(Level.FINER, "Test Finer");
|
|
||||||
logger.log(Level.FINEST, "Test Finest");
|
|
||||||
|
|
||||||
logger.log(Level.SEVERE, "Test Exception", new Exception("Test"));
|
|
||||||
|
|
||||||
try{Thread.sleep(3000);}catch(Exception e){}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -56,7 +56,7 @@ public class URLDecoderTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void percentMultibyteTest() throws UnsupportedEncodingException {
|
public void percentMultibyteTest() throws UnsupportedEncodingException {
|
||||||
assertEquals("Ängen", java.net.URLDecoder.decode("%C3%84ngen", "UTF-8"));
|
assertEquals("Ängen", java.net.URLDecoder.decode("%C3%84ngen", "UTF-8"));
|
||||||
assertEquals("Ängen", URLDecoder.decode("%C3%84ngen"));
|
assertEquals("Ängen", URLDecoder.decode("%C3%84ngen"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue