Skip to content

Commit 5c309d8

Browse files
committed
Add JavaFX demo
1 parent a218bd0 commit 5c309d8

21 files changed

Lines changed: 546 additions & 108 deletions

File tree

README.md

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -594,25 +594,10 @@ To build the framework use standard Git and Maven commands:
594594

595595
## Running Demo <a name="running-demo"></a>
596596

597-
The project includes 4 binary demo archives (`.tar`) with CLI and GUI consoles in `standalone` and `client`, `server`
598-
modes.
597+
The project contains various demo modules. Some of them can be run using the Maven Exec Plugin, some only via
598+
`.sh`/`.bat` scripts, and some support both options.
599599

600-
Each demo, in addition to framework components, includes two web components: a web server (Jetty 12 + Spring 6) and a
601-
web application. When the demo is running, you can open a browser and check the page at `http://127.0.0.1:8080/`. At
602-
the same time, it is important to note that the framework knows nothing about the web server or the web
603-
application — for it, they are just components.
604-
605-
Demo archives are created during the project build process and placed in the following directories:
606-
607-
```
608-
alpha-demo/alpha-demo-cli/target
609-
alpha-demo/alpha-demo-gui/target
610-
alpha-demo/alpha-demo-net/alpha-demo-net-cli/target
611-
alpha-demo/alpha-demo-net/alpha-demo-net-gui/target
612-
```
613-
The `alpha-demo-net-cli` and `alpha-demo-net-gui` projects also demonstrate installation using `install.sh/.bat` files.
614-
When this file is executed, all changes will occur within the framework directory. For details, refer to
615-
`script/installation.script`.
600+
Information on how to run a specific `Demo.java` is provided in the Javadoc of that class.
616601

617602
To connect the server use the following command (name: admin, password: admin):
618603

alpha-core/src/main/java/com/techsenger/alpha/core/api/component/ComponentConfigInfo.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package com.techsenger.alpha.core.api.component;
1818

19-
import com.techsenger.toolkit.core.os.OsUtils;
2019
import java.util.concurrent.ConcurrentHashMap;
2120

2221
/**
@@ -26,12 +25,4 @@
2625
*/
2726
public class ComponentConfigInfo extends ConcurrentHashMap<Object, Object> {
2827

29-
public static final String OS_FAMILY = "os.family";
30-
31-
public ComponentConfigInfo() {
32-
var os = OsUtils.getOs();
33-
if (os != null) {
34-
put(OS_FAMILY, os.toString().toLowerCase());
35-
}
36-
}
3728
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright 2018-2025 Pavel Castornii.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.techsenger.alpha.core.api.message;
18+
19+
/**
20+
*
21+
* @author Pavel Castornii
22+
*/
23+
public class SystemMessagePrinter extends AbstractMessagePrinter {
24+
25+
@Override
26+
public void printlnMessage(String message) {
27+
System.out.println(message);
28+
}
29+
30+
@Override
31+
public void printlnError(String error) {
32+
System.err.println(error);
33+
}
34+
}

alpha-core/src/test/java/com/techsenger/alpha/core/impl/component/ConfigXmlReaderTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,15 @@ public class ConfigXmlReaderTest {
3636

3737
private static final Logger logger = LoggerFactory.getLogger(ConfigXmlReaderTest.class);
3838

39+
private static final String OS_FAMILY = "os.family";
40+
3941
@Test
4042
public void read_nestedIfChooseConditionsForLinuxSystemProperty_success()
4143
throws URISyntaxException, ParserConfigurationException, SAXException, IOException {
4244
var uri = this.getClass().getResource("conditional-configuration.xml").toURI();
4345
var reader = new ConfigXmlReader();
4446
var configInfo = new ComponentConfigInfo();
45-
configInfo.put(ComponentConfigInfo.OS_FAMILY, "linux");
47+
configInfo.put(OS_FAMILY, "linux");
4648
var config = reader.read(new File(uri).toPath(), configInfo, null);
4749
var descriptors = config.getModules();
4850
assertThat(descriptors).hasSize(8);
@@ -63,7 +65,7 @@ public void read_nestedIfChooseConditionsForWindowsSystemProperty_success()
6365
var uri = this.getClass().getResource("conditional-configuration.xml").toURI();
6466
var reader = new ConfigXmlReader();
6567
var configInfo = new ComponentConfigInfo();
66-
configInfo.put(ComponentConfigInfo.OS_FAMILY, "windows");
68+
configInfo.put(OS_FAMILY, "windows");
6769
var config = reader.read(new File(uri).toPath(), configInfo, null);
6870
var descriptors = config.getModules();
6971
assertThat(descriptors).hasSize(5);
@@ -80,7 +82,7 @@ public void read_nestedIfChooseConditionsForMacSystemProperty_success()
8082
var uri = this.getClass().getResource("conditional-configuration.xml").toURI();
8183
var reader = new ConfigXmlReader();
8284
var configInfo = new ComponentConfigInfo();
83-
configInfo.put(ComponentConfigInfo.OS_FAMILY, "mac");
85+
configInfo.put(OS_FAMILY, "mac");
8486
var config = reader.read(new File(uri).toPath(), configInfo, null);
8587
var descriptors = config.getModules();
8688
assertThat(descriptors).hasSize(8);
@@ -100,7 +102,7 @@ public void read_nestedIfChooseConditionsForSolarisSystemProperty_success()
100102
var uri = this.getClass().getResource("conditional-configuration.xml").toURI();
101103
var reader = new ConfigXmlReader();
102104
var configInfo = new ComponentConfigInfo();
103-
configInfo.put(ComponentConfigInfo.OS_FAMILY, "solaris");
105+
configInfo.put(OS_FAMILY, "solaris");
104106
var config = reader.read(new File(uri).toPath(), configInfo, null);
105107
var descriptors = config.getModules();
106108
assertThat(descriptors).hasSize(5);

alpha-demo/alpha-demo-cli/pom.xml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@
1313
<name>Alpha - Demo CLI</name>
1414
<description>A demo of a standalone application with a CLI console</description>
1515

16-
<properties>
17-
<install.plugin.phase>package</install.plugin.phase>
18-
<dependency.plugin.skip>false</dependency.plugin.skip>
19-
<demo.main.module>com.techsenger.alpha.demo.cli</demo.main.module>
20-
<demo.main.dependency>com.techsenger.alpha.demo:alpha-demo-cli</demo.main.dependency>
21-
</properties>
22-
2316
<dependencies>
2417
<dependency>
2518
<groupId>org.slf4j</groupId>
@@ -81,7 +74,7 @@
8174
</goals>
8275
<configuration>
8376
<path>${project.build.directory}/framework</path>
84-
<mainClass>com.techsenger.alpha.demo.cli/com.techsenger.alpha.demo.cli.Demo</mainClass>
77+
<mainClass>com.techsenger.alpha.demo.cli/com.techsenger.alpha.demo.cli.CliDemo</mainClass>
8578
<modules>
8679
<module>
8780
<groupId>com.techsenger.alpha.demo</groupId>

alpha-demo/alpha-demo-cli/src/main/java/com/techsenger/alpha/demo/cli/Demo.java renamed to alpha-demo/alpha-demo-cli/src/main/java/com/techsenger/alpha/demo/cli/CliDemo.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,15 @@
2626
import org.slf4j.LoggerFactory;
2727

2828
/**
29+
* This demo shows how to work with the framework console.
30+
*
31+
* <p>To run this demo: build the project and run the scripts in the {@code target/framework/bin} folder.
2932
*
3033
* @author Pavel Castornii
3134
*/
32-
public final class Demo {
35+
public final class CliDemo {
3336

34-
private static final Logger logger = LoggerFactory.getLogger(Demo.class);
37+
private static final Logger logger = LoggerFactory.getLogger(CliDemo.class);
3538

3639
/**
3740
* @param args the command line arguments
@@ -58,7 +61,7 @@ private static void resolveAndStartComponent(Framework framework, String compone
5861
compManager.startComponent(componentName, componentVersion);
5962
}
6063

61-
private Demo() {
64+
private CliDemo() {
6265
// empty
6366
}
6467
}

alpha-demo/alpha-demo-gui/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@
1313
<name>Alpha - Demo GUI</name>
1414
<description>A demo of a standalone application with a GUI console</description>
1515

16-
<properties>
17-
<install.plugin.phase>package</install.plugin.phase>
18-
<dependency.plugin.skip>false</dependency.plugin.skip>
19-
</properties>
20-
2116
<dependencies>
2217
<dependency>
2318
<groupId>com.techsenger.alpha.demo</groupId>
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<parent>
5+
<groupId>com.techsenger.alpha.demo.jfx</groupId>
6+
<artifactId>alpha-demo-jfx</artifactId>
7+
<version>1.0.0-SNAPSHOT</version>
8+
</parent>
9+
10+
<groupId>com.techsenger.alpha.demo.jfx</groupId>
11+
<artifactId>alpha-demo-jfx-boot</artifactId>
12+
<packaging>jar</packaging>
13+
<name>Alpha - Demo JFX Boot</name>
14+
<description>A boot module for JavaFX demo</description>
15+
16+
<dependencies>
17+
<dependency>
18+
<!-- the core module must be compiled before the boot module -->
19+
<groupId>com.techsenger.alpha.demo.jfx</groupId>
20+
<artifactId>alpha-demo-jfx-core</artifactId>
21+
</dependency>
22+
<dependency>
23+
<groupId>org.slf4j</groupId>
24+
<artifactId>slf4j-api</artifactId>
25+
</dependency>
26+
<dependency>
27+
<groupId>org.apache.logging.log4j</groupId>
28+
<artifactId>log4j-core</artifactId>
29+
</dependency>
30+
<dependency>
31+
<groupId>org.apache.logging.log4j</groupId>
32+
<artifactId>log4j-jul</artifactId>
33+
</dependency>
34+
<dependency>
35+
<groupId>org.apache.logging.log4j</groupId>
36+
<artifactId>log4j-api</artifactId>
37+
</dependency>
38+
<dependency>
39+
<groupId>org.apache.logging.log4j</groupId>
40+
<artifactId>log4j-jcl</artifactId>
41+
</dependency>
42+
<dependency>
43+
<groupId>org.apache.logging.log4j</groupId>
44+
<artifactId>log4j-slf4j2-impl</artifactId>
45+
</dependency>
46+
<dependency>
47+
<groupId>com.techsenger.alpha</groupId>
48+
<artifactId>alpha-core</artifactId>
49+
</dependency>
50+
<dependency>
51+
<groupId>com.techsenger.toolkit</groupId>
52+
<artifactId>toolkit-core</artifactId>
53+
</dependency>
54+
<dependency>
55+
<groupId>org.fusesource.jansi</groupId>
56+
<artifactId>jansi</artifactId>
57+
</dependency>
58+
<dependency>
59+
<groupId>com.beust</groupId>
60+
<artifactId>jcommander</artifactId>
61+
</dependency>
62+
<dependency>
63+
<groupId>jakarta.el</groupId>
64+
<artifactId>jakarta.el-api</artifactId>
65+
</dependency>
66+
<dependency>
67+
<groupId>org.glassfish.expressly</groupId>
68+
<artifactId>expressly</artifactId>
69+
</dependency>
70+
</dependencies>
71+
72+
<build>
73+
<plugins>
74+
<plugin>
75+
<groupId>com.techsenger.alpha.assembly</groupId>
76+
<artifactId>alpha-assembly-maven-plugin</artifactId>
77+
<version>${project.version}</version>
78+
<executions>
79+
<execution>
80+
<phase>verify</phase>
81+
<goals>
82+
<goal>assemble-runtime</goal>
83+
</goals>
84+
<configuration>
85+
<path>${project.build.directory}/framework</path>
86+
</configuration>
87+
</execution>
88+
</executions>
89+
</plugin>
90+
<plugin>
91+
<groupId>org.codehaus.mojo</groupId>
92+
<artifactId>exec-maven-plugin</artifactId>
93+
<version>${exec.plugin.version}</version>
94+
<configuration>
95+
<executable>java</executable>
96+
<arguments>
97+
<argument>-Dmvn.localrepo=file://${settings.localRepository}</argument>
98+
<argument>-Dproject.version=${project.version}</argument>
99+
100+
<argument>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=localhost:7700</argument>
101+
<argument>-Dorg.jboss.logging.provider=log4j</argument>
102+
<argument>-Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager</argument>
103+
<argument>-Dcom.techsenger.alpha.core.root.path=${project.build.directory}/framework</argument>
104+
<argument>-Djava.net.preferIPv4Stack=true</argument>
105+
<argument>-Djava.io.tmpdir="$ROOT_PATH/temp"</argument>
106+
<argument>-Djava.io.tmpdir="$ROOT_PATH/temp"</argument>
107+
<argument>-Dfile.encoding=UTF-8</argument>
108+
<argument>--add-modules</argument>
109+
<argument>ALL-DEFAULT</argument>
110+
<argument>--add-modules</argument>
111+
<argument>org.apache.logging.log4j,org.apache.logging.log4j.jul</argument>
112+
<argument>--add-opens</argument>
113+
<argument>java.base/java.time=com.techsenger.alpha.core</argument>
114+
<argument>--add-opens</argument>
115+
<argument>java.base/java.lang=com.techsenger.alpha.core</argument>
116+
<argument>--enable-native-access=com.techsenger.alpha.core</argument>
117+
<argument>--module-path</argument>
118+
<modulepath/> <!-- placeholder that automatically resolves and injects the module path -->
119+
<argument>--module</argument>
120+
<argument>com.techsenger.alpha.demo.jfx.boot/com.techsenger.alpha.demo.jfx.boot.JfxDemo</argument>
121+
</arguments>
122+
</configuration>
123+
</plugin>
124+
</plugins>
125+
</build>
126+
</project>

0 commit comments

Comments
 (0)