Skip to content

Commit

Permalink
Improve javafx cdi module, fix some issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
finesoft committed Oct 8, 2022
1 parent d1051aa commit 54d73a8
Show file tree
Hide file tree
Showing 38 changed files with 1,137 additions and 255 deletions.
11 changes: 2 additions & 9 deletions corant-boms/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<version.hppc>0.9.1</version.hppc>
<version.hsqldb>2.6.1</version.hsqldb>
<version.icu4j>67.1</version.icu4j>
<version.jackson>2.13.3</version.jackson>
<version.jackson>2.13.4</version.jackson>
<version.jandex>2.4.2.Final</version.jandex>
<version.jasperreports>6.10.0</version.jasperreports>
<version.javafx>11.0.2</version.javafx>
Expand Down Expand Up @@ -104,7 +104,7 @@
<version.keycloak>6.0.1</version.keycloak>
<version.kotlin>1.3.72</version.kotlin>
<version.kryo>5.1.1</version.kryo>
<version.log4j2>2.18.0</version.log4j2>
<version.log4j2>2.19.0</version.log4j2>
<version.lombok>1.18.16</version.lombok>
<version.maven-bundle-plugin>5.1.2</version.maven-bundle-plugin>
<version.maven-compiler-plugin>3.8.0</version.maven-compiler-plugin>
Expand Down Expand Up @@ -683,13 +683,6 @@
<version>${version.jakarta.activation-api}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx</artifactId>
<version>${version.javafx}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-base</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public <C extends Collection<T>, T> C convert(Object value, Class<C> collectionC
@Override
public <C extends Collection<T>, T> C convert(Object value, Class<T> clazz,
IntFunction<C> collectionFactory, Object... hints) {
return Conversion.convert(value, clazz, collectionFactory, mapOf(hints));
return Conversion.convert(value, clazz, collectionFactory, mapOf(hints), false);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,19 @@ 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#";
public static final String RUN_MAIN_CLASS_PH = "#MAIN_CLASS#";
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";

Expand Down Expand Up @@ -150,8 +153,13 @@ Archive buildArchive() throws IOException {

List<Entry> resolveBinFiles() throws IOException {
List<Entry> 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;
}
Expand All @@ -176,12 +184,12 @@ List<Entry> resolveConfigFiles() {

List<Entry> resolveLaunchs() throws IOException {
List<Entry> 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));
}
Expand Down Expand Up @@ -212,34 +220,36 @@ List<Entry> 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand Down Expand Up @@ -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;
}
Expand All @@ -173,6 +186,10 @@ public boolean isUseDirectRunner() {
return useDirectRunner;
}

public boolean isUseJavaw() {
return useJavaw;
}

public boolean isWar() {
return project.getPackaging().equals("war");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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#

Expand Down Expand Up @@ -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%"
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ public class RandomWebServerPortSourceProvider implements ConfigSourceProvider {

@Override
public Iterable<ConfigSource> 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 {
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,9 @@
<groupId>org.corant</groupId>
<artifactId>corant-shared</artifactId>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
</dependency>
</dependencies>
</project>
Loading

0 comments on commit 54d73a8

Please sign in to comment.