diff --git a/corant-boms/pom.xml b/corant-boms/pom.xml index 50c098861..be428e967 100644 --- a/corant-boms/pom.xml +++ b/corant-boms/pom.xml @@ -68,7 +68,7 @@ 0.9.1 2.6.1 67.1 - 2.13.3 + 2.13.4 2.4.2.Final 6.10.0 11.0.2 @@ -104,7 +104,7 @@ 6.0.1 1.3.72 5.1.1 - 2.18.0 + 2.19.0 1.18.16 5.1.2 3.8.0 @@ -683,13 +683,6 @@ ${version.jakarta.activation-api} provided - - org.openjfx - javafx - ${version.javafx} - pom - import - org.openjfx javafx-base diff --git a/corant-context/src/main/java/org/corant/context/service/ConversionService.java b/corant-context/src/main/java/org/corant/context/service/ConversionService.java index 5752377b7..4a07ed2a9 100644 --- a/corant-context/src/main/java/org/corant/context/service/ConversionService.java +++ b/corant-context/src/main/java/org/corant/context/service/ConversionService.java @@ -61,7 +61,7 @@ public , T> C convert(Object value, Class collectionC @Override public , T> C convert(Object value, Class clazz, IntFunction collectionFactory, Object... hints) { - return Conversion.convert(value, clazz, collectionFactory, mapOf(hints)); + return Conversion.convert(value, clazz, collectionFactory, mapOf(hints), false); } @Override diff --git a/corant-devops/corant-devops-maven/corant-devops-maven-plugin/src/main/java/org/corant/devops/maven/plugin/packaging/DistPackager.java b/corant-devops/corant-devops-maven/corant-devops-maven-plugin/src/main/java/org/corant/devops/maven/plugin/packaging/DistPackager.java index 037ddc01c..34db260b5 100644 --- a/corant-devops/corant-devops-maven/corant-devops-maven-plugin/src/main/java/org/corant/devops/maven/plugin/packaging/DistPackager.java +++ b/corant-devops/corant-devops-maven/corant-devops-maven-plugin/src/main/java/org/corant/devops/maven/plugin/packaging/DistPackager.java @@ -52,9 +52,11 @@ public class DistPackager implements Packager { public static final String JVM_OPT = "jvm.options"; public static final String RUN_BAT = "run.bat"; + public static final String RUNW_BAT = "runw.bat"; public static final String LAUNCH_BATS = "startup.bat,start.bat,stop.bat,restart.bat,shutdown.bat"; public static final String RUN_SH = "run.sh"; + public static final String RUNW_SH = "runw.sh"; public static final String LAUNCH_SHS = "startup.sh,start.sh,stop.sh,restart.sh,shutdown.sh"; public static final String RUN_APP_NAME_PH = "#APPLICATION_NAME#"; public static final String RUN_APP_ARGS = "#APPLICATION_ARGUMENTS#"; @@ -62,6 +64,7 @@ public class DistPackager implements Packager { public static final String RUN_USED_CONFIG_LOCATION = "#USED_CONFIG_LOCATION#"; public static final String RUN_USED_CONFIG_PROFILE = "#USED_CONFIG_PROFILE#"; public static final String RUN_ADD_VM_ARGS = "#ADDITIONAL_VM_ARGUMENTS#"; + public static final String RUN_MODULE_ARGS = "#MODULE_ARGUMENTS#"; public static final String DIST_NAME_SUF = "-dist"; @@ -150,8 +153,13 @@ Archive buildArchive() throws IOException { List resolveBinFiles() throws IOException { List entries = new ArrayList<>(); - entries.add(resolveRunbat()); - entries.add(resolveRunsh()); + if (getMojo().isUseJavaw()) { + entries.add(resolveRunbat(RUNW_BAT)); + entries.add(resolveRunsh(RUNW_SH)); + } else { + entries.add(resolveRunbat(RUN_BAT)); + entries.add(resolveRunsh(RUN_SH)); + } entries.addAll(resolveLaunchs()); return entries; } @@ -176,12 +184,12 @@ List resolveConfigFiles() { List resolveLaunchs() throws IOException { List entries = new ArrayList<>(); - if (getMojo().isUseDirectRunner()) { + if (getMojo().isUseDirectRunner() && !getMojo().isUseJavaw()) { String[] bats = LAUNCH_BATS.split(","); String applicationName = resolveApplicationName(); for (String bat : bats) { String runbat = IOUtils.toString(ClassPathEntry.of(bat, bat).getInputStream(), CHARSET); - final String usebat = runbat.replaceAll(RUN_APP_NAME_PH, applicationName); + final String usebat = runbat.replace(RUN_APP_NAME_PH, applicationName); log.debug(String.format("(corant) resolve launch file %s.", bat)); entries.add(new ScriptEntry(bat, usebat)); } @@ -212,34 +220,36 @@ List resolveRootResources() throws IOException { return entries; } - Entry resolveRunbat() throws IOException { - String runbat = IOUtils.toString(ClassPathEntry.of(RUN_BAT, RUN_BAT).getInputStream(), CHARSET); + Entry resolveRunbat(String run_bat) throws IOException { + String runbat = IOUtils.toString(ClassPathEntry.of(run_bat, run_bat).getInputStream(), CHARSET); String applicationName = resolveApplicationName(); - final String usebat = runbat.replaceAll(RUN_MAIN_CLASS_PH, getMojo().getMainClass()) - .replaceAll(RUN_APP_NAME_PH, applicationName) - .replaceAll(RUN_USED_CONFIG_LOCATION, getMojo().getUsedConfigLocation()) - .replaceAll(RUN_USED_CONFIG_PROFILE, getMojo().getUsedConfigProfile()) - .replaceAll(RUN_APP_ARGS, + final String usebat = runbat.replace(RUN_MAIN_CLASS_PH, getMojo().getMainClass()) + .replace(RUN_APP_NAME_PH, applicationName) + .replace(RUN_USED_CONFIG_LOCATION, getMojo().getUsedConfigLocation()) + .replace(RUN_USED_CONFIG_PROFILE, getMojo().getUsedConfigProfile()) + .replace(RUN_APP_ARGS, getMojo().isUseDirectRunner() ? getMojo().getAppArgs().isEmpty() ? getMojo().getAppArgs().concat("%1") : getMojo().getAppArgs().concat(" %1") : getMojo().getAppArgs()) - .replaceAll(RUN_ADD_VM_ARGS, getMojo().getVmArgs()); - log.debug(String.format("(corant) resolve run command file %s.", RUN_BAT)); - return new ScriptEntry(RUN_BAT, usebat); + .replace(RUN_ADD_VM_ARGS, getMojo().getVmArgs()) + .replace(RUN_MODULE_ARGS, getMojo().getMiArgs()); + log.debug(String.format("(corant) resolve run command file %s.", run_bat)); + return new ScriptEntry(run_bat, usebat); } - Entry resolveRunsh() throws IOException { - String runsh = IOUtils.toString(ClassPathEntry.of(RUN_SH, RUN_SH).getInputStream(), CHARSET); + Entry resolveRunsh(String run_sh) throws IOException { + String runsh = IOUtils.toString(ClassPathEntry.of(run_sh, run_sh).getInputStream(), CHARSET); String applicationName = resolveApplicationName(); - final String usesh = runsh.replaceAll(RUN_MAIN_CLASS_PH, getMojo().getMainClass()) - .replaceAll(RUN_APP_NAME_PH, resolveRunshVar(applicationName)) - .replaceAll(RUN_USED_CONFIG_LOCATION, resolveRunshVar(getMojo().getUsedConfigLocation())) - .replaceAll(RUN_USED_CONFIG_PROFILE, resolveRunshVar(getMojo().getUsedConfigProfile())) - .replaceAll(RUN_APP_ARGS, resolveRunshVar(getMojo().getAppArgs())) - .replaceAll(RUN_ADD_VM_ARGS, resolveRunshVar(getMojo().getVmArgs())); - log.debug(String.format("(corant) resolve run command file %s.", RUN_SH)); - return new ScriptEntry(RUN_SH, usesh); + final String usesh = runsh.replace(RUN_MAIN_CLASS_PH, getMojo().getMainClass()) + .replace(RUN_APP_NAME_PH, resolveRunshVar(applicationName)) + .replace(RUN_USED_CONFIG_LOCATION, resolveRunshVar(getMojo().getUsedConfigLocation())) + .replace(RUN_USED_CONFIG_PROFILE, resolveRunshVar(getMojo().getUsedConfigProfile())) + .replace(RUN_APP_ARGS, resolveRunshVar(getMojo().getAppArgs())) + .replace(RUN_ADD_VM_ARGS, resolveRunshVar(getMojo().getVmArgs())) + .replace(RUN_MODULE_ARGS, getMojo().getMiArgs()); + log.debug(String.format("(corant) resolve run command file %s.", run_sh)); + return new ScriptEntry(run_sh, usesh); } private void packArchiveEntry(ArchiveOutputStream aos, Archive archive, Entry entry) diff --git a/corant-devops/corant-devops-maven/corant-devops-maven-plugin/src/main/java/org/corant/devops/maven/plugin/packaging/PackageMojo.java b/corant-devops/corant-devops-maven/corant-devops-maven-plugin/src/main/java/org/corant/devops/maven/plugin/packaging/PackageMojo.java index 36ed1c39b..ee6acbee5 100644 --- a/corant-devops/corant-devops-maven/corant-devops-maven-plugin/src/main/java/org/corant/devops/maven/plugin/packaging/PackageMojo.java +++ b/corant-devops/corant-devops-maven/corant-devops-maven-plugin/src/main/java/org/corant/devops/maven/plugin/packaging/PackageMojo.java @@ -61,6 +61,9 @@ public class PackageMojo extends AbstractMojo { @Parameter(defaultValue = "false", property = "corant.maven-mojo.with-dist") protected boolean withDist; + @Parameter(defaultValue = "false", property = "corant.maven-mojo.use-javaw") + protected boolean useJavaw; + @Parameter(defaultValue = "zip", property = "corant.maven-mojo.dist-format") protected String distFormat; @@ -70,6 +73,9 @@ public class PackageMojo extends AbstractMojo { @Parameter(property = "corant.maven-mojo.main-class") protected String mainClass; + @Parameter + protected String miArgs; + @Parameter protected String vmArgs; @@ -149,6 +155,13 @@ public String getMainClass() { : mainClass; } + /** + * Returns the module info arguments + */ + public String getMiArgs() { + return miArgs != null && !miArgs.isEmpty() ? miArgs.trim().replace('\n', ' ') : ""; + } + public MavenProject getProject() { return project; } @@ -173,6 +186,10 @@ public boolean isUseDirectRunner() { return useDirectRunner; } + public boolean isUseJavaw() { + return useJavaw; + } + public boolean isWar() { return project.getPackaging().equals("war"); } diff --git a/corant-devops/corant-devops-maven/corant-devops-maven-plugin/src/main/java/org/corant/devops/maven/plugin/packaging/Packager.java b/corant-devops/corant-devops-maven/corant-devops-maven-plugin/src/main/java/org/corant/devops/maven/plugin/packaging/Packager.java index 6002f527a..0af83cb6b 100644 --- a/corant-devops/corant-devops-maven/corant-devops-maven-plugin/src/main/java/org/corant/devops/maven/plugin/packaging/Packager.java +++ b/corant-devops/corant-devops-maven/corant-devops-maven-plugin/src/main/java/org/corant/devops/maven/plugin/packaging/Packager.java @@ -38,6 +38,7 @@ public interface Packager { String CFG_DIR = "cfg"; String BIN_DIR = "bin"; String LOG_DIR = "log"; + String JFX_DIR = "jfx"; Attributes.Name FW_VER_KEY = new Attributes.Name("Corant-Kernel-Version"); diff --git a/corant-devops/corant-devops-maven/corant-devops-maven-plugin/src/main/resources/run.bat b/corant-devops/corant-devops-maven/corant-devops-maven-plugin/src/main/resources/run.bat index 51d4080e1..67b5e97e6 100644 --- a/corant-devops/corant-devops-maven/corant-devops-maven-plugin/src/main/resources/run.bat +++ b/corant-devops/corant-devops-maven/corant-devops-maven-plugin/src/main/resources/run.bat @@ -8,6 +8,7 @@ set MAIN_CLASS=#MAIN_CLASS# set USED_CONFIG_LOCATION=#USED_CONFIG_LOCATION# set USED_CONFIG_PROFILE=#USED_CONFIG_PROFILE# set ADDITIONAL_VM_ARGUMENTS=#ADDITIONAL_VM_ARGUMENTS# +set MODULE_ARGUMENTS=#MODULE_ARGUMENTS# set APPLICATION_ARGUMENTS=#APPLICATION_ARGUMENTS# set APPLICATION_NAME=#APPLICATION_NAME# @@ -54,8 +55,6 @@ rem such options are the lines beginning with '-', thus "findstr /b" for /F "usebackq delims=" %%a in (`findstr /b \- "%CFG_JVM_OPTS%"`) do set JVM_OPTIONS=!JVM_OPTIONS! %%a @endlocal & set CORANT_JVM_OPTS=%JVM_OPTIONS% %CORANT_JVM_OPTS% -set CORANT_JVM_OPTS=%CORANT_JVM_OPTS% -classpath "%CLASS_PATH%" - if "%USED_CONFIG_LOCATION%" == "" set USED_CONFIG_LOCATION=filesystem:%CFG_DIR% set CORANT_JVM_OPTS=%CORANT_JVM_OPTS% -Dcorant.config.location="%USED_CONFIG_LOCATION%" @@ -66,11 +65,11 @@ if NOT "%APPLICATION_NAME%" == "" set CORANT_JVM_OPTS=%CORANT_JVM_OPTS% -Dcorant if exist "%LCF_URL%" set CORANT_JVM_OPTS=%CORANT_JVM_OPTS% -Dlog4j.configurationFile="%LCF_URL%" -set CORANT_JVM_OPTS=%CORANT_JVM_OPTS% -Dcorant.application.root-dir=filesystem:"%ROOT_DIR%" +set CORANT_JVM_OPTS=%CORANT_JVM_OPTS% -Dcorant.application.root-dir=filesystem:"%ROOT_DIR%" -classpath "%CLASS_PATH%" -if NOT "%DEBUG_ARGS%"=="" set JVM_ARGS=%JVM_ARGS% %DEBUG_ARGS% +if NOT "%DEBUG_ARGS%"=="" set CORANT_JVM_OPTS=%CORANT_JVM_OPTS% %DEBUG_ARGS% -"%_JAVACMD%" %CORANT_JVM_OPTS% %MAIN_CLASS% %APPLICATION_ARGUMENTS% +"%_JAVACMD%" %CORANT_JVM_OPTS% %MODULE_ARGUMENTS% %MAIN_CLASS% %APPLICATION_ARGUMENTS% endlocal GOTO :EOF diff --git a/corant-devops/corant-devops-maven/corant-devops-maven-plugin/src/main/resources/runw.bat b/corant-devops/corant-devops-maven/corant-devops-maven-plugin/src/main/resources/runw.bat new file mode 100644 index 000000000..5be179ba8 --- /dev/null +++ b/corant-devops/corant-devops-maven/corant-devops-maven-plugin/src/main/resources/runw.bat @@ -0,0 +1,77 @@ +@echo off + +setlocal enabledelayedexpansion + +TITLE #APPLICATION_NAME# + +set MAIN_CLASS=#MAIN_CLASS# +set USED_CONFIG_LOCATION=#USED_CONFIG_LOCATION# +set USED_CONFIG_PROFILE=#USED_CONFIG_PROFILE# +set ADDITIONAL_VM_ARGUMENTS=#ADDITIONAL_VM_ARGUMENTS# +set MODULE_ARGUMENTS=#MODULE_ARGUMENTS# +set APPLICATION_ARGUMENTS=#APPLICATION_ARGUMENTS# +set APPLICATION_NAME=#APPLICATION_NAME# + + +if "%OS%" == "Windows_NT" ( + set "DIR_PATH=%~dp0%" +) else ( + set DIR_PATH=.\ +) + +pushd "%DIR_PATH%.." +set "ROOT_DIR=%CD%" +popd + +set LIB_DIR=%ROOT_DIR%\lib +set APP_DIR=%ROOT_DIR%\app +set CFG_DIR=%ROOT_DIR%\cfg +set LCF_URL=%CFG_DIR%\log4j2.xml + +set CLASS_PATH=%CFG_DIR%\*;%APP_DIR%\*;%LIB_DIR%\* + +set _JAVACMD=%JAVACMD% + +if "%JAVA_HOME%" == "" goto NO_JAVA_HOME +if not exist "%JAVA_HOME%\bin\javaw.exe" goto NO_JAVA_HOME +if "%_JAVACMD%" == "" set _JAVACMD=start "%JAVA_HOME%\bin\" javaw +goto RUN_JAVA + +:NO_JAVA_HOME +if "%_JAVACMD%" == "" set _JAVACMD=start javaw +echo. +echo Warning: JAVA_HOME environment variable is not set. +echo. + +:RUN_JAVA + +set "CFG_JVM_OPTS=%~dp0\..\cfg\jvm.options" +set CORANT_JVM_OPTS= +if NOT "%ADDITIONAL_VM_ARGUMENTS%" == "" set CORANT_JVM_OPTS=%CORANT_JVM_OPTS% %ADDITIONAL_VM_ARGUMENTS% + +@setlocal +rem extract the options from the JVM options file %CFG_JVM_OPTS% +rem such options are the lines beginning with '-', thus "findstr /b" +for /F "usebackq delims=" %%a in (`findstr /b \- "%CFG_JVM_OPTS%"`) do set JVM_OPTIONS=!JVM_OPTIONS! %%a +@endlocal & set CORANT_JVM_OPTS=%JVM_OPTIONS% %CORANT_JVM_OPTS% + +if "%USED_CONFIG_LOCATION%" == "" set USED_CONFIG_LOCATION=filesystem:%CFG_DIR% + +set CORANT_JVM_OPTS=%CORANT_JVM_OPTS% -Dcorant.config.location="%USED_CONFIG_LOCATION%" + +if NOT "%USED_CONFIG_PROFILE%" == "" set CORANT_JVM_OPTS=%CORANT_JVM_OPTS% -Dcorant.config.profile="%USED_CONFIG_PROFILE%" + +if NOT "%APPLICATION_NAME%" == "" set CORANT_JVM_OPTS=%CORANT_JVM_OPTS% -Dcorant.application-name="%APPLICATION_NAME%" + +if exist "%LCF_URL%" set CORANT_JVM_OPTS=%CORANT_JVM_OPTS% -Dlog4j.configurationFile="%LCF_URL%" + +set CORANT_JVM_OPTS=%CORANT_JVM_OPTS% -Dcorant.application.root-dir=filesystem:"%ROOT_DIR%" -classpath "%CLASS_PATH%" + +if NOT "%DEBUG_ARGS%"=="" set CORANT_JVM_OPTS=%CORANT_JVM_OPTS% %DEBUG_ARGS% + +%_JAVACMD% %CORANT_JVM_OPTS% %MODULE_ARGUMENTS% %MAIN_CLASS% %APPLICATION_ARGUMENTS% + +endlocal +GOTO :EOF + +:EOF \ No newline at end of file diff --git a/corant-devops/corant-devops-maven/corant-devops-maven-plugin/src/main/resources/runw.sh b/corant-devops/corant-devops-maven/corant-devops-maven-plugin/src/main/resources/runw.sh new file mode 100644 index 000000000..e515c0a45 --- /dev/null +++ b/corant-devops/corant-devops-maven/corant-devops-maven-plugin/src/main/resources/runw.sh @@ -0,0 +1,22 @@ +# !/bin/sh +MAIN_CLASS=#MAIN_CLASS# +ADDITIONAL_VM_ARGUMENTS=#ADDITIONAL_VM_ARGUMENTS# +MODULE_ARGUMENTS=#MODULE_ARGUMENTS# +APPLICATION_NAME=#APPLICATION_NAME# + +BIN_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +ROOT_DIR=$(cd $BIN_DIR/.. && pwd) + +CLASSPATH="$ROOT_DIR/lib/*:$ROOT_DIR/app/*" + +JAVA="javaw " + +CORANT_JVM_OPTS="$ADDITIONAL_VM_ARGUMENTS -cp $CLASSPATH" + +if test -n "$APPLICATION_NAME" +then + CORANT_JVM_OPTS="$CORANT_JVM_OPTS -Dcorant.application-name=$APPLICATION_NAME" +fi + +exec $JAVA $CORANT_JVM_OPTS $* $MODULE_ARGUMENTS $MAIN_CLASS diff --git a/corant-devops/corant-devops-test/corant-devops-test-unit/src/main/java/org/corant/devops/test/unit/web/RandomWebServerPortSourceProvider.java b/corant-devops/corant-devops-test/corant-devops-test-unit/src/main/java/org/corant/devops/test/unit/web/RandomWebServerPortSourceProvider.java index 3a609a4c8..be65042cb 100644 --- a/corant-devops/corant-devops-test/corant-devops-test-unit/src/main/java/org/corant/devops/test/unit/web/RandomWebServerPortSourceProvider.java +++ b/corant-devops/corant-devops-test/corant-devops-test-unit/src/main/java/org/corant/devops/test/unit/web/RandomWebServerPortSourceProvider.java @@ -34,7 +34,11 @@ public class RandomWebServerPortSourceProvider implements ConfigSourceProvider { @Override public Iterable getConfigSources(ClassLoader forClassLoader) { - return Collections.singleton(TEST_WSPORT_CFGSRC); + if (CorantJunit4Runner.ENA_RDM_WEB_PORTS.get()) { + return Collections.singleton(TEST_WSPORT_CFGSRC); + } else { + return Collections.emptyList(); + } } public static class RandomWebServerPortConfigSource implements ConfigSource { @@ -55,11 +59,7 @@ public String getName() { @Override public int getOrdinal() { - if (CorantJunit4Runner.ENA_RDM_WEB_PORTS.get()) { - return Integer.MAX_VALUE; - } else { - return Integer.MIN_VALUE; - } + return Integer.MAX_VALUE; } @Override diff --git a/corant-modules/corant-modules-aicv/corant-modules-aicv-yolo/pom.xml b/corant-modules/corant-modules-aicv/corant-modules-aicv-yolo/pom.xml index a7ba72b42..67066fd9a 100644 --- a/corant-modules/corant-modules-aicv/corant-modules-aicv-yolo/pom.xml +++ b/corant-modules/corant-modules-aicv/corant-modules-aicv-yolo/pom.xml @@ -25,5 +25,9 @@ org.corant corant-shared + + org.openjfx + javafx-controls + \ No newline at end of file diff --git a/corant-modules/corant-modules-aicv/corant-modules-aicv-yolo/src/main/java/org/corant/modules/aicv/yolo/TestJfx.java b/corant-modules/corant-modules-aicv/corant-modules-aicv-yolo/src/main/java/org/corant/modules/aicv/yolo/TestJfx.java new file mode 100644 index 000000000..b46decee8 --- /dev/null +++ b/corant-modules/corant-modules-aicv/corant-modules-aicv-yolo/src/main/java/org/corant/modules/aicv/yolo/TestJfx.java @@ -0,0 +1,199 @@ +/* + * Copyright (c) 2013-2021, Bingo.Chen (finesoft@gmail.com). + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package org.corant.modules.aicv.yolo; + +import static org.corant.shared.util.Empties.isNotEmpty; +import java.io.ByteArrayInputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; +import org.corant.kernel.logging.LoggerFactory; +import org.corant.shared.util.Threads; +import org.opencv.core.Core; +import org.opencv.core.Mat; +import org.opencv.core.MatOfByte; +import org.opencv.core.MatOfFloat; +import org.opencv.core.MatOfInt; +import org.opencv.core.MatOfRect; +import org.opencv.core.Point; +import org.opencv.core.Rect; +import org.opencv.core.Scalar; +import org.opencv.core.Size; +import org.opencv.dnn.Dnn; +import org.opencv.dnn.Net; +import org.opencv.imgcodecs.Imgcodecs; +import org.opencv.imgproc.Imgproc; +import org.opencv.videoio.VideoCapture; +import com.carrotsearch.hppc.FloatArrayList; +import com.carrotsearch.hppc.IntArrayList; +import javafx.application.Application; +import javafx.application.Platform; +import javafx.scene.Scene; +import javafx.scene.canvas.Canvas; +import javafx.scene.canvas.GraphicsContext; +import javafx.scene.image.Image; +import javafx.scene.layout.Pane; +import javafx.stage.Stage; +import nu.pattern.OpenCV; + +/** + * corant-modules-aicv-yolo + * + * @author bingo 下午4:28:09 + * + */ +public class TestJfx extends Application { + + static { + LoggerFactory.disableAccessWarnings(); + } + + GraphicsContext gc; + + public static void main(String... args) { + launch(args); + } + + @Override + public void start(Stage stage) throws Exception { + // Create the Canvas + Canvas canvas = new Canvas(1024, 768); + // Set the width of the Canvas + // canvas.setWidth(640); + // Set the height of the Canvas + // canvas.setHeight(480); + + // Get the graphics context of the canvas + gc = canvas.getGraphicsContext2D(); + + // Draw a Text + // gc.strokeText("Hello Canvas", 150, 100); + + // Create the Pane + Pane root = new Pane(); + // Set the Style-properties of the Pane + // root.setStyle("-fx-padding: 10;" + "-fx-border-style: solid inside;" + "-fx-border-width: 2;" + // + "-fx-border-insets: 5;" + "-fx-border-radius: 5;" + "-fx-border-color: blue;"); + + // Add the Canvas to the Pane + root.getChildren().add(canvas); + // Create the Scene + Scene scene = new Scene(root); + // Add the Scene to the Stage + stage.setScene(scene); + // Set the Title of the Stage + stage.setTitle("Creation of a Canvas"); + // Display the Stage + stage.show(); + Threads.runInDaemon(this::doStart); + } + + protected void doStart() { + OpenCV.loadShared(); + String modelWeights = "E:/IDE/ai-model-repo/vehicles/yolov3.weights"; + String modelConfiguration = "E:/IDE/ai-model-repo/vehicles/yolov3.cfg"; + String filePath = "D:/shared/VID_20211217_210759.mp4"; + + AtomicBoolean running = new AtomicBoolean(true); + // JFrame jframe = new JFrame("Video"); + // JLabel vidpanel = new JLabel(); + // jframe.setContentPane(vidpanel); + // jframe.setVisible(true); + // jframe.setExtendedState(Frame.MAXIMIZED_BOTH); + // jframe.addWindowListener(new java.awt.event.WindowAdapter() { + // @Override + // public void windowClosing(java.awt.event.WindowEvent e) { + // e.getWindow().dispose(); + // running.set(false); + // } + // }); + Net net = Dnn.readNetFromDarknet(modelConfiguration, modelWeights); + net.setPreferableBackend(3); + net.setPreferableTarget(0); + Size sz = new Size(416, 416); + List result = new ArrayList<>(); + List outBlobNames = Nets.getOutputNames(net); + + VideoCapture cap = new VideoCapture(filePath); + Mat frame = new Mat(); + begin: while (running.get()) { + if (running.get() && cap.read(frame)) { + Mat blob = Dnn.blobFromImage(frame, 1 / 255.0, sz, new Scalar(0), true, false); + net.setInput(blob); + for (String name : outBlobNames) { + if (!running.get()) { + break begin; + } + net.forward(result, name); + float confThreshold = 0.6f; + IntArrayList clsIds = new IntArrayList(); + FloatArrayList confs = new FloatArrayList(); + List rects = new ArrayList<>(); + for (int i = 0; i < result.size(); ++i) { + Mat level = result.get(i); + for (int j = 0; j < level.rows(); ++j) { + if (!running.get()) { + break begin; + } + Mat row = level.row(j); + Mat scores = row.colRange(5, level.cols()); + Core.MinMaxLocResult mm = Core.minMaxLoc(scores); + float confidence = (float) mm.maxVal; + Point classIdPoint = mm.maxLoc; + if (confidence > confThreshold) { + int centerX = (int) (row.get(0, 0)[0] * frame.cols()); + int centerY = (int) (row.get(0, 1)[0] * frame.rows()); + int width = (int) (row.get(0, 2)[0] * frame.cols()); + int height = (int) (row.get(0, 3)[0] * frame.rows()); + int left = centerX - width / 2; + int top = centerY - height / 2; + clsIds.add((int) classIdPoint.x); + confs.add(confidence); + rects.add(new Rect(left, top, width, height)); + } + } + } + if (isNotEmpty(confs)) { + float nmsThresh = 0.5f; + MatOfFloat confidences = new MatOfFloat(Mats.from(confs)); + Rect[] boxesArray = rects.toArray(new Rect[0]); + MatOfRect boxes = new MatOfRect(boxesArray); + MatOfInt indices = new MatOfInt(); + Dnn.NMSBoxes(boxes, confidences, confThreshold, nmsThresh, indices); + int[] ind = indices.toArray(); + for (int idx : ind) { + Rect box = boxesArray[idx]; + Imgproc.rectangle(frame, box.tl(), box.br(), new Scalar(0, 0, 255), 2); + } + } + } + if (gc != null && running.get()) { + try { + Platform.runLater(() -> { + MatOfByte bytemat = new MatOfByte(); + Imgcodecs.imencode(".bmp", frame, bytemat); + // byte[] bytes = bytemat.toArray(); + Image image = new Image(new ByteArrayInputStream(bytemat.toArray())); + gc.drawImage(image, 0, 0); + }); + // vidpanel.setGraphic(new ImageView(image)); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + } + +} diff --git a/corant-modules/corant-modules-datasource/corant-modules-datasource-shared/src/main/java/org/corant/modules/datasource/shared/JDBCTemplate.java b/corant-modules/corant-modules-datasource/corant-modules-datasource-shared/src/main/java/org/corant/modules/datasource/shared/JDBCTemplate.java index 41bae8539..15afeb076 100644 --- a/corant-modules/corant-modules-datasource/corant-modules-datasource-shared/src/main/java/org/corant/modules/datasource/shared/JDBCTemplate.java +++ b/corant-modules/corant-modules-datasource/corant-modules-datasource-shared/src/main/java/org/corant/modules/datasource/shared/JDBCTemplate.java @@ -122,15 +122,32 @@ public static JDBCTemplate build(DataSource ds) { return new JDBCTemplate(ds); } + public static int execute(Connection conn, String sql, Map namedParams) + throws SQLException { + Pair sqlAndParams = SqlStatements.normalize(sql, namedParams); + return SIMPLE_RUNNER.execute(conn, sqlAndParams.getKey(), sqlAndParams.getValue()); + } + public static int execute(Connection conn, String sql, Object... params) throws SQLException { - Pair processeds = SqlStatements.normalize(sql, params); - return SIMPLE_RUNNER.execute(conn, processeds.getKey(), processeds.getValue()); + Pair sqlAndParams = SqlStatements.normalize(sql, params); + return SIMPLE_RUNNER.execute(conn, sqlAndParams.getKey(), sqlAndParams.getValue()); + } + + public static List execute(Connection conn, String sql, ResultSetHandler rsh, + Map namedParams) throws SQLException { + Pair sqlAndParams = SqlStatements.normalize(sql, namedParams); + return SIMPLE_RUNNER.execute(conn, sqlAndParams.getKey(), rsh, sqlAndParams.getValue()); } public static List execute(Connection conn, String sql, ResultSetHandler rsh, Object... params) throws SQLException { - Pair processeds = SqlStatements.normalize(sql, params); - return SIMPLE_RUNNER.execute(conn, processeds.getKey(), rsh, processeds.getValue()); + Pair sqlAndParams = SqlStatements.normalize(sql, params); + return SIMPLE_RUNNER.execute(conn, sqlAndParams.getKey(), rsh, sqlAndParams.getValue()); + } + + public static List>> executes(Connection conn, String sql, + Map namedParams) throws SQLException { + return execute(conn, sql, MAP_LIST_HANDLER, namedParams); } public static List>> executes(Connection conn, String sql, @@ -138,20 +155,36 @@ public static List>> executes(Connection conn, String s return execute(conn, sql, MAP_LIST_HANDLER, params); } + public static Map get(Connection conn, String sql, + Map namedParams) throws SQLException { + return query(conn, sql, MAP_HANDLER, namedParams); + } + public static Map get(Connection conn, String sql, Object... params) throws SQLException { return query(conn, sql, MAP_HANDLER, params); } + public static Map insert(Connection conn, String sql, + Map namedParams) throws SQLException { + return insert(conn, sql, MAP_HANDLER, namedParams); + } + public static Map insert(Connection conn, String sql, Object... params) throws SQLException { return insert(conn, sql, MAP_HANDLER, params); } + public static T insert(Connection conn, String sql, ResultSetHandler rsh, + Map namedParams) throws SQLException { + Pair sqlAndParams = SqlStatements.normalize(sql, namedParams); + return SIMPLE_RUNNER.insert(conn, sqlAndParams.getKey(), rsh, sqlAndParams.getValue()); + } + public static T insert(Connection conn, String sql, ResultSetHandler rsh, Object... params) throws SQLException { - Pair processeds = SqlStatements.normalize(sql, params); - return SIMPLE_RUNNER.insert(conn, processeds.getKey(), rsh, processeds.getValue()); + Pair sqlAndParams = SqlStatements.normalize(sql, params); + return SIMPLE_RUNNER.insert(conn, sqlAndParams.getKey(), rsh, sqlAndParams.getValue()); } public static void insertBatch(Connection conn, String sql, int batchSubmitSize, @@ -171,15 +204,26 @@ public static T insertBatch(Connection conn, String sql, ResultSetHandler return SIMPLE_RUNNER.insertBatch(conn, sql, rsh, params); } + public static List> query(Connection conn, String sql, + Map namedParams) throws SQLException { + return query(conn, sql, MAP_LIST_HANDLER, namedParams); + } + public static List> query(Connection conn, String sql, Object... params) throws SQLException { return query(conn, sql, MAP_LIST_HANDLER, params); } + public static T query(Connection conn, String sql, ResultSetHandler rsh, + Map namedParams) throws SQLException { + Pair sqlAndParams = SqlStatements.normalize(sql, namedParams); + return SIMPLE_RUNNER.query(conn, sqlAndParams.getKey(), rsh, sqlAndParams.getValue()); + } + public static T query(Connection conn, String sql, ResultSetHandler rsh, Object... params) throws SQLException { - Pair processeds = SqlStatements.normalize(sql, params); - return SIMPLE_RUNNER.query(conn, processeds.getKey(), rsh, processeds.getValue()); + Pair sqlAndParams = SqlStatements.normalize(sql, params); + return SIMPLE_RUNNER.query(conn, sqlAndParams.getKey(), rsh, sqlAndParams.getValue()); } public static void release(ResultSet rs, PreparedStatement stmt, Connection conn, @@ -361,9 +405,15 @@ public static int tryUpdate(Connection conn, String sql, Object... params) { } } + public static int update(Connection conn, String sql, Map namedParams) + throws SQLException { + Pair sqlAndParams = SqlStatements.normalize(sql, namedParams); + return SIMPLE_RUNNER.update(conn, sqlAndParams.getKey(), sqlAndParams.getValue()); + } + public static int update(Connection conn, String sql, Object... params) throws SQLException { - Pair processeds = SqlStatements.normalize(sql, params); - return SIMPLE_RUNNER.update(conn, processeds.getKey(), processeds.getValue()); + Pair sqlAndParams = SqlStatements.normalize(sql, params); + return SIMPLE_RUNNER.update(conn, sqlAndParams.getKey(), sqlAndParams.getValue()); } @Deprecated @@ -425,14 +475,14 @@ public int[] batch(String sql, Stream> params) throws SQLException { } public int execute(String sql, Object... params) throws SQLException { - Pair processeds = SqlStatements.normalize(sql, params); - return runner.execute(processeds.getKey(), processeds.getValue()); + Pair sqlAndParams = SqlStatements.normalize(sql, params); + return runner.execute(sqlAndParams.getKey(), sqlAndParams.getValue()); } public List execute(String sql, ResultSetHandler rsh, Object... params) throws SQLException { - Pair processeds = SqlStatements.normalize(sql, params); - return runner.execute(processeds.getKey(), rsh, processeds.getValue()); + Pair sqlAndParams = SqlStatements.normalize(sql, params); + return runner.execute(sqlAndParams.getKey(), rsh, sqlAndParams.getValue()); } public List> executes(String sql, Object... params) throws SQLException { @@ -440,8 +490,8 @@ public List> executes(String sql, Object... params) throws S } public Map get(String sql, Object... params) throws SQLException { - Pair processeds = SqlStatements.normalize(sql, params); - return runner.query(processeds.getKey(), MAP_HANDLER, processeds.getValue()); + Pair sqlAndParams = SqlStatements.normalize(sql, params); + return runner.query(sqlAndParams.getKey(), MAP_HANDLER, sqlAndParams.getValue()); } public DataSource getDataSource() { @@ -461,8 +511,8 @@ public Map insert(String sql, Object... params) throws SQLExcept } public T insert(String sql, ResultSetHandler rsh, Object... params) throws SQLException { - Pair processeds = SqlStatements.normalize(sql, params); - return runner.insert(processeds.getKey(), rsh, processeds.getValue()); + Pair sqlAndParams = SqlStatements.normalize(sql, params); + return runner.insert(sqlAndParams.getKey(), rsh, sqlAndParams.getValue()); } public void insertBatch(String sql, int batchSubmitSize, Stream> params, @@ -485,8 +535,8 @@ public List> query(String sql, Object... params) throws SQLE } public T query(String sql, ResultSetHandler rsh, Object... params) throws SQLException { - Pair processeds = SqlStatements.normalize(sql, params); - return runner.query(processeds.getKey(), rsh, processeds.getValue()); + Pair sqlAndParams = SqlStatements.normalize(sql, params); + return runner.query(sqlAndParams.getKey(), rsh, sqlAndParams.getValue()); } /** @@ -498,7 +548,7 @@ public T query(String sql, ResultSetHandler rsh, Object... params) throws *
    * Example: try(Stream stream = stream(s,f,p)){
    *    stream.forEach(row->{
-   *        //do somthing
+   *        //do something
    *    })
    * }
    * 
@@ -523,7 +573,7 @@ public Stream> stream(String sql, Integer fetchSize, Object. *
    * Example: try(Stream stream = stream(s,f,r,p)){
    *    stream.forEach(row->{
-   *        //do somthing
+   *        //do something
    *    })
    * }
    * 
diff --git a/corant-modules/corant-modules-ddd/corant-modules-ddd-shared/src/main/java/org/corant/modules/ddd/shared/message/JMSMessageDispatcher.java b/corant-modules/corant-modules-ddd/corant-modules-ddd-shared/src/main/java/org/corant/modules/ddd/shared/message/JMSMessageDispatcher.java index b25c94454..366d123e6 100644 --- a/corant-modules/corant-modules-ddd/corant-modules-ddd-shared/src/main/java/org/corant/modules/ddd/shared/message/JMSMessageDispatcher.java +++ b/corant-modules/corant-modules-ddd/corant-modules-ddd-shared/src/main/java/org/corant/modules/ddd/shared/message/JMSMessageDispatcher.java @@ -104,7 +104,7 @@ public void send(String broker, boolean multicast, String destination, Map properties, Message message) { JMSContext ctx = obtainJmsContext(broker); final Destination dest = resolveDestination(message, ctx, multicast, destination); - logger.finer(() -> String.format("Resolved JMS message destination %s for domain message %", + logger.finer(() -> String.format("Resolved JMS message destination %s for domain message %s", dest, message.getClass())); final javax.jms.Message jmsMsg = createJMSMessage(ctx, message); if (isNotEmpty(properties)) { diff --git a/corant-modules/corant-modules-javafx/corant-modules-javafx-cdi/pom.xml b/corant-modules/corant-modules-javafx/corant-modules-javafx-cdi/pom.xml index 8418ef30c..5053cb073 100644 --- a/corant-modules/corant-modules-javafx/corant-modules-javafx-cdi/pom.xml +++ b/corant-modules/corant-modules-javafx/corant-modules-javafx-cdi/pom.xml @@ -11,6 +11,10 @@ org.corant corant-context + + org.corant + corant-kernel + org.openjfx javafx-fxml diff --git a/corant-modules/corant-modules-javafx/corant-modules-javafx-cdi/src/main/java/org/corant/modules/javafx/cdi/FXML.java b/corant-modules/corant-modules-javafx/corant-modules-javafx-cdi/src/main/java/org/corant/modules/javafx/cdi/CorantApplicationParametersFactory.java similarity index 63% rename from corant-modules/corant-modules-javafx/corant-modules-javafx-cdi/src/main/java/org/corant/modules/javafx/cdi/FXML.java rename to corant-modules/corant-modules-javafx/corant-modules-javafx-cdi/src/main/java/org/corant/modules/javafx/cdi/CorantApplicationParametersFactory.java index d940c3438..76a736bd0 100644 --- a/corant-modules/corant-modules-javafx/corant-modules-javafx-cdi/src/main/java/org/corant/modules/javafx/cdi/FXML.java +++ b/corant-modules/corant-modules-javafx/corant-modules-javafx-cdi/src/main/java/org/corant/modules/javafx/cdi/CorantApplicationParametersFactory.java @@ -13,26 +13,26 @@ */ package org.corant.modules.javafx.cdi; -import static org.corant.shared.util.Strings.EMPTY; -import javax.enterprise.util.Nonbinding; +import javax.enterprise.inject.Produces; +import javax.inject.Singleton; +import javafx.application.Application.Parameters; /** * corant-modules-javafx-cdi * - * @author bingo 下午11:26:29 + * @author bingo 上午12:21:56 * */ -public @interface FXML { +@Singleton +public class CorantApplicationParametersFactory { - /** - * The name of the resources used to resolve resource key attribute values. - */ - @Nonbinding - String bundle(); + protected volatile Parameters parameters; - /** - * The URL used to resolve relative path attribute values. - */ - @Nonbinding - String url() default EMPTY; + public @Produces Parameters getParameters() { + return parameters; + } + + protected void setParameters(Parameters p) { + this.parameters = p; + } } diff --git a/corant-modules/corant-modules-javafx/corant-modules-javafx-cdi/src/main/java/org/corant/modules/javafx/cdi/CorantFXML.java b/corant-modules/corant-modules-javafx/corant-modules-javafx-cdi/src/main/java/org/corant/modules/javafx/cdi/CorantFXML.java new file mode 100644 index 000000000..2da820769 --- /dev/null +++ b/corant-modules/corant-modules-javafx/corant-modules-javafx-cdi/src/main/java/org/corant/modules/javafx/cdi/CorantFXML.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2013-2021, Bingo.Chen (finesoft@gmail.com). + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package org.corant.modules.javafx.cdi; + +import static org.corant.shared.util.Objects.defaultObject; +import static org.corant.shared.util.Strings.defaultString; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import javax.enterprise.util.AnnotationLiteral; +import javax.enterprise.util.Nonbinding; +import javax.inject.Qualifier; +import org.corant.shared.normal.Defaults; +import org.corant.shared.util.Strings; + +/** + * corant-modules-javafx-cdi + * + * @author bingo 下午11:26:29 + * + */ +@Qualifier +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.TYPE}) +public @interface CorantFXML { + + CorantFXML EMPTY = CorantFXMLLiteral.of(); + + /** + * The name of the resources used to resolve resource key attribute values. + */ + @Nonbinding + String bundle() default Strings.EMPTY; + + /** + * the character set used by FXMLLoader + */ + @Nonbinding + String charset() default Strings.EMPTY; + + /** + * The URL used to resolve relative path attribute values. + */ + @Nonbinding + String url() default Strings.EMPTY; + + class CorantFXMLLiteral extends AnnotationLiteral implements CorantFXML { + + private static final long serialVersionUID = 4686509228865568858L; + + private final String bundle; + private final String url; + private final String charset; + + CorantFXMLLiteral(String bundle, String url, String charset) { + super(); + this.bundle = defaultString(bundle); + this.url = defaultString(url); + this.charset = defaultObject(charset, Defaults.DFLT_CHARSET_STR); + } + + public static CorantFXMLLiteral of() { + return of(null, null, null); + } + + public static CorantFXMLLiteral of(String bundle) { + return of(bundle, null); + } + + public static CorantFXMLLiteral of(String bundle, String url) { + return of(bundle, url, Defaults.DFLT_CHARSET_STR); + } + + public static CorantFXMLLiteral of(String bundle, String url, String charset) { + return new CorantFXMLLiteral(bundle, url, charset); + } + + @Override + public String bundle() { + return bundle; + } + + @Override + public String charset() { + return charset; + } + + @Override + public String url() { + return url; + } + + } +} diff --git a/corant-modules/corant-modules-javafx/corant-modules-javafx-cdi/src/main/java/org/corant/modules/javafx/cdi/FXMLLoaderFactory.java b/corant-modules/corant-modules-javafx/corant-modules-javafx-cdi/src/main/java/org/corant/modules/javafx/cdi/CorantFXMLLoaderFactory.java similarity index 61% rename from corant-modules/corant-modules-javafx/corant-modules-javafx-cdi/src/main/java/org/corant/modules/javafx/cdi/FXMLLoaderFactory.java rename to corant-modules/corant-modules-javafx/corant-modules-javafx-cdi/src/main/java/org/corant/modules/javafx/cdi/CorantFXMLLoaderFactory.java index 44faaedb4..390a19d65 100644 --- a/corant-modules/corant-modules-javafx/corant-modules-javafx-cdi/src/main/java/org/corant/modules/javafx/cdi/FXMLLoaderFactory.java +++ b/corant-modules/corant-modules-javafx/corant-modules-javafx-cdi/src/main/java/org/corant/modules/javafx/cdi/CorantFXMLLoaderFactory.java @@ -17,10 +17,12 @@ import static org.corant.shared.util.Conversions.toObject; import static org.corant.shared.util.Strings.isBlank; import java.net.URL; +import java.nio.charset.Charset; import java.util.ResourceBundle; import javax.enterprise.context.Dependent; import javax.enterprise.inject.Produces; import javax.enterprise.inject.spi.InjectionPoint; +import org.corant.config.Configs; import org.corant.context.Beans; import javafx.fxml.FXMLLoader; import javafx.fxml.JavaFXBuilderFactory; @@ -31,15 +33,21 @@ * @author bingo 下午11:08:06 * */ -public class FXMLLoaderFactory { +public class CorantFXMLLoaderFactory { @Produces @Dependent - public FXMLLoader produce(final InjectionPoint ip) { - final FXML fxml = ip.getAnnotated().getAnnotation(FXML.class); - final URL url = fxml == null || isBlank(fxml.url()) ? null : toObject(fxml.url(), URL.class); - final ResourceBundle bundle = - fxml == null || isBlank(fxml.bundle()) ? null : ResourceBundle.getBundle(fxml.bundle()); - return new FXMLLoader(url, bundle, new JavaFXBuilderFactory(), Beans::resolve, UTF_8); + @CorantFXML + protected FXMLLoader produce(final InjectionPoint ip) { + final CorantFXML fxml = (CorantFXML) ip.getQualifiers().stream() + .filter(q -> q instanceof CorantFXML).findFirst().orElse(null); + final URL url = fxml == null || isBlank(fxml.url()) ? null + : toObject(Configs.assemblyStringConfigProperty(fxml.url()), URL.class); + final ResourceBundle bundle = fxml == null || isBlank(fxml.bundle()) ? null + : ResourceBundle.getBundle(Configs.assemblyStringConfigProperty(fxml.bundle())); + final Charset charset = fxml == null || isBlank(fxml.charset()) ? UTF_8 + : Charset.forName(Configs.assemblyStringConfigProperty(fxml.charset())); + return new FXMLLoader(url, bundle, new JavaFXBuilderFactory(), Beans::resolve, charset); } + } diff --git a/corant-modules/corant-modules-javafx/corant-modules-javafx-cdi/src/main/java/org/corant/modules/javafx/cdi/CorantJavaFXApplication.java b/corant-modules/corant-modules-javafx/corant-modules-javafx-cdi/src/main/java/org/corant/modules/javafx/cdi/CorantJavaFXApplication.java new file mode 100644 index 000000000..c98f09b0d --- /dev/null +++ b/corant-modules/corant-modules-javafx/corant-modules-javafx-cdi/src/main/java/org/corant/modules/javafx/cdi/CorantJavaFXApplication.java @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2013-2021, Bingo.Chen (finesoft@gmail.com). + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package org.corant.modules.javafx.cdi; + +import static org.corant.context.Beans.resolve; +import static org.corant.context.Beans.resolveAccept; +import org.corant.Corant; +import org.corant.context.CDIs; +import org.corant.modules.javafx.cdi.CorantFXML.CorantFXMLLiteral; +import javafx.application.Application; +import javafx.fxml.FXMLLoader; +import javafx.stage.Stage; + +/** + * corant-modules-javafx-cdi + * + * @author bingo 上午12:31:43 + * + */ +public class CorantJavaFXApplication extends Application { + + @Override + public final void init() throws Exception { + startCorant(); + resolveAccept(CorantApplicationParametersFactory.class, p -> p.setParameters(getParameters())); + super.init(); + doInit(); + } + + @Override + public final void start(Stage primaryStage) throws Exception { + CDIs.fireEvent(primaryStage, StartupScene.INSTANCE); + doStart(primaryStage); + } + + @Override + public final void stop() throws Exception { + try { + super.stop(); + doStop(); + } finally { + stopCorant(); + } + } + + protected void doInit() throws Exception {} + + protected void doStart(Stage primaryStage) throws Exception {} + + protected void doStop() throws Exception {} + + protected FXMLLoader resolveFXMLLoader() { + return resolveFXMLLoader(null, null, null); + } + + protected FXMLLoader resolveFXMLLoader(String bundle) { + return resolveFXMLLoader(bundle, null, null); + } + + protected FXMLLoader resolveFXMLLoader(String bundle, String url) { + return resolveFXMLLoader(bundle, url, null); + } + + protected FXMLLoader resolveFXMLLoader(String bundle, String url, String charset) { + return resolve(FXMLLoader.class, CorantFXMLLiteral.of(bundle, url, charset)); + } + + protected void startCorant() { + if (Corant.current() == null) { + synchronized (Corant.class) { + if (Corant.current() == null) { + Corant.startup(getParameters().getRaw().toArray(String[]::new)); + } + } + } + if (!Corant.current().isRunning()) { + Corant.current().start(null); + } + } + + protected void stopCorant() { + if (Corant.current() != null) { + synchronized (Corant.class) { + if (Corant.current() != null) { + Corant.shutdown(); + } + } + } + } + +} diff --git a/corant-modules/corant-modules-javafx/corant-modules-javafx-cdi/src/main/java/org/corant/modules/javafx/cdi/CorantJavaFXPreloader.java b/corant-modules/corant-modules-javafx/corant-modules-javafx-cdi/src/main/java/org/corant/modules/javafx/cdi/CorantJavaFXPreloader.java new file mode 100644 index 000000000..743e4c715 --- /dev/null +++ b/corant-modules/corant-modules-javafx/corant-modules-javafx-cdi/src/main/java/org/corant/modules/javafx/cdi/CorantJavaFXPreloader.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2013-2021, Bingo.Chen (finesoft@gmail.com). + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package org.corant.modules.javafx.cdi; + +import org.corant.Corant; +import javafx.application.Preloader; +import javafx.stage.Stage; + +/** + * corant-modules-javafx-cdi + * + * @author bingo 下午11:51:55 + * + */ +public class CorantJavaFXPreloader extends Preloader { + + @Override + public boolean handleErrorNotification(ErrorNotification info) { + stopCorant(); + return super.handleErrorNotification(info); + } + + @Override + public void init() throws Exception { + startCorant(); + super.init(); + } + + @Override + public void start(Stage primaryStage) throws Exception {} + + @Override + public void stop() throws Exception { + super.stop(); + stopCorant(); + } + + protected void startCorant() { + if (Corant.current() == null) { + synchronized (Corant.class) { + if (Corant.current() == null) { + Corant.startup(getParameters().getRaw().toArray(String[]::new)); + } + } + } + if (!Corant.current().isRunning()) { + Corant.current().start(null); + } + } + + protected void stopCorant() { + if (Corant.current() != null) { + synchronized (Corant.class) { + if (Corant.current() != null) { + Corant.shutdown(); + } + } + } + } +} diff --git a/corant-modules/corant-modules-javafx/corant-modules-javafx-cdi/src/main/java/org/corant/modules/javafx/cdi/StartupScene.java b/corant-modules/corant-modules-javafx/corant-modules-javafx-cdi/src/main/java/org/corant/modules/javafx/cdi/StartupScene.java new file mode 100644 index 000000000..2b3b07ab1 --- /dev/null +++ b/corant-modules/corant-modules-javafx/corant-modules-javafx-cdi/src/main/java/org/corant/modules/javafx/cdi/StartupScene.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2013-2021, Bingo.Chen (finesoft@gmail.com). + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package org.corant.modules.javafx.cdi; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import javax.enterprise.util.AnnotationLiteral; +import javax.inject.Qualifier; + +/** + * corant-modules-javafx-cdi + * + * @author bingo 上午12:41:32 + * + */ +@Qualifier +@Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface StartupScene { + + StartupSceneLiteral INSTANCE = new StartupSceneLiteral(); + + class StartupSceneLiteral extends AnnotationLiteral implements StartupScene { + + private static final long serialVersionUID = -5372955628801737362L; + + } +} diff --git a/corant-modules/corant-modules-javafx/corant-modules-javafx-cdi/src/main/java/org/corant/modules/javafx/cdi/UIThreads.java b/corant-modules/corant-modules-javafx/corant-modules-javafx-cdi/src/main/java/org/corant/modules/javafx/cdi/UIThreads.java new file mode 100644 index 000000000..3aee04e88 --- /dev/null +++ b/corant-modules/corant-modules-javafx/corant-modules-javafx-cdi/src/main/java/org/corant/modules/javafx/cdi/UIThreads.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2013-2021, Bingo.Chen (finesoft@gmail.com). + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package org.corant.modules.javafx.cdi; + +import static org.corant.shared.util.Assertions.shouldNoneNull; +import static org.corant.shared.util.Assertions.shouldNotNull; +import static org.corant.shared.util.Functions.uncheckedRunner; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.FutureTask; +import org.corant.shared.exception.CorantRuntimeException; +import javafx.application.Platform; + +/** + * corant-modules-javafx-cdi + * + * @author bingo 下午11:41:07 + * + */ +public class UIThreads { + + public static T callInsideUIAndWait(final Callable callable) + throws InterruptedException, ExecutionException { + final FutureTask future = new FutureTask<>(shouldNotNull(callable)); + Platform.runLater(future); + return future.get(); + } + + public static T callInsideUISync(final Callable callable) { + FutureTask ft = new FutureTask<>(shouldNotNull(callable)); + runInsideUISync(ft); + try { + return ft.get(); + } catch (InterruptedException | ExecutionException e) { + throw new CorantRuntimeException(e, + "An error occurred while executing a task inside the UI thread"); + } + } + + public static boolean isUIThread() { + return Platform.isFxApplicationThread(); + } + + public static void runInsideUIAndWait(final Runnable runnable) + throws InterruptedException, ExecutionException { + final FutureTask future = new FutureTask<>(shouldNotNull(runnable), null); + Platform.runLater(future); + future.get(); + } + + public static void runInsideUIAsync(final Runnable runnable) { + Platform.runLater(shouldNotNull(runnable)); + } + + public static void runInsideUISync(final Runnable runnable) { + shouldNotNull(runnable); + if (isUIThread()) { + runnable.run(); + } else { + final FutureTask task = new FutureTask<>(uncheckedRunner(runnable::run), null); + Platform.runLater(task); + try { + task.get(); + } catch (InterruptedException | ExecutionException e) { + throw new CorantRuntimeException(e); + } + } + } + + public static void runOutsideUI(final ExecutorService executorService, final Runnable runnable) { + shouldNotNull(runnable); + if (!isUIThread()) { + runnable.run(); + } else { + shouldNotNull(executorService).submit(uncheckedRunner(runnable::run)); + } + } + + public static void runOutsideUIAsync(final ExecutorService executorService, + final Runnable runnable) { + shouldNoneNull(runnable, executorService); + executorService.submit(uncheckedRunner(runnable::run)); + } +} diff --git a/corant-modules/corant-modules-javafx/corant-modules-javafx-cdi/src/main/java/org/corant/modules/javafx/cdi/package-info.java b/corant-modules/corant-modules-javafx/corant-modules-javafx-cdi/src/main/java/org/corant/modules/javafx/cdi/package-info.java index 2885d5378..c004e4b76 100644 --- a/corant-modules/corant-modules-javafx/corant-modules-javafx-cdi/src/main/java/org/corant/modules/javafx/cdi/package-info.java +++ b/corant-modules/corant-modules-javafx/corant-modules-javafx-cdi/src/main/java/org/corant/modules/javafx/cdi/package-info.java @@ -13,7 +13,7 @@ */ /** * corant-modules-javafx-cdi - * + * * @author bingo 下午11:06:37 * */ diff --git a/corant-modules/corant-modules-jms/corant-modules-jms-api/src/main/java/org/corant/modules/jms/annotation/MessageContext.java b/corant-modules/corant-modules-jms/corant-modules-jms-api/src/main/java/org/corant/modules/jms/annotation/MessageContext.java index c62952c7c..4a691fd41 100644 --- a/corant-modules/corant-modules-jms/corant-modules-jms-api/src/main/java/org/corant/modules/jms/annotation/MessageContext.java +++ b/corant-modules/corant-modules-jms/corant-modules-jms-api/src/main/java/org/corant/modules/jms/annotation/MessageContext.java @@ -34,10 +34,13 @@ public @interface MessageContext { /** * The connection factory id, used to represent a JMS service or cluster, usually set up through a - * configuration file. + * configuration file. Default is empty that means unspecified. At the same time the connection + * factory id is used for CDI qualifier. *

* Note: If the value of this property uses the "${...}" expression, the specific value can * be obtained from the system property or configuration. + * + * @see org.corant.context.qualifier.Qualifiers */ String connectionFactoryId() default EMPTY; @@ -48,7 +51,8 @@ * JMSContext.DUPS_OK_ACKNOWLEDGE. The session will be non-transacted and messages received by * this session will be acknowledged automatically according to the value of acknowledgeMode. For * a definition of the meaning of these acknowledgement modes see the links below. The values - * JMSContext.SESSION_TRANSACTED and JMSContext.CLIENT_ACKNOWLEDGE may not be used. + * JMSContext.SESSION_TRANSACTED and JMSContext.CLIENT_ACKNOWLEDGE may not be used. Default is + * false *

* Note: The final value type is boolean type; in order to support configurability, the * string is used as the value type of annotation property, and the value will eventually be diff --git a/corant-modules/corant-modules-jms/corant-modules-jms-api/src/main/java/org/corant/modules/jms/annotation/MessageDestination.java b/corant-modules/corant-modules-jms/corant-modules-jms-api/src/main/java/org/corant/modules/jms/annotation/MessageDestination.java index 76a2baeac..9ad44177a 100644 --- a/corant-modules/corant-modules-jms/corant-modules-jms-api/src/main/java/org/corant/modules/jms/annotation/MessageDestination.java +++ b/corant-modules/corant-modules-jms/corant-modules-jms-api/src/main/java/org/corant/modules/jms/annotation/MessageDestination.java @@ -37,7 +37,10 @@ /** * The connection factory id, used to represent a JMS service or cluster, usually set up through a * configuration file, if the value uses the "${...}" expression, the specific value can be - * obtained from the system property or configuration.. + * obtained from the system property or configuration. + * + * Default is empty that means unspecified. At the same time the connection factory id is used for + * CDI qualifier. */ String connectionFactoryId() default EMPTY; @@ -52,7 +55,7 @@ * the specific value can be obtained from the system property or configuration, and then convert * it to boolean value. * - * @return multicast + * @return whether is Topic */ String multicast() default "false"; diff --git a/corant-modules/corant-modules-jms/corant-modules-jms-api/src/main/java/org/corant/modules/jms/annotation/MessageDriven.java b/corant-modules/corant-modules-jms/corant-modules-jms-api/src/main/java/org/corant/modules/jms/annotation/MessageDriven.java index 23f68d51c..dd6a58c5e 100644 --- a/corant-modules/corant-modules-jms/corant-modules-jms-api/src/main/java/org/corant/modules/jms/annotation/MessageDriven.java +++ b/corant-modules/corant-modules-jms/corant-modules-jms-api/src/main/java/org/corant/modules/jms/annotation/MessageDriven.java @@ -227,7 +227,7 @@ /** * The value of the timeout in seconds. If the value is zero, the transaction service restores the * default value. If the value is negative a SystemException is thrown. Only works if - * {@link #xa()} = true, default is 0. + * {@link #xa()} = true, default is 300. * *

* Note: The final value type is integer type; in order to support configurability, diff --git a/corant-modules/corant-modules-jms/corant-modules-jms-api/src/main/java/org/corant/modules/jms/annotation/MessageProperty.java b/corant-modules/corant-modules-jms/corant-modules-jms-api/src/main/java/org/corant/modules/jms/annotation/MessageProperty.java index 3c2b987f9..7082a6772 100644 --- a/corant-modules/corant-modules-jms/corant-modules-jms-api/src/main/java/org/corant/modules/jms/annotation/MessageProperty.java +++ b/corant-modules/corant-modules-jms/corant-modules-jms-api/src/main/java/org/corant/modules/jms/annotation/MessageProperty.java @@ -34,6 +34,7 @@ /** The name of the property */ String name(); + /** The type of the property */ Class type() default String.class; /** diff --git a/corant-modules/corant-modules-jms/corant-modules-jms-api/src/main/java/org/corant/modules/jms/annotation/MessageReply.java b/corant-modules/corant-modules-jms/corant-modules-jms-api/src/main/java/org/corant/modules/jms/annotation/MessageReply.java index 7ab624298..00de76239 100644 --- a/corant-modules/corant-modules-jms/corant-modules-jms-api/src/main/java/org/corant/modules/jms/annotation/MessageReply.java +++ b/corant-modules/corant-modules-jms/corant-modules-jms-api/src/main/java/org/corant/modules/jms/annotation/MessageReply.java @@ -20,6 +20,7 @@ import javax.jms.JMSProducer; import javax.jms.Message; import org.corant.modules.jms.JMSNames; +import org.corant.modules.jms.marshaller.MessageMarshaller; /** * corant-modules-jms-shared @@ -62,6 +63,7 @@ * be obtained from the system property or configuration. * * @return the marshaler name + * @see MessageMarshaller */ String marshaller() default JMSNames.MSG_MARSHAL_SCHEMA_STD_JAVA; diff --git a/corant-modules/corant-modules-jms/corant-modules-jms-api/src/main/java/org/corant/modules/jms/annotation/MessageSend.java b/corant-modules/corant-modules-jms/corant-modules-jms-api/src/main/java/org/corant/modules/jms/annotation/MessageSend.java index ed84f9b5f..29416d8a0 100644 --- a/corant-modules/corant-modules-jms/corant-modules-jms-api/src/main/java/org/corant/modules/jms/annotation/MessageSend.java +++ b/corant-modules/corant-modules-jms/corant-modules-jms-api/src/main/java/org/corant/modules/jms/annotation/MessageSend.java @@ -40,7 +40,7 @@ * For transacted sends, this time starts when the client sends the message, not when the * transaction is committed. * - * deliveryDelay is set to -1 by default, means not setting + * DeliveryDelay is set to -1 by default, means not setting * * @return deliveryDelay * @see JMSProducer#setDeliveryDelay(long) @@ -75,7 +75,8 @@ * JMSContext.DUPS_OK_ACKNOWLEDGE. The session will be non-transacted and messages received by * this session will be acknowledged automatically according to the value of acknowledgeMode. For * a definition of the meaning of these acknowledgement modes see the links below. The values - * JMSContext.SESSION_TRANSACTED and JMSContext.CLIENT_ACKNOWLEDGE may not be used. + * JMSContext.SESSION_TRANSACTED and JMSContext.CLIENT_ACKNOWLEDGE may not be used. Default is + * false. * *

* Note: The final value type is boolean type; in order to support configurability, the diff --git a/corant-modules/corant-modules-json/src/main/java/org/corant/modules/bson/Bsons.java b/corant-modules/corant-modules-json/src/main/java/org/corant/modules/bson/Bsons.java index a6de1d99f..2b71f676f 100644 --- a/corant-modules/corant-modules-json/src/main/java/org/corant/modules/bson/Bsons.java +++ b/corant-modules/corant-modules-json/src/main/java/org/corant/modules/bson/Bsons.java @@ -238,8 +238,8 @@ public static BsonValue toSimpleBsonValue(Object source) { throw new CorantRuntimeException(e); } } - throw new IllegalArgumentException( - String.format("Unable to convert %s (%s) to BsonValue.", source.getClass().getName())); + throw new IllegalArgumentException(String.format("Unable to convert %s (%s) to BsonValue.", + source, source.getClass().getName())); } static Object decodeTransformer(Object objectToTransform) { diff --git a/corant-modules/corant-modules-jta/corant-modules-jta-narayana/src/main/java/org/corant/modules/jta/narayana/NarayanaExtension.java b/corant-modules/corant-modules-jta/corant-modules-jta-narayana/src/main/java/org/corant/modules/jta/narayana/NarayanaExtension.java index b03baae3b..108115c95 100644 --- a/corant-modules/corant-modules-jta/corant-modules-jta-narayana/src/main/java/org/corant/modules/jta/narayana/NarayanaExtension.java +++ b/corant-modules/corant-modules-jta/corant-modules-jta-narayana/src/main/java/org/corant/modules/jta/narayana/NarayanaExtension.java @@ -168,7 +168,7 @@ void configEnvironmentBean() { "JTA recovery settings: init-offset: %ss, period: %ss, back-off: %ss, expiry-scan-interval: %sh.", recoveryBean.getPeriodicRecoveryInitilizationOffset(), recoveryBean.getPeriodicRecoveryPeriod(), recoveryBean.getRecoveryBackoffPeriod(), - recoveryBean.getExpiryScanInterval(), recoveryBean.getExpiryScanInterval())); + recoveryBean.getExpiryScanInterval())); } } diff --git a/corant-modules/corant-modules-microprofile/corant-modules-microprofile-restclient/pom.xml b/corant-modules/corant-modules-microprofile/corant-modules-microprofile-restclient/pom.xml index c87c5e65f..012df1a9d 100644 --- a/corant-modules/corant-modules-microprofile/corant-modules-microprofile-restclient/pom.xml +++ b/corant-modules/corant-modules-microprofile/corant-modules-microprofile-restclient/pom.xml @@ -13,6 +13,14 @@ org.jboss.resteasy resteasy-client-microprofile + + org.jboss.resteasy + resteasy-jackson2-provider + + + org.jboss.resteasy + resteasy-multipart-provider + org.corant corant-config diff --git a/corant-modules/corant-modules-query/corant-modules-query-shared/src/main/java/org/corant/modules/query/shared/spi/ResultFieldConvertHintHandler.java b/corant-modules/corant-modules-query/corant-modules-query-shared/src/main/java/org/corant/modules/query/shared/spi/ResultFieldConvertHintHandler.java index 5eb6dd0b5..013099f71 100644 --- a/corant-modules/corant-modules-query/corant-modules-query-shared/src/main/java/org/corant/modules/query/shared/spi/ResultFieldConvertHintHandler.java +++ b/corant-modules/corant-modules-query/corant-modules-query-shared/src/main/java/org/corant/modules/query/shared/spi/ResultFieldConvertHintHandler.java @@ -199,7 +199,7 @@ protected void handle(Map map, String[] keyPath, Class target } } catch (Exception e) { logger.log(Level.WARNING, e, - () -> String.format("Hanle result conversion error on property %s with value %s.", + () -> String.format("Handle result conversion error on property %s with value %s.", String.join(".", keyPath), orginalVal)); } } diff --git a/corant-shared/src/main/java/org/corant/shared/conversion/Conversion.java b/corant-shared/src/main/java/org/corant/shared/conversion/Conversion.java index 491139a83..0978411eb 100644 --- a/corant-shared/src/main/java/org/corant/shared/conversion/Conversion.java +++ b/corant-shared/src/main/java/org/corant/shared/conversion/Conversion.java @@ -13,6 +13,8 @@ */ package org.corant.shared.conversion; +import static org.corant.shared.util.Assertions.shouldNoneNull; +import static org.corant.shared.util.Assertions.shouldNotNull; import static org.corant.shared.util.Iterables.iterableOf; import static org.corant.shared.util.Iterables.transform; import static org.corant.shared.util.Objects.forceCast; @@ -73,6 +75,7 @@ public static > C convert(Collection value, if (value == null) { return null; } + shouldNotNull(targetItemClass, "The target class of the conversion can't be null"); C collection = collectionFactory.apply(value.size()); for (T t : convert(value, targetItemClass, hints)) { collection.add(t); @@ -92,9 +95,10 @@ public static > C convert(Collection value, */ public static Iterable convert(Iterable value, Class sourceClass, Class targetClass, Map hints) { + shouldNoneNull(sourceClass, targetClass); Converter converter = resolveConverter(sourceClass, targetClass); if (converter != null) { - LOGGER.finer(() -> String.format("Resolve converter %", converter)); + LOGGER.finer(() -> String.format("Resolve converter %s", converter)); return converter.iterable(value, hints); } else { Converter stringConverter = resolveConverter(String.class, targetClass); @@ -123,6 +127,7 @@ public static Iterable convert(Iterable value, Class targetClass, if (value == null) { return null; } + shouldNotNull(targetClass, "The target class of the conversion can't be null"); return () -> new Iterator<>() { final Iterator it = value.iterator(); Converter converter = null; @@ -156,7 +161,7 @@ public T next() { throw new ConversionException("Can not find converter for type pair s% -> %s.", sourceClass, targetClass); } - LOGGER.finer(() -> String.format("Resolve converter %", converter)); + LOGGER.finer(() -> String.format("Resolve converter %s", converter)); } return (T) converter.apply(tryStringConverter ? next.toString() : next, hints); } @@ -189,7 +194,7 @@ public static , T> C convert(Object value, Class coll | InvocationTargetException | NoSuchMethodException | SecurityException e) { throw new NotSupportedException(); } - }, hints); + }, hints, false); } /** @@ -208,8 +213,8 @@ public static T convert(Object value, Class targetClass) { /** * Convert a value object to a collection objects, use for converting the * iterable/array/iterator/enumeration objects to collection objects. - * - * if the value object not belong to above then regard the value object as the first item of + *

+ * If the value object not belong to above then regard the value object as the first item of * collection and convert it. * * @param the target class of item of the collection @@ -218,10 +223,13 @@ public static T convert(Object value, Class targetClass) { * @param targetItemClass the target class of item of the collection * @param collectionFactory the constructor of collection * @param hints the converter hints use for intervening converters + * @param supportsSingleton whether to be converted as single element collection if the given + * value is not iterable/array/iterator/enumeration. * @return A collection of items converted according to the target type */ public static > C convert(Object value, Class targetItemClass, - IntFunction collectionFactory, Map hints) { + IntFunction collectionFactory, Map hints, boolean supportsSingleton) { + shouldNotNull(targetItemClass, "The target item class of the conversion can't be null"); Iterable it = null; int size = 10; if (value instanceof Iterable) { @@ -242,8 +250,11 @@ public static > C convert(Object value, Class targ Object[] array = wrapArray(value); size = array.length; it = convert(iterableOf(wrapArray(array)), targetItemClass, hints); - } else { + } else if (supportsSingleton) { it = convert(iterableOf(value), targetItemClass, hints); + } else { + throw new ConversionException( + "The given value can't be converted, the target item class of the conversion must be iterable/array/iterator/enumeration"); } } final C collection = collectionFactory.apply(size); @@ -269,13 +280,14 @@ public static T convert(Object value, Class targetClass, Map sourceClass = value.getClass(); if (targetClass.isAssignableFrom(sourceClass)) { return (T) value; } Converter converter = resolveConverter(sourceClass, targetClass); if (converter != null) { - LOGGER.finer(() -> String.format("Resolve converter %", converter)); + LOGGER.finer(() -> String.format("Resolve converter %s", converter)); return converter.apply((S) value, hints); } else { Converter stringConverter = resolveConverter(String.class, targetClass); @@ -331,6 +343,7 @@ public static T convert(Object value, TypeLiteral typeLiteral, Map T[] convert(Object[] value, Class targetItemClass, IntFunction arrayFactory, Map hints) { + shouldNotNull(targetItemClass, "The target item class of the conversion can't be null"); if (value == null) { return arrayFactory.apply(0); } @@ -359,6 +372,7 @@ public static > C convert(Object[] value, if (value == null) { return null; } + shouldNotNull(targetItemClass, "The target item class of the conversion can't be null"); C collection = collectionFactory.apply(value.length); for (T t : convert(iterableOf(value), targetItemClass, hints)) { collection.add(t); @@ -376,6 +390,7 @@ public static > C convert(Object[] value, * @return the converted object */ public static T[] convertArray(Object value, Class targetClass, Map hints) { + shouldNotNull(targetClass, "The target class can't null"); if (value == null) { return (T[]) Array.newInstance(targetClass, 0); } else if (value.getClass().isArray()) { @@ -412,6 +427,7 @@ public static T[] convertArray(Object value, Class targetClass, Map Map convertMap(Object value, Class keyClass, Class valueClass, Map hints) { + shouldNoneNull(keyClass, valueClass); if (value == null) { return null; } else if (value instanceof Map) { @@ -552,9 +568,9 @@ static Object convertType(Object value, Type targetType, Map hints) { "Cannot convert for type " + typeClass + "<" + Arrays.toString(argClasses) + "[]>"); } } else if (List.class.isAssignableFrom(typeClass) && argClasses.length == 1) { - result = convert(value, argClasses[0], ArrayList::new, hints); + result = convert(value, argClasses[0], ArrayList::new, hints, false); } else if (Set.class.isAssignableFrom(typeClass) && argClasses.length == 1) { - result = convert(value, argClasses[0], HashSet::new, hints); + result = convert(value, argClasses[0], HashSet::new, hints, false); } else if (Optional.class.isAssignableFrom(typeClass) && argClasses.length == 1) { result = Optional.ofNullable(convert(value, argClasses[0], hints)); } else if (Supplier.class.isAssignableFrom(typeClass) && argClasses.length == 1) { diff --git a/corant-shared/src/main/java/org/corant/shared/resource/Resource.java b/corant-shared/src/main/java/org/corant/shared/resource/Resource.java index 3564e301a..008f2bbf5 100644 --- a/corant-shared/src/main/java/org/corant/shared/resource/Resource.java +++ b/corant-shared/src/main/java/org/corant/shared/resource/Resource.java @@ -22,7 +22,7 @@ import java.nio.channels.ReadableByteChannel; import java.util.Map; import java.util.logging.Level; -import org.corant.shared.util.Resources; +import java.util.logging.Logger; import org.corant.shared.util.Streams; /** @@ -38,6 +38,8 @@ */ public interface Resource { + Logger logger = Logger.getLogger(Resource.class.getName()); + String META_CONTENT_TYPE = "Content-Type"; String META_CONTENT_LENGTH = "Content-Length"; String META_LAST_MODIFIED = "Last-Modified"; @@ -54,7 +56,7 @@ default boolean exists() { /** * Return a byte array for the content of this resource, please evaluate the size of the resource * when using it to avoid OOM. - * + *

* NOTE: the stream will be closed after reading. * * @throws IOException If I/O errors occur @@ -92,7 +94,7 @@ default Map getMetadata() { * Returns metadata information for this resource's corresponding name with the given name and * type. * - * @param + * @param the metadata value type class * @param name the metadata key * @param type the metadata value type, may involve type conversion */ @@ -142,7 +144,7 @@ default InputStream tryOpenInputStream() { try { return openInputStream(); } catch (IOException e) { - Resources.logger.log(Level.WARNING, e, + logger.log(Level.WARNING, e, () -> String.format("Can't not open stream from %s.", getLocation())); } return null; diff --git a/corant-shared/src/main/java/org/corant/shared/resource/WritableResource.java b/corant-shared/src/main/java/org/corant/shared/resource/WritableResource.java index 868f5dbee..58dea4a76 100644 --- a/corant-shared/src/main/java/org/corant/shared/resource/WritableResource.java +++ b/corant-shared/src/main/java/org/corant/shared/resource/WritableResource.java @@ -19,7 +19,6 @@ import java.nio.channels.WritableByteChannel; import java.nio.file.OpenOption; import java.util.logging.Level; -import org.corant.shared.util.Resources; /** * corant-shared @@ -39,7 +38,7 @@ default OutputStream tryOpenOutputStream() { try { return openOutputStream(); } catch (IOException e) { - Resources.logger.log(Level.WARNING, e, + logger.log(Level.WARNING, e, () -> String.format("Can't not open stream from %s.", getLocation())); } return null; diff --git a/corant-shared/src/main/java/org/corant/shared/util/Conversions.java b/corant-shared/src/main/java/org/corant/shared/util/Conversions.java index ee8009346..d1e2684f6 100644 --- a/corant-shared/src/main/java/org/corant/shared/util/Conversions.java +++ b/corant-shared/src/main/java/org/corant/shared/util/Conversions.java @@ -101,7 +101,7 @@ public static BigDecimal toBigDecimal(Object obj) { /** * Convert an object to BigDecimal object, supports String to BigDecimal Number to BigDecimal, * return the given alternative object if the converted object is null else return the converted - * obejct. Support converting String or Numeric type to BigDecimal type. + * object. Support converting String or Numeric type to BigDecimal type. * * @param obj the object that to be converted * @param altVal the alternative object if converted object is null @@ -116,7 +116,7 @@ public static BigDecimal toBigDecimal(Object obj, BigDecimal altVal) { /** * Convert an object to rounding BigDecimal object with scale, support converting String or * Numeric type to BigDecimal type. Return the given alternative object if the converted object is - * null else return the converted obejct. + * null else return the converted object. * * @param obj the object that to be converted * @param altVal the alternative object if converted object is null @@ -225,7 +225,7 @@ public static Byte toByte(Object obj) { /** * Convert an object to Byte object, support converting String (normal or Hex) or Numeric type to * Byte type, Float or Double type object may involve rounding or truncation. Return the given - * alternative object if the converted object is null else return the converted obejct. + * alternative object if the converted object is null else return the converted object. * * @param obj the object that to be converted * @param altVal the alternative object if converted object is null @@ -269,7 +269,7 @@ public static Class toClass(Object obj) { */ public static > C toCollection(Object obj, Class itemClass, IntFunction collectionFactory) { - return Conversion.convert(obj, itemClass, collectionFactory, null); + return Conversion.convert(obj, itemClass, collectionFactory, null, true); } /** @@ -377,12 +377,9 @@ public static List toList(Object obj, Class clazz) { public static List toList(Object obj, Class clazz, Map hints) { if (obj == null) { return null; - } else if (obj instanceof Collection) { - return Conversion.convert((Collection) obj, ArrayList::new, clazz, hints); - } else if (obj.getClass().isArray()) { - return Conversion.convert(wrapArray(obj), ArrayList::new, clazz, hints); + } else { + return Conversion.convert(obj, clazz, ArrayList::new, hints, false); } - return Conversion.convert(obj, clazz, ArrayList::new, hints);// FIXME weird } public static List toList(Object obj, Function convert) { @@ -592,12 +589,9 @@ public static Set toSet(Object obj, Class clazz) { public static Set toSet(Object obj, Class clazz, Map hints) { if (obj == null) { return null; - } else if (obj instanceof Collection) { - return Conversion.convert((Collection) obj, HashSet::new, clazz, hints); - } else if (obj.getClass().isArray()) { - return Conversion.convert(wrapArray(obj), HashSet::new, clazz, hints); + } else { + return Conversion.convert(obj, clazz, HashSet::new, hints, false); } - return Conversion.convert(obj, clazz, HashSet::new, hints);// FIXME weird } public static Set toSet(Object obj, Function convert) { diff --git a/corant-shared/src/main/java/org/corant/shared/util/Maps.java b/corant-shared/src/main/java/org/corant/shared/util/Maps.java index aeefce5be..edae3fc06 100644 --- a/corant-shared/src/main/java/org/corant/shared/util/Maps.java +++ b/corant-shared/src/main/java/org/corant/shared/util/Maps.java @@ -150,10 +150,6 @@ public static List extractMapKeyPathValues(Object object, Object[] keyPat /** * @see #flatMap(Map, String, int) - * - * @param map - * @param maxDepth - * @return flatMap */ public static Map flatMap(Map map, int maxDepth) { Map flatMap = new HashMap<>(); @@ -210,7 +206,7 @@ public static Map flatMap(Map map, int maxDepth) { * } * * - * @param map the map to be flatten + * @param map the map to be flattened * @param splitor the string key splitor, use to splite key levels. * @param maxDepth Maximum leveling depth * @return a map, where the key consists of the key of the given map and the given delimiter @@ -236,8 +232,8 @@ public static Map flatMap(Map map, String splitor, in /** * @see #flatMap(Map, String, int) * - * @param map the map to be flatten - * @param splitor the string key splitor, use to splite key levels. + * @param map the map to be flattened + * @param splitor the string key splitor, use to split key levels. * @param maxDepth Maximum leveling depth * @return a map, where the key consists of the key of the original map and the given delimiter */ @@ -368,22 +364,16 @@ public static > C getMapCollection(final Map ma * @param hints the lastConverter hints use for intervening converters * @return the mapped expected collection value * - * @see Conversion#convert(Object, Class, IntFunction, Map) - * @see Conversion#convert(Collection, IntFunction, Class, Map) - * @see Conversion#convert(Object[], IntFunction, Class, Map) + * @see Conversion#convert(Object, Class, IntFunction, Map, boolean) */ public static > C getMapCollection(final Map map, final Object key, final IntFunction collectionFactory, final Class elementClazz, final Map hints) { Object obj = map == null ? null : map.get(key); - if (obj instanceof Collection) { - return Conversion.convert((Collection) obj, collectionFactory, elementClazz, hints); - } else if (obj instanceof Object[] || obj != null && obj.getClass().isArray()) { - return Conversion.convert(wrapArray(obj), collectionFactory, elementClazz, hints); - } else if (obj != null) { - return Conversion.convert(obj, elementClazz, collectionFactory, hints); - } else { + if (obj == null) { return null; + } else { + return Conversion.convert(obj, elementClazz, collectionFactory, hints, false); } } @@ -408,47 +398,7 @@ public static > C getMapCollection(final Map ma public static > C getMapCollection(final Map map, final Object key, final IntFunction collectionFactory, final Function converter) { - Object obj = map == null ? null : map.get(key); - if (obj instanceof Collection) { - Collection vals = (Collection) obj; - C results = collectionFactory.apply(vals.size()); - for (Object val : vals) { - results.add(converter.apply(val)); - } - return results; - } else if (obj instanceof Object[] || obj != null && obj.getClass().isArray()) { - Object[] vals = wrapArray(obj); - C results = collectionFactory.apply(vals.length); - for (Object val : vals) { - results.add(converter.apply(val)); - } - return results; - } else if (obj instanceof Iterable) { - Iterable vals = (Iterable) obj; - C results = collectionFactory.apply(10); - for (Object val : vals) { - results.add(converter.apply(val)); - } - return results; - } else if (obj instanceof Iterator) { - Iterator vals = (Iterator) obj; - C results = collectionFactory.apply(10); - while (vals.hasNext()) { - results.add(converter.apply(vals.next())); - } - return results; - } else if (obj instanceof Enumeration) { - Enumeration vals = (Enumeration) obj; - C results = collectionFactory.apply(10); - while (vals.hasMoreElements()) { - results.add(converter.apply(vals.nextElement())); - } - return results; - } else if (obj == null) { - return null; - } else { - throw new NotSupportedException(); - } + return convertCollection(map == null ? null : map.get(key), collectionFactory, converter); } /** @@ -759,13 +709,13 @@ public static List getMapList(final Map map, final Object key, * @param the expected returned element type * @param map the map to use * @param key the key to lookup - * @param singleElementconverter the converter function that extract value to expected list + * @param singleElementConverter the converter function that extract value to expected list * element. * @return the expected list */ public static List getMapList(final Map map, final Object key, - final Function singleElementconverter) { - return getMapObjectList(map, key, v -> toList(v, singleElementconverter)); + final Function singleElementConverter) { + return getMapObjectList(map, key, v -> toList(v, singleElementConverter)); } /** @@ -1162,6 +1112,86 @@ public static Map newLinkedHashMap(Map ma return map != null ? new LinkedHashMap<>(map) : new LinkedHashMap<>(); } + /** + * + * Remove and return converted the collection value mapped to the given key in the given Map or + * {@code null} if the given map is {@code null} or the map contains no mapping for the key or the + * mapped value is {@code null}. + * + *

+ * Note: The returned collection is reconstructed + * + * @param the target class of item of the collection + * @param the target collection class + * @param map the map to use + * @param key the key to lookup + * @param collectionFactory the constructor of collection + * @param elementClazz the element class + * @return the mapped expected collection value + */ + public static > C popMapCollection(final Map map, + final Object key, final IntFunction collectionFactory, final Class elementClazz) { + Object obj = map == null ? null : map.remove(key); + if (obj == null) { + return null; + } else { + return Conversion.convert(obj, elementClazz, collectionFactory, null, false); + } + } + + /** + * + * Remove and return converted the collection value mapped to the given key in the given Map or + * {@code null} if the given map is {@code null} or the map contains no mapping for the key or the + * mapped value is {@code null}. + * + *

+ * Note: The returned collection is reconstructed + * + * @param the target class of item of the collection + * @param the target collection class + * @param map the map to use + * @param key the key to lookup + * @param collectionFactory the constructor of collection + * @param converter the single element converter + * @return the mapped expected collection value + */ + public static > C popMapCollection(final Map map, + final Object key, final IntFunction collectionFactory, + final Function converter) { + return convertCollection(map == null ? null : map.remove(key), collectionFactory, converter); + } + + /** + * Remove and return converted the value corresponding to the given key in the given map, and the + * intermediate process may involve type conversion. + * + * @param the expected value type + * @param map the map to use + * @param key the key to lookup + * @param clazz the expected value class + * @return the mapped object + */ + public static T popMapObject(final Map map, final Object key, final Class clazz) { + return popMapObject(map, key, clazz, null); + } + + /** + * Remove and return converted the value corresponding to the given key in the given map, and the + * intermediate process may involve type conversion. + * + * @param the expected value type + * @param map the map to use + * @param key the key to lookup + * @param clazz the expected value class + * @param hints the conversion hints + * @return the mapped object + */ + public static T popMapObject(final Map map, final Object key, final Class clazz, + final Map hints) { + return toObject(map == null ? null : map.remove(key), shouldNotNull(clazz), hints); + } + public static Properties propertiesOf(String... strings) { Properties result = new Properties(); result.putAll(mapOf((Object[]) strings)); @@ -1231,6 +1261,50 @@ public static Map union(Map... maps) { return union; } + static > C convertCollection(Object obj, + final IntFunction collectionFactory, final Function converter) { + if (obj == null) { + return null; + } else if (obj instanceof Collection) { + Collection vals = (Collection) obj; + C results = collectionFactory.apply(vals.size()); + for (Object val : vals) { + results.add(converter.apply(val)); + } + return results; + } else if (obj instanceof Object[] || obj.getClass().isArray()) { + Object[] vals = wrapArray(obj); + C results = collectionFactory.apply(vals.length); + for (Object val : vals) { + results.add(converter.apply(val)); + } + return results; + } else if (obj instanceof Iterable) { + Iterable vals = (Iterable) obj; + C results = collectionFactory.apply(10); + for (Object val : vals) { + results.add(converter.apply(val)); + } + return results; + } else if (obj instanceof Iterator) { + Iterator vals = (Iterator) obj; + C results = collectionFactory.apply(10); + while (vals.hasNext()) { + results.add(converter.apply(vals.next())); + } + return results; + } else if (obj instanceof Enumeration) { + Enumeration vals = (Enumeration) obj; + C results = collectionFactory.apply(10); + while (vals.hasMoreElements()) { + results.add(converter.apply(vals.nextElement())); + } + return results; + } else { + throw new NotSupportedException(); + } + } + @SuppressWarnings({"unchecked", "rawtypes"}) static void doFlatMap(Map resultMap, FlatMapKey key, Object val, int maxDepth) { diff --git a/corant-shared/src/main/java/org/corant/shared/util/Resources.java b/corant-shared/src/main/java/org/corant/shared/util/Resources.java index fcca0dbbf..6750a3111 100644 --- a/corant-shared/src/main/java/org/corant/shared/util/Resources.java +++ b/corant-shared/src/main/java/org/corant/shared/util/Resources.java @@ -42,7 +42,7 @@ */ public class Resources { - public static final Logger logger = Logger.getLogger(Resources.class.getName()); + static final Logger logger = Logger.getLogger(Resources.class.getName()); /** * Get URL resources from specified URL path, support Glob / Regex Pattern. @@ -60,7 +60,7 @@ public class Resources { * * @param the resource type * @param path the resource path - * @throws IOException + * @throws IOException if an I/O error occurs * @see PathMatcher#decidePathMatcher(String, boolean, boolean) */ public static Stream from(String path) throws IOException { @@ -80,9 +80,9 @@ public static Stream from(String path) throws IOExcep /** * Use specified class loader to scan all class path resources. * - * @param classLoader - * @return - * @throws IOException fromClassPath + * @param classLoader class loader for loading resources + * @return A class path resource stream + * @throws IOException if an I/O error occurs */ public static Stream fromClassPath(ClassLoader classLoader) throws IOException { @@ -100,15 +100,17 @@ public static Stream fromClassPath(ClassLoader classLoader) * 1.if path is "javax/sql/" then will scan all resources that under the javax.sql class path. * 2.if path is "java/sql/Driver.class" then will scan single resource javax.sql.Driver. * 3.if path is "META-INF/maven/" then will scan all resources under the META-INF/maven. - * 4.if path is blank ({@code Strings.isBlank}) then will scan all class path in the system. + * 4.if path is blank ({@code + * Strings.isBlank + * }) then will scan all class path in the system. * 5.if path is "javax/sql/*Driver.class" then will scan javax.sql class path and filter class name * end with Driver.class. * * - * @param classLoader - * @param classPath - * @return - * @throws IOException fromClassPath + * @param classLoader class loader for loading resources + * @param classPath the resource class path or expression, supports glob-pattern/regex + * @return A class path resource stream + * @throws IOException if an I/O error occurs */ public static Stream fromClassPath(ClassLoader classLoader, String classPath) throws IOException { @@ -118,9 +120,9 @@ public static Stream fromClassPath(ClassLoader classLoader, S /** * Use default class loader to scan the specified path resources. * - * @param classPath - * @return - * @throws IOException fromClassPath + * @param classPath the resource class path or expression, supports glob-pattern/regex + * @return A class path resource stream + * @throws IOException if an I/O error occurs */ public static Stream fromClassPath(String classPath) throws IOException { return ClassPathResourceLoader.DFLT_INST.load(classPath).stream(); @@ -129,9 +131,8 @@ public static Stream fromClassPath(String classPath) throws I /** * Use file create file system resource. * - * @param file - * @return - * @throws IOException fromFileSystem + * @param file used to build FileSystemResource + * @return A file system resource */ public static FileSystemResource fromFileSystem(File file) { return new FileSystemResource(shouldNotNull(file)); @@ -140,9 +141,9 @@ public static FileSystemResource fromFileSystem(File file) { /** * Use Path to find file system resource. * - * @param path - * @return - * @throws IOException fromFileSystem + * @param path used to build FileSystemResource + * @return A file system resource + * @throws IOException if an I/O error occurs */ public static FileSystemResource fromFileSystem(Path path) throws IOException { return new FileSystemResource(path); @@ -151,10 +152,11 @@ public static FileSystemResource fromFileSystem(Path path) throws IOException { /** * Use path string to find file system resource. Support glob/regex expression * + * @param path the resource path or expression, supports glob-pattern/regex + * @return A file system resource stream + * @throws IOException if an I/O error occurs + * * @see PathMatcher#decidePathMatcher(String, boolean, boolean) - * @param path - * @return - * @throws IOException fromFileSystem */ public static Stream fromFileSystem(String path) throws IOException { return FileSystemResourceLoader.DFLT_INST.load(path).stream(); @@ -163,10 +165,10 @@ public static Stream fromFileSystem(String path) throws IOEx /** * Use input stream to build input stream resource. * - * @param inputStream - * @param location - * @return - * @throws IOException fromInputStream + * @param inputStream used to build InputStreamResource + * @param location used to denote the origin of a given input stream + * @return an input stream resource + * @throws IOException if an I/O error occurs */ public static InputStreamResource fromInputStream(InputStream inputStream, String location) throws IOException { @@ -176,9 +178,9 @@ public static InputStreamResource fromInputStream(InputStream inputStream, Strin /** * Get the resources of a relative path through a class and path * - * @param relative - * @param path - * @return fromRelativeClass + * @param relative the relative class use to search the resource + * @param path resource class path + * @return a URLResource */ public static URLResource fromRelativeClass(Class relative, String path) { return ClassPathResourceLoader.relative(relative, path); @@ -187,9 +189,9 @@ public static URLResource fromRelativeClass(Class relative, String path) { /** * Use specified URL string to find resource. * - * @param url - * @return - * @throws IOException fromUrl + * @param url used to build URLResource + * @return a URLResource + * @throws IOException if an I/O error occurs */ public static URLResource fromUrl(String url) throws IOException { return new URLResource(SourceType.URL.resolve(url)); @@ -198,9 +200,9 @@ public static URLResource fromUrl(String url) throws IOException { /** * Use specified URL to find resource. * - * @param url - * @return - * @throws IOException fromUrl + * @param url used to build URLResource + * @return a URLResource + * @throws IOException if an I/O error occurs */ public static URLResource fromUrl(URL url) throws IOException { return new URLResource(url); @@ -209,10 +211,10 @@ public static URLResource fromUrl(URL url) throws IOException { /** * Use specified http URL and proxy to find resource. * - * @param url - * @param proxy - * @return - * @throws IOException fromUrl + * @param url used to build URLResource + * @param proxy the Proxy through which this connection will be made + * @return an input stream resource + * @throws IOException if an I/O error occurs */ public static InputStreamResource fromUrl(URL url, Proxy proxy) throws IOException { return fromInputStream(url.openConnection(proxy).getInputStream(), url.toExternalForm()); @@ -222,9 +224,6 @@ public static InputStreamResource fromUrl(URL url, Proxy proxy) throws IOExcepti * Not throw IO exception, just warning * * @see #from - * - * @param path - * @return tryFrom */ public static Stream tryFrom(final String path) { try { @@ -240,8 +239,6 @@ public static Stream tryFrom(final String path) { * Not throw IO exception, just warning * * @see #fromClassPath(ClassLoader) - * @param classLoader - * @return tryFromClassPath */ public static Stream tryFromClassPath(ClassLoader classLoader) { try { @@ -257,9 +254,6 @@ public static Stream tryFromClassPath(ClassLoader classLoader * Not throw IO exception, just warning * * @see #fromClassPath(ClassLoader, String) - * @param classLoader - * @param classPath - * @return tryFromClassPath */ public static Stream tryFromClassPath(ClassLoader classLoader, String classPath) { @@ -276,8 +270,6 @@ public static Stream tryFromClassPath(ClassLoader classLoader * Not throw IO exception, just warning * * @see #fromClassPath(String) - * @param classPath - * @return tryFromClassPath */ public static Stream tryFromClassPath(String classPath) { try { @@ -293,8 +285,6 @@ public static Stream tryFromClassPath(String classPath) { * Not throw IO exception, just warning * * @see #fromFileSystem(Path) - * @param path - * @return tryFromFileSystem */ public static FileSystemResource tryFromFileSystem(Path path) { try { @@ -310,8 +300,6 @@ public static FileSystemResource tryFromFileSystem(Path path) { * Not throw IO exception, just warning * * @see #fromFileSystem(String) - * @param path - * @return tryFromFileSystem */ public static Stream tryFromFileSystem(String path) { try { @@ -327,9 +315,6 @@ public static Stream tryFromFileSystem(String path) { * Not throw IO exception, just warning * * @see #fromInputStream(InputStream, String) - * @param inputStream - * @param location - * @return tryFromInputStream */ public static InputStreamResource tryFromInputStream(InputStream inputStream, String location) { try { @@ -344,8 +329,6 @@ public static InputStreamResource tryFromInputStream(InputStream inputStream, St * Not throw IO exception, just warning * * @see #fromUrl(String) - * @param url - * @return tryFromUrl */ public static URLResource tryFromUrl(String url) { try { @@ -360,8 +343,6 @@ public static URLResource tryFromUrl(String url) { * Not throw IO exception, just warning * * @see #fromUrl(URL) - * @param url - * @return tryFromUrl */ public static URLResource tryFromUrl(URL url) { try { @@ -376,9 +357,6 @@ public static URLResource tryFromUrl(URL url) { * Not throw IO exception, just warning * * @see #fromUrl(URL, Proxy) - * @param url - * @param proxy - * @return tryFromUrl */ public static InputStreamResource tryFromUrl(URL url, Proxy proxy) { try {