├── IgniteDemo
├── .gitignore
├── .mvn
│ └── wrapper
│ │ ├── MavenWrapperDownloader.java
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── README.md
├── mvnw
├── mvnw.cmd
├── nbactions.xml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── asgteach
│ │ │ └── springignite
│ │ │ ├── ExampleApp.java
│ │ │ ├── PrimaryController.java
│ │ │ ├── SecondaryController.java
│ │ │ ├── SpringBootIgniteApp.java
│ │ │ └── service
│ │ │ └── WeatherService.java
│ └── resources
│ │ └── com
│ │ └── asgteach
│ │ └── springignite
│ │ ├── primary.fxml
│ │ ├── secondary.fxml
│ │ └── styles.css
│ └── test
│ └── java
│ └── com
│ └── gluonhq
│ └── springignitedemo
│ └── SpringIgniteDemoApplicationTests.java
├── Music.sql
├── README.md
├── SpringBootClientFXMultiThread
├── .gitignore
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── mvnw
├── mvnw.cmd
├── nbactions.xml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── asgteach
│ │ │ └── springboot
│ │ │ ├── MusicClientApp.java
│ │ │ ├── MusicFXApp.java
│ │ │ ├── ViewController.java
│ │ │ ├── domain
│ │ │ └── MusicCategory.java
│ │ │ └── service
│ │ │ └── MusicRESTService.java
│ └── resources
│ │ ├── application.properties
│ │ └── com
│ │ └── asgteach
│ │ └── springboot
│ │ └── view.fxml
│ └── test
│ └── java
│ └── com
│ └── asgteach
│ └── springbootrestjfx
│ └── SpringbootrestjfxApplicationTests.java
├── SpringBootRest
├── .gitignore
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── mvnw
├── mvnw.cmd
├── nb-configuration.xml
├── nbactions.xml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── asgteach
│ │ │ └── springbootrest
│ │ │ ├── SpringbootrestApplication.java
│ │ │ ├── domain
│ │ │ └── MusicCategory.java
│ │ │ └── service
│ │ │ ├── MusicCategoryNotFoundException.java
│ │ │ ├── MusicCategoryResource.java
│ │ │ └── MusicRepository.java
│ └── resources
│ │ ├── application.properties
│ │ ├── data.sql
│ │ └── schema.sql
│ └── test
│ └── java
│ └── com
│ └── asgteach
│ └── springbootrest
│ └── SpringbootrestApplicationTests.java
├── SpringBootRestMySql
├── .gitignore
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── mvnw
├── mvnw.cmd
├── nb-configuration.xml
├── nbactions.xml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── asgteach
│ │ │ └── springbootrest
│ │ │ ├── SpringbootrestApplication.java
│ │ │ ├── domain
│ │ │ └── MusicCategory.java
│ │ │ └── service
│ │ │ ├── MusicCategoryNotFoundException.java
│ │ │ ├── MusicCategoryResource.java
│ │ │ └── MusicRepository.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── com
│ └── asgteach
│ └── springbootrest
│ └── SpringbootrestApplicationTests.java
├── SpringBootWebClientFX
├── .gitignore
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── mvnw
├── mvnw.cmd
├── nbactions.xml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── asgteach
│ │ │ └── springboot
│ │ │ ├── MusicClientApp.java
│ │ │ ├── MusicFXApp.java
│ │ │ ├── ViewController.java
│ │ │ ├── domain
│ │ │ └── MusicCategory.java
│ │ │ └── service
│ │ │ └── MusicRESTService.java
│ └── resources
│ │ ├── application.properties
│ │ └── com
│ │ └── asgteach
│ │ └── springboot
│ │ └── view.fxml
│ └── test
│ └── java
│ └── com
│ └── asgteach
│ └── springbootrestjfx
│ └── SpringbootrestjfxApplicationTests.java
├── WeatherJFXClient
├── .gitignore
├── .mvn
│ └── wrapper
│ │ ├── MavenWrapperDownloader.java
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── README.md
├── mvnw
├── mvnw.cmd
├── nbactions.xml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── asgteach
│ │ │ └── weatherclient
│ │ │ ├── PrimaryController.java
│ │ │ ├── SecondaryController.java
│ │ │ ├── WeatherClientApplication.java
│ │ │ ├── WeatherFXApp.java
│ │ │ ├── domain
│ │ │ └── Weather.java
│ │ │ └── service
│ │ │ └── WeatherClient.java
│ └── resources
│ │ ├── application.properties
│ │ └── com
│ │ └── asgteach
│ │ └── weatherclient
│ │ ├── primary.fxml
│ │ ├── secondary.fxml
│ │ └── styles.css
│ └── test
│ └── java
│ └── com
│ └── gluonhq
│ └── springignitedemo
│ └── SpringIgniteDemoApplicationTests.java
└── WeatherService
├── .gitignore
├── .mvn
└── wrapper
│ ├── maven-wrapper.jar
│ └── maven-wrapper.properties
├── mvnw
├── mvnw.cmd
├── nbactions.xml
├── pom.xml
└── src
├── main
├── java
│ └── com
│ │ └── asgteach
│ │ └── weatherservice
│ │ ├── WeatherController.java
│ │ ├── WeatherServiceApplication.java
│ │ ├── domain
│ │ ├── Forecaster.java
│ │ └── Weather.java
│ │ └── repository
│ │ ├── ReactiveWeatherRepository.java
│ │ └── WeatherRepository.java
└── resources
│ └── application.properties
└── test
└── java
└── com
└── asgteach
└── weatherservice
└── WeatherserviceApplicationTests.java
/IgniteDemo/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/IgniteDemo/.mvn/wrapper/MavenWrapperDownloader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007-present the original author or authors.
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 | * https://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 | import java.net.*;
17 | import java.io.*;
18 | import java.nio.channels.*;
19 | import java.util.Properties;
20 |
21 | public class MavenWrapperDownloader {
22 |
23 | private static final String WRAPPER_VERSION = "0.5.6";
24 | /**
25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
26 | */
27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
29 |
30 | /**
31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
32 | * use instead of the default one.
33 | */
34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
35 | ".mvn/wrapper/maven-wrapper.properties";
36 |
37 | /**
38 | * Path where the maven-wrapper.jar will be saved to.
39 | */
40 | private static final String MAVEN_WRAPPER_JAR_PATH =
41 | ".mvn/wrapper/maven-wrapper.jar";
42 |
43 | /**
44 | * Name of the property which should be used to override the default download url for the wrapper.
45 | */
46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
47 |
48 | public static void main(String args[]) {
49 | System.out.println("- Downloader started");
50 | File baseDirectory = new File(args[0]);
51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
52 |
53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom
54 | // wrapperUrl parameter.
55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
56 | String url = DEFAULT_DOWNLOAD_URL;
57 | if(mavenWrapperPropertyFile.exists()) {
58 | FileInputStream mavenWrapperPropertyFileInputStream = null;
59 | try {
60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
61 | Properties mavenWrapperProperties = new Properties();
62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
64 | } catch (IOException e) {
65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
66 | } finally {
67 | try {
68 | if(mavenWrapperPropertyFileInputStream != null) {
69 | mavenWrapperPropertyFileInputStream.close();
70 | }
71 | } catch (IOException e) {
72 | // Ignore ...
73 | }
74 | }
75 | }
76 | System.out.println("- Downloading from: " + url);
77 |
78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
79 | if(!outputFile.getParentFile().exists()) {
80 | if(!outputFile.getParentFile().mkdirs()) {
81 | System.out.println(
82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
83 | }
84 | }
85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
86 | try {
87 | downloadFileFromURL(url, outputFile);
88 | System.out.println("Done");
89 | System.exit(0);
90 | } catch (Throwable e) {
91 | System.out.println("- Error downloading");
92 | e.printStackTrace();
93 | System.exit(1);
94 | }
95 | }
96 |
97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception {
98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
99 | String username = System.getenv("MVNW_USERNAME");
100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
101 | Authenticator.setDefault(new Authenticator() {
102 | @Override
103 | protected PasswordAuthentication getPasswordAuthentication() {
104 | return new PasswordAuthentication(username, password);
105 | }
106 | });
107 | }
108 | URL website = new URL(urlString);
109 | ReadableByteChannel rbc;
110 | rbc = Channels.newChannel(website.openStream());
111 | FileOutputStream fos = new FileOutputStream(destination);
112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
113 | fos.close();
114 | rbc.close();
115 | }
116 |
117 | }
118 |
--------------------------------------------------------------------------------
/IgniteDemo/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gailasgteach/JavaFX-SpringBoot-Samples/91efd37a37c5560541a25ade6b0932d8e2606cff/IgniteDemo/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/IgniteDemo/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.2/apache-maven-3.8.2-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
3 |
--------------------------------------------------------------------------------
/IgniteDemo/README.md:
--------------------------------------------------------------------------------
1 | # Spring Ignite Demo
2 |
3 | Simple application, demonstrating the use of [Gluon Ignite](https://github.com/gluonhq/ignite) with SpringBoot.
4 |
--------------------------------------------------------------------------------
/IgniteDemo/mvnw.cmd:
--------------------------------------------------------------------------------
1 | @REM ----------------------------------------------------------------------------
2 | @REM Licensed to the Apache Software Foundation (ASF) under one
3 | @REM or more contributor license agreements. See the NOTICE file
4 | @REM distributed with this work for additional information
5 | @REM regarding copyright ownership. The ASF licenses this file
6 | @REM to you under the Apache License, Version 2.0 (the
7 | @REM "License"); you may not use this file except in compliance
8 | @REM with the License. You may obtain a copy of the License at
9 | @REM
10 | @REM https://www.apache.org/licenses/LICENSE-2.0
11 | @REM
12 | @REM Unless required by applicable law or agreed to in writing,
13 | @REM software distributed under the License is distributed on an
14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | @REM KIND, either express or implied. See the License for the
16 | @REM specific language governing permissions and limitations
17 | @REM under the License.
18 | @REM ----------------------------------------------------------------------------
19 |
20 | @REM ----------------------------------------------------------------------------
21 | @REM Maven Start Up Batch script
22 | @REM
23 | @REM Required ENV vars:
24 | @REM JAVA_HOME - location of a JDK home dir
25 | @REM
26 | @REM Optional ENV vars
27 | @REM M2_HOME - location of maven2's installed home dir
28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
31 | @REM e.g. to debug Maven itself, use
32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
34 | @REM ----------------------------------------------------------------------------
35 |
36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
37 | @echo off
38 | @REM set title of command window
39 | title %0
40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
42 |
43 | @REM set %HOME% to equivalent of $HOME
44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
45 |
46 | @REM Execute a user defined script before this one
47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending
49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
51 | :skipRcPre
52 |
53 | @setlocal
54 |
55 | set ERROR_CODE=0
56 |
57 | @REM To isolate internal variables from possible post scripts, we use another setlocal
58 | @setlocal
59 |
60 | @REM ==== START VALIDATION ====
61 | if not "%JAVA_HOME%" == "" goto OkJHome
62 |
63 | echo.
64 | echo Error: JAVA_HOME not found in your environment. >&2
65 | echo Please set the JAVA_HOME variable in your environment to match the >&2
66 | echo location of your Java installation. >&2
67 | echo.
68 | goto error
69 |
70 | :OkJHome
71 | if exist "%JAVA_HOME%\bin\java.exe" goto init
72 |
73 | echo.
74 | echo Error: JAVA_HOME is set to an invalid directory. >&2
75 | echo JAVA_HOME = "%JAVA_HOME%" >&2
76 | echo Please set the JAVA_HOME variable in your environment to match the >&2
77 | echo location of your Java installation. >&2
78 | echo.
79 | goto error
80 |
81 | @REM ==== END VALIDATION ====
82 |
83 | :init
84 |
85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
86 | @REM Fallback to current working directory if not found.
87 |
88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
90 |
91 | set EXEC_DIR=%CD%
92 | set WDIR=%EXEC_DIR%
93 | :findBaseDir
94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound
95 | cd ..
96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound
97 | set WDIR=%CD%
98 | goto findBaseDir
99 |
100 | :baseDirFound
101 | set MAVEN_PROJECTBASEDIR=%WDIR%
102 | cd "%EXEC_DIR%"
103 | goto endDetectBaseDir
104 |
105 | :baseDirNotFound
106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
107 | cd "%EXEC_DIR%"
108 |
109 | :endDetectBaseDir
110 |
111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
112 |
113 | @setlocal EnableExtensions EnableDelayedExpansion
114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
116 |
117 | :endReadAdditionalConfig
118 |
119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
122 |
123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
124 |
125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
127 | )
128 |
129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data.
131 | if exist %WRAPPER_JAR% (
132 | if "%MVNW_VERBOSE%" == "true" (
133 | echo Found %WRAPPER_JAR%
134 | )
135 | ) else (
136 | if not "%MVNW_REPOURL%" == "" (
137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
138 | )
139 | if "%MVNW_VERBOSE%" == "true" (
140 | echo Couldn't find %WRAPPER_JAR%, downloading it ...
141 | echo Downloading from: %DOWNLOAD_URL%
142 | )
143 |
144 | powershell -Command "&{"^
145 | "$webclient = new-object System.Net.WebClient;"^
146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
148 | "}"^
149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
150 | "}"
151 | if "%MVNW_VERBOSE%" == "true" (
152 | echo Finished downloading %WRAPPER_JAR%
153 | )
154 | )
155 | @REM End of extension
156 |
157 | @REM Provide a "standardized" way to retrieve the CLI args that will
158 | @REM work with both Windows and non-Windows executions.
159 | set MAVEN_CMD_LINE_ARGS=%*
160 |
161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
162 | if ERRORLEVEL 1 goto error
163 | goto end
164 |
165 | :error
166 | set ERROR_CODE=1
167 |
168 | :end
169 | @endlocal & set ERROR_CODE=%ERROR_CODE%
170 |
171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending
173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
175 | :skipRcPost
176 |
177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause
179 |
180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
181 |
182 | exit /B %ERROR_CODE%
183 |
--------------------------------------------------------------------------------
/IgniteDemo/nbactions.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | run
5 |
6 | jar
7 |
8 |
9 | clean
10 | javafx:run
11 |
12 |
13 |
14 | debug
15 |
16 | jar
17 |
18 |
19 | process-classes
20 | org.codehaus.mojo:exec-maven-plugin:3.0.0:exec
21 |
22 |
23 | -agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address}
24 | ${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs}
25 |
26 | com.asgteach.springignite.SpringBootIgniteApp
27 | java
28 | true
29 |
30 |
31 |
32 | profile
33 |
34 | jar
35 |
36 |
37 | process-classes
38 | org.codehaus.mojo:exec-maven-plugin:3.0.0:exec
39 |
40 |
41 |
42 | ${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs}
43 | com.asgteach.springignite.SpringBootIgniteApp
44 | java
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/IgniteDemo/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 | 4.0.0
7 |
8 | org.springframework.boot
9 | spring-boot-starter-parent
10 | 2.6.2
11 |
12 |
13 | com.asgteach
14 | spring-ignite-demo
15 | 0.0.1-SNAPSHOT
16 | IgniteDemo
17 | Demo project for Spring Boot with Gluon Ignite
18 |
19 | 17
20 | 17.0.0.1
21 | 0.0.8
22 | com.asgteach.springignite.SpringBootIgniteApp
23 |
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter
28 |
29 |
30 | org.springframework.boot
31 | spring-boot-starter-test
32 | test
33 |
34 |
35 | org.openjfx
36 | javafx-controls
37 | ${javafxVersion}
38 |
39 |
40 | org.openjfx
41 | javafx-fxml
42 | ${javafxVersion}
43 |
44 |
45 | com.gluonhq
46 | ignite-spring
47 | 1.2.2
48 |
49 |
50 |
51 |
52 |
53 |
54 | org.springframework.boot
55 | spring-boot-maven-plugin
56 |
57 |
58 | org.openjfx
59 | javafx-maven-plugin
60 | ${javafx-maven-plugin-version}
61 |
62 | ${mainClassName}
63 |
64 |
65 |
66 |
67 | default-cli
68 |
69 | ${mainClassName}
70 |
71 |
72 |
73 |
74 | debug
75 |
76 | ${mainClassName}
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/IgniteDemo/src/main/java/com/asgteach/springignite/ExampleApp.java:
--------------------------------------------------------------------------------
1 | // ExampleApp.java - ExampleApp interface
2 | package com.asgteach.springignite;
3 | import java.net.URL;
4 |
5 | public interface ExampleApp {
6 | default URL getViewLocation() {
7 | return getClass().getResource("primary.fxml");
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/IgniteDemo/src/main/java/com/asgteach/springignite/PrimaryController.java:
--------------------------------------------------------------------------------
1 | // PrimaryController.java - JavaFX primary controller
2 | package com.asgteach.springignite;
3 | import com.asgteach.springignite.service.WeatherService;
4 | import java.io.IOException;
5 | import java.net.URL;
6 | import java.util.ResourceBundle;
7 | import javafx.event.ActionEvent;
8 | import javafx.fxml.FXML;
9 | import javafx.fxml.FXMLLoader;
10 | import javafx.fxml.Initializable;
11 | import javafx.scene.control.Label;
12 | import org.springframework.beans.factory.annotation.Autowired;
13 | import org.springframework.stereotype.Component;
14 |
15 | @Component
16 | public class PrimaryController implements Initializable {
17 |
18 | @FXML
19 | private Label weatherLabel;
20 |
21 | @Autowired
22 | private WeatherService weatherService;
23 |
24 | @Autowired
25 | private FXMLLoader fxmlLoader;
26 |
27 | @FXML
28 | public void loadWeatherForecast(ActionEvent actionEvent) {
29 | System.out.println("Load Weather Forecast Action");
30 | this.weatherLabel.setText(weatherService.getWeatherForecast());
31 | }
32 |
33 |
34 | @Override
35 | public void initialize(URL location, ResourceBundle resources) {
36 | System.out.println("PrimaryController initialized!");
37 | }
38 |
39 | @FXML
40 | private void switchToSecondary(ActionEvent event) throws IOException {
41 | System.out.println("Switch to Secondary Action");
42 | fxmlLoader.setLocation(getClass().getResource("secondary.fxml"));
43 | SpringBootIgniteApp.setRoot(fxmlLoader.load());
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/IgniteDemo/src/main/java/com/asgteach/springignite/SecondaryController.java:
--------------------------------------------------------------------------------
1 | // SecondaryController.java - JavaFX secondary controller
2 | package com.asgteach.springignite;
3 | import java.io.IOException;
4 | import java.net.URL;
5 | import java.util.ResourceBundle;
6 | import javafx.event.ActionEvent;
7 | import javafx.fxml.FXML;
8 | import javafx.fxml.FXMLLoader;
9 | import javafx.fxml.Initializable;
10 | import org.springframework.beans.factory.annotation.Autowired;
11 | import org.springframework.stereotype.Component;
12 |
13 | @Component
14 | public class SecondaryController implements Initializable {
15 |
16 | @Autowired
17 | private FXMLLoader fxmlLoader;
18 |
19 | @Override
20 | public void initialize(URL location, ResourceBundle resources) {
21 | System.out.println("SecondaryController initialized!");
22 | }
23 |
24 | @FXML
25 | private void switchToPrimary(ActionEvent event) throws IOException {
26 | System.out.println("Switch to Primary Action");
27 | fxmlLoader.setLocation(getClass().getResource("primary.fxml"));
28 | SpringBootIgniteApp.setRoot(fxmlLoader.load());
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/IgniteDemo/src/main/java/com/asgteach/springignite/SpringBootIgniteApp.java:
--------------------------------------------------------------------------------
1 | // SpringBootIgniteApp.java - Main application
2 | package com.asgteach.springignite;
3 | import com.gluonhq.ignite.spring.SpringContext;
4 | import java.io.IOException;
5 | import javafx.application.Application;
6 | import javafx.fxml.FXMLLoader;
7 | import javafx.scene.Parent;
8 | import javafx.scene.Scene;
9 | import javafx.stage.Stage;
10 | import org.springframework.beans.factory.annotation.Autowired;
11 | import org.springframework.boot.SpringApplication;
12 | import org.springframework.boot.autoconfigure.SpringBootApplication;
13 | import org.springframework.context.annotation.ComponentScan;
14 |
15 | @SpringBootApplication
16 | @ComponentScan({
17 | "com.gluonhq.ignite.spring",
18 | "com.asgteach.springignite.service"
19 | })
20 | public class SpringBootIgniteApp extends Application
21 | implements ExampleApp {
22 |
23 | public static void main(String[] args) {
24 | Application.launch(SpringBootIgniteApp.class, args);
25 | }
26 |
27 | @Autowired
28 | private FXMLLoader loader;
29 |
30 | private final SpringContext context = new SpringContext(this);
31 | private static Scene scene;
32 |
33 | @Override
34 | public void start(Stage stage) throws IOException {
35 | context.init(() -> SpringApplication.run(SpringBootIgniteApp.class));
36 | loader.setLocation(getViewLocation());
37 | Parent primaryView = loader.load();
38 | stage.setTitle("Spring Boot Ignite Example");
39 | stage.setScene(scene = new Scene(primaryView));
40 | stage.show();
41 | }
42 |
43 | static void setRoot(Parent view) {
44 | scene.setRoot(view);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/IgniteDemo/src/main/java/com/asgteach/springignite/service/WeatherService.java:
--------------------------------------------------------------------------------
1 | // WeatherService.java - Weather service
2 | package com.asgteach.springignite.service;
3 | import org.springframework.stereotype.Service;
4 |
5 | @Service
6 | public class WeatherService {
7 | private final String[] forecasts = {
8 | "Hot and sunny. Bring your sunscreen.",
9 | "It's gonna snow. Look out, winter is coming.",
10 | "Foggy and cold. Time for an espresso.",
11 | "Rain is on the way. Don't forget your umbrella.",
12 | "Breezy with a few fluffy clouds. Let's go sailing."
13 | };
14 |
15 | public String getWeatherForecast() {
16 | int index = (int)(Math.random() * forecasts.length);
17 | return forecasts[index];
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/IgniteDemo/src/main/resources/com/asgteach/springignite/primary.fxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
13 |
18 |
20 |
21 |
22 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/IgniteDemo/src/main/resources/com/asgteach/springignite/secondary.fxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/IgniteDemo/src/main/resources/com/asgteach/springignite/styles.css:
--------------------------------------------------------------------------------
1 | .button {
2 | -fx-font-weight: bold;
3 | }
4 |
--------------------------------------------------------------------------------
/IgniteDemo/src/test/java/com/gluonhq/springignitedemo/SpringIgniteDemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.gluonhq.springignitedemo;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class SpringIgniteDemoApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/Music.sql:
--------------------------------------------------------------------------------
1 |
2 | drop table Tracks;
3 | drop table Recordings;
4 | drop table MusicCategories;
5 | drop table RecordingArtists;
6 |
7 |
8 |
9 | /*
10 | okay if this statement fails with
11 | Error code -1, SQL state X0Y68: Schema 'MUSIC' already exists.
12 | */
13 | /*create schema Music; */
14 |
15 | create table MusicCategories
16 | (MusicCategoryID integer not null primary key AUTO_INCREMENT,
17 | MusicCategory varchar(20));
18 |
19 | create table RecordingArtists
20 | (RecordingArtistID integer not null primary key AUTO_INCREMENT,
21 | RecordingArtistName varchar(36),
22 | Notes varchar(200));
23 |
24 | create table Recordings
25 | (RecordingID integer not null primary key AUTO_INCREMENT,
26 | RecordingTitle varchar(50),
27 | RecordingArtistID integer,
28 | MusicCategoryID integer,
29 | RecordingLabel varchar(36),
30 | Format varchar(20),
31 | NumberofTracks smallint,
32 | Notes varchar(200),
33 | foreign key (RecordingArtistID)
34 | references RecordingArtists(RecordingArtistID),
35 | foreign key (MusicCategoryID)
36 | references MusicCategories(MusicCategoryID));
37 |
38 | create table Tracks
39 | (TrackID integer not null primary key AUTO_INCREMENT,
40 | TrackNumber smallint,
41 | TrackTitle varchar(100),
42 | TrackLength varchar(10),
43 | RecordingID integer,
44 | foreign key (RecordingID)
45 | references Recordings(RecordingID));
46 |
47 | insert into RecordingArtists
48 | values (1, 'The Philadelphia Orchestra', '');
49 | insert into RecordingArtists
50 | values (2, 'Doors', '');
51 | insert into RecordingArtists
52 | values (3, 'John Lennon', '');
53 | insert into RecordingArtists
54 | values (4, 'Santana', '');
55 | insert into RecordingArtists
56 | values (5, 'Paul Simon', '');
57 | insert into RecordingArtists
58 | values (6, 'Isam Band', '');
59 | insert into RecordingArtists
60 | values (9, 'It''s a Beautiful Day', '');
61 | insert into RecordingArtists
62 | values (7, 'Beatles', '');
63 |
64 |
65 | insert into MusicCategories
66 | values (1, 'Classical');
67 | insert into MusicCategories
68 | values (2, 'Rock');
69 | insert into MusicCategories
70 | values (3, 'Jazz');
71 | insert into MusicCategories
72 | values (4, 'Rap');
73 | insert into MusicCategories
74 | values (5, 'Country');
75 | insert into MusicCategories
76 | values (6, 'Musical Theatre');
77 | insert into MusicCategories
78 | values (7, 'Blues');
79 | insert into MusicCategories
80 | values (8, 'Alternative');
81 |
82 | insert into Recordings
83 | values (1, 'Orff: Carmina Burana', 1, 1, 'Sony Classical', '', 11, '');
84 | insert into Recordings
85 | values (2, 'Doors', 2, 2, 'Elektra', '', 11, '');
86 | insert into Recordings
87 | values (3, 'Imagine', 3, 2, 'Warner Brothers', '', 21, '');
88 | insert into Recordings
89 | values (4, 'Santana', 4, 2, 'Columbia', '', 9, '');
90 | insert into Recordings
91 | values (5, 'Graceland', 5, 2, 'Warner Brothers', '', 11, '');
92 | insert into Recordings
93 | values (6, 'Stay Awhile', 6, 2, 'Spragueland', '', 13, '');
94 | insert into Recordings
95 | values (7, 'Sgt. Pepper''s Lonely Hearts Club Band',
96 | 7, 2, 'EMI Records', '', 12, '');
97 |
98 | insert into Tracks
99 | values (1, 1, 'O Fortuna', '2:44', 1);
100 | insert into Tracks
101 | values (2, 2, 'Fortune plango vulnera', '2:39', 1);
102 | insert into Tracks
103 | values (3, 3, 'Veris leta facies', '3:26', 1);
104 | insert into Tracks
105 | values (4, 4, 'Omnia Sol temperat', '1:47', 1);
106 | insert into Tracks
107 | values (5, 5, 'Ecce gratum', '2:35', 1);
108 | insert into Tracks
109 | values (6, 6, 'Tanz', '1:36', 1);
110 | insert into Tracks
111 | values (7, 7, 'Floret silva', '3:15', 1);
112 | insert into Tracks
113 | values (8, 8, 'Chramet, gip die varwe mir', '3:11', 1);
114 | insert into Tracks
115 | values (9, 9, 'Reie', '1:49', 1);
116 | insert into Tracks
117 | values (10, 10, 'Swazhie get umbe', '2:31', 1);
118 | insert into Tracks
119 | values (11, 11, 'Were deu werlt alle min', '0:55', 1);
120 |
121 | insert into Tracks
122 | values (12, 1, 'Break on Through', '2:25', 2);
123 | insert into Tracks
124 | values (13, 2, 'Soul Kitchen', '3:30', 2);
125 | insert into Tracks
126 | values (14, 3, 'The Crystal Ship', '2:30', 2);
127 | insert into Tracks
128 | values (15, 4, 'Twentieth Century Fox', '2:30', 2);
129 | insert into Tracks
130 | values (16, 5, 'Alabama Song', '3:15', 2);
131 | insert into Tracks
132 | values (17, 6, 'Light My Fire', '6:30', 2);
133 | insert into Tracks
134 | values (18, 7, 'Back Door Man', '3:30', 2);
135 | insert into Tracks
136 | values (19, 8, 'I Looked At You', '2:18', 2);
137 | insert into Tracks
138 | values (20, 9, 'End Of The Night', '2:49', 2);
139 | insert into Tracks
140 | values (21, 10, 'Take It As It Comes', '2:13', 2);
141 | insert into Tracks
142 | values (22, 11, 'The End', '11:35', 2);
143 |
144 | insert into Tracks
145 | values (25, 1, 'Real Love', '2:30', 3);
146 | insert into Tracks
147 | values (26, 2, 'Twist and Shout', '2:32', 3);
148 | insert into Tracks
149 | values (27, 3, 'Help', '2:17', 3);
150 | insert into Tracks
151 | values (28, 4, 'In My Life', '2:25', 3);
152 | insert into Tracks
153 | values (29, 5, 'Strawberry Fields Forever', '4:06', 3);
154 | insert into Tracks
155 | values (30, 6, 'A Day in the Life', '5:00', 3);
156 | insert into Tracks
157 | values (31, 7, 'Revolution', '3:21', 3);
158 | insert into Tracks
159 | values (32, 8, 'The Ballad of John & Yoko', '2:58', 3);
160 | insert into Tracks
161 | values (33, 9, 'Julia', '2:57', 3);
162 | insert into Tracks
163 | values (34, 10, 'Don''t Let Me Down', '3:30', 3);
164 | insert into Tracks
165 | values (35, 11, 'Give Peace A Chance', '3:30', 3);
166 | insert into Tracks
167 | values (36, 12, 'How?', '3:37', 3);
168 | insert into Tracks
169 | values (37, 13, 'Imagine (Rehearsal)', '1:26', 3);
170 | insert into Tracks
171 | values (38, 14, 'God', '4:04', 3);
172 | insert into Tracks
173 | values (39, 15, 'Mother', '5:15', 3);
174 | insert into Tracks
175 | values (40, 16, 'Stand By Me', '3:30', 3);
176 | insert into Tracks
177 | values (41, 17, 'Jealous Guy', '4:10', 3);
178 | insert into Tracks
179 | values (42, 18, 'Woman', '3:32', 3);
180 | insert into Tracks
181 | values (43, 19, 'Beautiful Boy', '3:54', 3);
182 | insert into Tracks
183 | values (44, 20, '(Just Like) Starting Over', '4:05', 3);
184 | insert into Tracks
185 | values (45, 21, 'Imagine', '3:00', 3);
186 |
187 | insert into Tracks
188 | values (46, 6, 'Persuasion', '2:33', 4);
189 | insert into Tracks
190 | values (47, 7, 'Treat', '4:43', 4);
191 | insert into Tracks
192 | values (48, 8, 'You Just Don''t Care', '4:34', 4);
193 | insert into Tracks
194 | values (49, 9, 'Soul Sacrifice', '6:37', 4);
195 | insert into Tracks
196 | values (51, 1, 'Waiting', '4:03', 4);
197 | insert into Tracks
198 | values (52, 2, 'Evil Ways', '3:57', 4);
199 | insert into Tracks
200 | values (53, 3, 'Shades Of Time', '3:14', 4);
201 | insert into Tracks
202 | values (54, 5, 'Jingo', '4:21', 4);
203 | insert into Tracks
204 | values (55, 4, 'Savor', '2:47', 4);
205 |
206 | insert into Tracks
207 | values (56, 3, 'I Know What I Know', '3:13', 5);
208 | insert into Tracks
209 | values (57, 4, 'Gumboots', '2:42', 5);
210 | insert into Tracks
211 | values (58, 5, 'Diamonds On The Soles Of Her Feet', '5:34', 5);
212 | insert into Tracks
213 | values (59, 6, 'You Can Call Me Al', '4:39', 5);
214 | insert into Tracks
215 | values (60, 7, 'Under African Skies', '3:34', 5);
216 | insert into Tracks
217 | values (61, 8, 'Homeless', '3:45', 5);
218 | insert into Tracks
219 | values (62, 9, 'Crazy Love Vol. II', '4:17', 5);
220 | insert into Tracks
221 | values (63, 10, 'That Was Your Mother', '2:51', 5);
222 | insert into Tracks
223 | values (64, 11, 'All Around The World', '3:15', 5);
224 | insert into Tracks
225 | values (65, 1, 'The Boy in the Bubble', '3:59', 5);
226 | insert into Tracks
227 | values (66, 2, 'Graceland', '4:48', 5);
228 |
229 | insert into Tracks
230 | values (67, 3, 'Stay Awhile', '3:41', 6);
231 | insert into Tracks
232 | values (68, 4, 'When You''re Close', '3:53', 6);
233 | insert into Tracks
234 | values (69, 5, 'I Wouldn''t Mind Knowing', '3:12', 6);
235 | insert into Tracks
236 | values (70, 6, 'Birds Hover', '4:32', 6);
237 | insert into Tracks
238 | values (71, 7, 'Sweet Little Angel of Mine', '2:48', 6);
239 | insert into Tracks
240 | values (72, 8, 'Psychic Hotline', '4:16', 6);
241 | insert into Tracks
242 | values (73, 9, 'Showtime Baby', '3:53', 6);
243 | insert into Tracks
244 | values (74, 10, 'Fell In and Fallen', '4:13', 6);
245 | insert into Tracks
246 | values (75, 11, 'Fourteen Years', '3:47', 6);
247 | insert into Tracks
248 | values (76, 12, 'Louise', '3:06', 6);
249 | insert into Tracks
250 | values (77, 13, 'Whoever Brought You Near', '2:17', 6);
251 | insert into Tracks
252 | values (78, 1, 'Gypsy Girl', '4:14', 6);
253 | insert into Tracks
254 | values (79, 2, 'You Stole Their Hearts', '3:47', 6);
255 |
256 | insert into Tracks
257 | values (80, 3, 'Lucy In The Sky With Diamonds', '3:30', 7);
258 | insert into Tracks
259 | values (81, 4, 'Getting Better', '2:49', 7);
260 | insert into Tracks
261 | values (82, 5, 'Fixing A Hole', '2:38', 7);
262 | insert into Tracks
263 | values (83, 6, 'She''s Leaving Home', '3:37', 7);
264 | insert into Tracks
265 | values (84, 7, 'Being For The Benefit Of Mr. Kite!', '2:37', 7);
266 | insert into Tracks
267 | values (85, 9, 'When I''m Sixty-Four', '2:37', 7);
268 | insert into Tracks
269 | values (86, 8, 'Within You Without You', '5:07', 7);
270 | insert into Tracks
271 | values (87, 10, 'Lovely Rita', '2:44', 7);
272 | insert into Tracks
273 | values (91, 11, 'Sgt. Pepper''s Band Lonely Hearts (Reprise)', '1:20', 7);
274 | insert into Tracks
275 | values (88, 12, 'A Day In The Life', '5:33', 7);
276 | insert into Tracks
277 | values (89, 1, 'Sgt. Pepper''s Lonely Hearts Club Band', '2:04', 7);
278 | insert into Tracks
279 | values (90, 2, 'With a Little Help From My Friends', '2:46', 7);
280 |
281 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # JavaFX-SpringBoot-Samples
2 |
3 | Projects
4 |
5 | IgniteDemo - JavaFX & SpringBoot with two views.
6 |
7 | SpringBootRest - Rest Server using JPA, Hibernate, H2 in-memory database
8 | Provides CRUD REST endpoints for MusicCategory table
9 | Synchronous traditional REST server, uses embedded Tomcat.
10 | See applications.properties for custom configuration.
11 |
12 | SpringBootRestMySql - Rest Server using JPA, Hibernate, MySQL database. You must
13 | install MySQL (Community Edition is fine)
14 | See the application.properties file for custom configuration,
15 | including root password
16 |
17 | Optionally install MySQLWorkbench to initialize database
18 | with schema and data
19 |
20 | SpringBootWebClientFX - JavaFX & SpringBoot client that provides CRUD operations.
21 | Uses WebFlux WebClient in blocking mode.
22 | You must run the SpringBootRest (or SpringBootRestMySql) server first.
23 |
24 | SpringBootWebClientFXMultiThread - JavaFX & SpringBoot client that provides CRUD
25 | operations.
26 | Uses WebFlux WebClient in blocking mode
27 | Uses JavaFX Concurency library to make REST calls in a
28 | background thread
29 | Includes a delay so you can see the ProgressIndicator.
30 | You must run the SpringBootRest (or SpringBootRestMySql) server first.
31 |
32 | WeatherService - SpringBoot Reactive WebService
33 | Emits random Weather forecasts on interval as server sent events
34 | Uses SpringBoot WebFlux library
35 |
36 | WeatherJFXClient - JavaFX & SpringBoot client that subscribes to the Reactive
37 | Weather Service and displays weather forecasts as they arrive.
38 | You must run WeatherService first.
39 |
40 |
--------------------------------------------------------------------------------
/SpringBootClientFXMultiThread/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/SpringBootClientFXMultiThread/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gailasgteach/JavaFX-SpringBoot-Samples/91efd37a37c5560541a25ade6b0932d8e2606cff/SpringBootClientFXMultiThread/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/SpringBootClientFXMultiThread/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.3/apache-maven-3.8.3-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/SpringBootClientFXMultiThread/mvnw.cmd:
--------------------------------------------------------------------------------
1 | @REM ----------------------------------------------------------------------------
2 | @REM Licensed to the Apache Software Foundation (ASF) under one
3 | @REM or more contributor license agreements. See the NOTICE file
4 | @REM distributed with this work for additional information
5 | @REM regarding copyright ownership. The ASF licenses this file
6 | @REM to you under the Apache License, Version 2.0 (the
7 | @REM "License"); you may not use this file except in compliance
8 | @REM with the License. You may obtain a copy of the License at
9 | @REM
10 | @REM https://www.apache.org/licenses/LICENSE-2.0
11 | @REM
12 | @REM Unless required by applicable law or agreed to in writing,
13 | @REM software distributed under the License is distributed on an
14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | @REM KIND, either express or implied. See the License for the
16 | @REM specific language governing permissions and limitations
17 | @REM under the License.
18 | @REM ----------------------------------------------------------------------------
19 |
20 | @REM ----------------------------------------------------------------------------
21 | @REM Maven Start Up Batch script
22 | @REM
23 | @REM Required ENV vars:
24 | @REM JAVA_HOME - location of a JDK home dir
25 | @REM
26 | @REM Optional ENV vars
27 | @REM M2_HOME - location of maven2's installed home dir
28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
31 | @REM e.g. to debug Maven itself, use
32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
34 | @REM ----------------------------------------------------------------------------
35 |
36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
37 | @echo off
38 | @REM set title of command window
39 | title %0
40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
42 |
43 | @REM set %HOME% to equivalent of $HOME
44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
45 |
46 | @REM Execute a user defined script before this one
47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending
49 | if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
50 | if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
51 | :skipRcPre
52 |
53 | @setlocal
54 |
55 | set ERROR_CODE=0
56 |
57 | @REM To isolate internal variables from possible post scripts, we use another setlocal
58 | @setlocal
59 |
60 | @REM ==== START VALIDATION ====
61 | if not "%JAVA_HOME%" == "" goto OkJHome
62 |
63 | echo.
64 | echo Error: JAVA_HOME not found in your environment. >&2
65 | echo Please set the JAVA_HOME variable in your environment to match the >&2
66 | echo location of your Java installation. >&2
67 | echo.
68 | goto error
69 |
70 | :OkJHome
71 | if exist "%JAVA_HOME%\bin\java.exe" goto init
72 |
73 | echo.
74 | echo Error: JAVA_HOME is set to an invalid directory. >&2
75 | echo JAVA_HOME = "%JAVA_HOME%" >&2
76 | echo Please set the JAVA_HOME variable in your environment to match the >&2
77 | echo location of your Java installation. >&2
78 | echo.
79 | goto error
80 |
81 | @REM ==== END VALIDATION ====
82 |
83 | :init
84 |
85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
86 | @REM Fallback to current working directory if not found.
87 |
88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
90 |
91 | set EXEC_DIR=%CD%
92 | set WDIR=%EXEC_DIR%
93 | :findBaseDir
94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound
95 | cd ..
96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound
97 | set WDIR=%CD%
98 | goto findBaseDir
99 |
100 | :baseDirFound
101 | set MAVEN_PROJECTBASEDIR=%WDIR%
102 | cd "%EXEC_DIR%"
103 | goto endDetectBaseDir
104 |
105 | :baseDirNotFound
106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
107 | cd "%EXEC_DIR%"
108 |
109 | :endDetectBaseDir
110 |
111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
112 |
113 | @setlocal EnableExtensions EnableDelayedExpansion
114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
116 |
117 | :endReadAdditionalConfig
118 |
119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
122 |
123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
124 |
125 | FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
127 | )
128 |
129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data.
131 | if exist %WRAPPER_JAR% (
132 | if "%MVNW_VERBOSE%" == "true" (
133 | echo Found %WRAPPER_JAR%
134 | )
135 | ) else (
136 | if not "%MVNW_REPOURL%" == "" (
137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
138 | )
139 | if "%MVNW_VERBOSE%" == "true" (
140 | echo Couldn't find %WRAPPER_JAR%, downloading it ...
141 | echo Downloading from: %DOWNLOAD_URL%
142 | )
143 |
144 | powershell -Command "&{"^
145 | "$webclient = new-object System.Net.WebClient;"^
146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
148 | "}"^
149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
150 | "}"
151 | if "%MVNW_VERBOSE%" == "true" (
152 | echo Finished downloading %WRAPPER_JAR%
153 | )
154 | )
155 | @REM End of extension
156 |
157 | @REM Provide a "standardized" way to retrieve the CLI args that will
158 | @REM work with both Windows and non-Windows executions.
159 | set MAVEN_CMD_LINE_ARGS=%*
160 |
161 | %MAVEN_JAVA_EXE% ^
162 | %JVM_CONFIG_MAVEN_PROPS% ^
163 | %MAVEN_OPTS% ^
164 | %MAVEN_DEBUG_OPTS% ^
165 | -classpath %WRAPPER_JAR% ^
166 | "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
167 | %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
168 | if ERRORLEVEL 1 goto error
169 | goto end
170 |
171 | :error
172 | set ERROR_CODE=1
173 |
174 | :end
175 | @endlocal & set ERROR_CODE=%ERROR_CODE%
176 |
177 | if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
178 | @REM check for post script, once with legacy .bat ending and once with .cmd ending
179 | if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
180 | if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
181 | :skipRcPost
182 |
183 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
184 | if "%MAVEN_BATCH_PAUSE%"=="on" pause
185 |
186 | if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
187 |
188 | cmd /C exit /B %ERROR_CODE%
189 |
--------------------------------------------------------------------------------
/SpringBootClientFXMultiThread/nbactions.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | run
5 |
6 | jar
7 |
8 |
9 | clean
10 | javafx:run
11 |
12 |
13 |
14 | debug
15 |
16 | jar
17 |
18 |
19 | process-classes
20 | org.codehaus.mojo:exec-maven-plugin:3.0.0:exec
21 |
22 |
23 | -agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address}
24 | ${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs}
25 |
26 | com.asgteach.springboot.MusicClientApp
27 | java
28 | true
29 |
30 |
31 |
32 | profile
33 |
34 | jar
35 |
36 |
37 | process-classes
38 | org.codehaus.mojo:exec-maven-plugin:3.0.0:exec
39 |
40 |
41 |
42 | ${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs}
43 | com.asgteach.springboot.MusicClientApp
44 | java
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/SpringBootClientFXMultiThread/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 | 4.0.0
7 |
8 | org.springframework.boot
9 | spring-boot-starter-parent
10 | 2.6.2
11 |
12 |
13 | com.asgteach
14 | springbootfx
15 | 0.0.1-SNAPSHOT
16 | SpringBootClientFXMultiThread
17 | Consume REST for Spring Boot
18 |
19 | 17
20 | 17.0.0.1
21 | 0.0.8
22 | com.asgteach.springboot.MusicClientApp
23 |
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-webflux
28 |
29 |
30 | org.springframework.boot
31 | spring-boot-starter-test
32 | test
33 |
34 |
35 | org.openjfx
36 | javafx-controls
37 | ${javafxVersion}
38 |
39 |
40 | org.openjfx
41 | javafx-fxml
42 | ${javafxVersion}
43 |
44 |
45 | com.gluonhq
46 | ignite-spring
47 | 1.2.2
48 |
49 |
50 |
51 |
52 |
53 |
54 | org.springframework.boot
55 | spring-boot-maven-plugin
56 |
57 |
58 | org.openjfx
59 | javafx-maven-plugin
60 | ${javafx-maven-plugin-version}
61 |
62 | ${mainClassName}
63 |
64 |
65 |
66 |
67 | default-cli
68 |
69 | ${mainClassName}
70 |
71 |
72 |
73 |
74 | debug
75 |
76 | ${mainClassName}
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/SpringBootClientFXMultiThread/src/main/java/com/asgteach/springboot/MusicClientApp.java:
--------------------------------------------------------------------------------
1 | // MusicClientApp.java - Main application
2 | package com.asgteach.springboot;
3 | import com.gluonhq.ignite.spring.SpringContext;
4 | import java.io.IOException;
5 | import javafx.application.Application;
6 | import javafx.fxml.FXMLLoader;
7 | import javafx.scene.Parent;
8 | import javafx.scene.Scene;
9 | import javafx.stage.Stage;
10 | import org.springframework.beans.factory.annotation.Autowired;
11 | import org.springframework.boot.SpringApplication;
12 | import org.springframework.boot.autoconfigure.SpringBootApplication;
13 | import org.springframework.context.ConfigurableApplicationContext;
14 | import org.springframework.context.annotation.ComponentScan;
15 |
16 | @SpringBootApplication
17 | @ComponentScan({
18 | "com.gluonhq.ignite.spring",
19 | "com.asgteach.springboot"
20 | })
21 | public class MusicClientApp extends Application implements MusicFXApp {
22 | public static void main(String[] args) {
23 | Application.launch(MusicClientApp.class, args);
24 | }
25 |
26 | @Autowired
27 | private FXMLLoader loader;
28 |
29 | private final SpringContext context = new SpringContext(this);
30 | private ConfigurableApplicationContext ctx;
31 |
32 | @Override
33 | public void start(Stage stage) throws IOException {
34 | context.init(() -> {
35 | return ctx = SpringApplication.run(MusicClientApp.class);
36 | });
37 | loader.setLocation(getViewLocation());
38 | Parent primaryView = loader.load();
39 | stage.setTitle("Spring Boot Ignite Music with REST MultiThread");
40 | stage.setScene(new Scene(primaryView));
41 | stage.show();
42 | }
43 |
44 | @Override
45 | public void stop() {
46 | // Close this application context,
47 | // destroys all beans in its bean factory
48 | ctx.close();
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/SpringBootClientFXMultiThread/src/main/java/com/asgteach/springboot/MusicFXApp.java:
--------------------------------------------------------------------------------
1 | // MusicFXApp.java - MusicFXApp interface
2 | package com.asgteach.springboot;
3 | import java.net.URL;
4 |
5 | public interface MusicFXApp {
6 | default URL getViewLocation() {
7 | return getClass().getResource("view.fxml");
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/SpringBootClientFXMultiThread/src/main/java/com/asgteach/springboot/ViewController.java:
--------------------------------------------------------------------------------
1 | // ViewController.java - Controller for view
2 | package com.asgteach.springboot;
3 | import com.asgteach.springboot.domain.MusicCategory;
4 | import com.asgteach.springboot.service.MusicRESTService;
5 | import java.net.URL;
6 | import java.util.List;
7 | import java.util.ResourceBundle;
8 | import javafx.beans.property.BooleanProperty;
9 | import javafx.beans.property.IntegerProperty;
10 | import javafx.beans.property.SimpleBooleanProperty;
11 | import javafx.beans.property.SimpleIntegerProperty;
12 | import javafx.collections.FXCollections;
13 | import javafx.collections.ObservableList;
14 | import javafx.concurrent.Task;
15 | import javafx.event.ActionEvent;
16 | import javafx.fxml.FXML;
17 | import javafx.fxml.Initializable;
18 | import javafx.scene.control.Button;
19 | import javafx.scene.control.Label;
20 | import javafx.scene.control.ProgressIndicator;
21 | import javafx.scene.control.TableColumn;
22 | import javafx.scene.control.TableView;
23 | import javafx.scene.control.TextField;
24 | import javafx.scene.control.cell.PropertyValueFactory;
25 | import javafx.scene.input.KeyEvent;
26 | import org.slf4j.Logger;
27 | import org.slf4j.LoggerFactory;
28 | import org.springframework.beans.factory.annotation.Autowired;
29 | import org.springframework.stereotype.Component;
30 |
31 | @Component
32 | public class ViewController implements Initializable {
33 | private final int SLEEPCOUNT = 2500;
34 | private static final Logger log =
35 | LoggerFactory.getLogger(ViewController.class);
36 |
37 | @Autowired
38 | private MusicRESTService musicService;
39 |
40 | @FXML
41 | private TableView tableView;
42 | @FXML
43 | private TableColumn idColumn;
44 | @FXML
45 | private TableColumn categoryNameColumn;
46 | @FXML
47 | private TextField categoryTextField;
48 | @FXML
49 | private Button removeButton;
50 | @FXML
51 | private Button createButton;
52 | @FXML
53 | private Button updateButton;
54 | @FXML
55 | private Label updateResult;
56 | @FXML
57 | private ProgressIndicator progressIndicator;
58 |
59 | private final BooleanProperty modifiedProperty =
60 | new SimpleBooleanProperty(false);
61 | private MusicCategory selectedCategory;
62 | private final IntegerProperty backgroundActive =
63 | new SimpleIntegerProperty(0);
64 | private final ObservableList musicCategoryData =
65 | FXCollections.observableArrayList();
66 |
67 | @FXML
68 | private void createButtonAction(ActionEvent actionEvent) {
69 | log.info("Create");
70 | backgroundActive.set(backgroundActive.get() + 1);
71 | String category = categoryTextField.getText();
72 | CreateTask task = new CreateTask(category);
73 | task.setOnSucceeded(t -> {
74 | musicCategoryData.setAll(
75 | FXCollections.observableList(task.getValue()));
76 | updateResult.setText("New category " + category + " created.");
77 | categoryTextField.setText("");
78 | backgroundActive.set(backgroundActive.get() - 1);
79 | });
80 | task.setOnFailed(t -> {
81 | backgroundActive.set(backgroundActive.get() - 1);
82 | updateResult.setText("Oops! " +
83 | task.getException().getLocalizedMessage());
84 | });
85 | new Thread(task).start();
86 | }
87 |
88 | @FXML
89 | private void removeButtonAction(ActionEvent actionEvent) {
90 | log.info("Remove " + selectedCategory);
91 | MusicCategory musicCategory = selectedCategory;
92 | RemoveTask task = new RemoveTask(musicCategory);
93 | backgroundActive.set(backgroundActive.get() + 1);
94 | task.setOnSucceeded(t -> {
95 | musicCategoryData.setAll(
96 | FXCollections.observableList(task.getValue()));
97 | updateResult.setText("Category " +
98 | musicCategory.getMusicCategory() + " deleted.");
99 | categoryTextField.setText("");
100 | backgroundActive.set(backgroundActive.get() - 1);
101 | });
102 | task.setOnFailed(t -> {
103 | backgroundActive.set(backgroundActive.get() - 1);
104 | updateResult.setText("Unable to remove category " +
105 | musicCategory.getMusicCategory() + ".\n" +
106 | "Foregin key constraint.");
107 | });
108 | new Thread(task).start();
109 | }
110 |
111 | @FXML
112 | private void updateButtonAction(ActionEvent actionEvent) {
113 | log.info("Update " + selectedCategory);
114 | MusicCategory musicCategory =
115 | tableView.getSelectionModel().getSelectedItem();
116 | musicCategory.setMusicCategory(categoryTextField.getText());
117 | UpdateTask task = new UpdateTask(musicCategory);
118 | backgroundActive.set(backgroundActive.get() + 1);
119 | task.setOnSucceeded(t -> {
120 | musicCategoryData.setAll(
121 | FXCollections.observableList(task.getValue()));
122 | updateResult.setText("Category " +
123 | musicCategory.getMusicCategory() + " updated.");
124 | categoryTextField.setText("");
125 | backgroundActive.set(backgroundActive.get() - 1);
126 | modifiedProperty.set(false);
127 | });
128 | task.setOnFailed(t -> {
129 | backgroundActive.set(backgroundActive.get() - 1);
130 | updateResult.setText("Oops! " +
131 | task.getException().getLocalizedMessage());
132 | });
133 | new Thread(task).start();
134 | }
135 |
136 | @FXML
137 | private void handleKeyAction(KeyEvent keyEvent) {
138 | modifiedProperty.set(true);
139 | }
140 |
141 | @Override
142 | public void initialize(URL location, ResourceBundle resources) {
143 | // Disable Remove/Edit buttons if nothing is selected in ListView
144 | removeButton.disableProperty().bind(
145 | tableView.getSelectionModel().selectedItemProperty().isNull());
146 | updateButton.disableProperty().bind(
147 | tableView.getSelectionModel().selectedItemProperty().isNull()
148 | .or(modifiedProperty.not())
149 | .or(categoryTextField.textProperty().isEmpty()));
150 | createButton.disableProperty().bind(
151 | tableView.getSelectionModel().selectedItemProperty().isNotNull()
152 | .or(categoryTextField.textProperty().isEmpty()));
153 | progressIndicator.visibleProperty().bind(
154 | backgroundActive.greaterThan(0));
155 |
156 | categoryNameColumn.setCellValueFactory(
157 | new PropertyValueFactory<>("musicCategory"));
158 | idColumn.setCellValueFactory(
159 | new PropertyValueFactory<>("musicCategoryId"));
160 | musicCategoryData.setAll(
161 | FXCollections.observableList(musicService.getMusicCategories()));
162 | tableView.setItems(musicCategoryData);
163 | tableView.getSelectionModel().selectedItemProperty().addListener(
164 | (observable, oldValue, newValue) -> {
165 | // newValue can be null if nothing is selected
166 | selectedCategory = newValue;
167 | modifiedProperty.set(false);
168 | if (newValue != null) {
169 | // Populate controls with selected Person
170 | categoryTextField.setText(
171 | selectedCategory.getMusicCategory());
172 | } else {
173 | categoryTextField.setText("");
174 | }
175 | });
176 |
177 | // Clear selection
178 | tableView.getSelectionModel().clearSelection();
179 | }
180 |
181 | private class CreateTask extends Task> {
182 | private final String category;
183 |
184 | private CreateTask(String category) {
185 | this.category = category;
186 | }
187 |
188 | @Override
189 | protected List call() throws Exception {
190 | Thread.sleep(SLEEPCOUNT);
191 | musicService.createMusicCategory(category);
192 | return musicService.getMusicCategories();
193 | }
194 | }
195 |
196 | private class RemoveTask extends Task> {
197 | private final MusicCategory musicCategory;
198 |
199 | private RemoveTask(MusicCategory category) {
200 | this.musicCategory = category;
201 | }
202 |
203 | @Override
204 | protected List call() throws Exception {
205 | Thread.sleep(SLEEPCOUNT);
206 | musicService.deleteMusicCategory(musicCategory);
207 | return musicService.getMusicCategories();
208 | }
209 | }
210 |
211 | private class UpdateTask extends Task> {
212 | private final MusicCategory musicCategory;
213 |
214 | private UpdateTask(MusicCategory category) {
215 | this.musicCategory = category;
216 | }
217 |
218 | @Override
219 | protected List call() throws Exception {
220 | Thread.sleep(SLEEPCOUNT);
221 | musicService.updateMusicCategory(musicCategory);
222 | return musicService.getMusicCategories();
223 | }
224 | }
225 | }
226 |
--------------------------------------------------------------------------------
/SpringBootClientFXMultiThread/src/main/java/com/asgteach/springboot/domain/MusicCategory.java:
--------------------------------------------------------------------------------
1 | // MusicCategory.java - MusicCategory domain class
2 | package com.asgteach.springboot.domain;
3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4 |
5 | @JsonIgnoreProperties(ignoreUnknown = true)
6 | public class MusicCategory {
7 | private Integer musicCategoryId;
8 | private String musicCategory;
9 |
10 | public MusicCategory() { }
11 |
12 | public Integer getMusicCategoryId() {
13 | return musicCategoryId;
14 | }
15 |
16 | public void setMusicCategoryId(Integer musicCategoryId) {
17 | this.musicCategoryId = musicCategoryId;
18 | }
19 |
20 | public String getMusicCategory() {
21 | return musicCategory;
22 | }
23 |
24 | public void setMusicCategory(String musicCategory) {
25 | this.musicCategory = musicCategory;
26 | }
27 |
28 | @Override
29 | public String toString() {
30 | return musicCategoryId + ": " + musicCategory;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/SpringBootClientFXMultiThread/src/main/java/com/asgteach/springboot/service/MusicRESTService.java:
--------------------------------------------------------------------------------
1 | // MusicRESTService.java - Music REST service
2 | package com.asgteach.springboot.service;
3 | import com.asgteach.springboot.domain.MusicCategory;
4 | import java.util.List;
5 | import org.slf4j.Logger;
6 | import org.slf4j.LoggerFactory;
7 | import org.springframework.http.HttpHeaders;
8 | import org.springframework.http.MediaType;
9 | import org.springframework.stereotype.Service;
10 | import org.springframework.web.reactive.function.client.WebClient;
11 | import reactor.core.publisher.Mono;
12 |
13 | @Service
14 | public class MusicRESTService {
15 | private final WebClient webClient;
16 |
17 | public MusicRESTService(WebClient.Builder webClientBuilder) {
18 | webClient =
19 | webClientBuilder.baseUrl("http://localhost:8080").build();
20 | }
21 |
22 | private static final Logger log =
23 | LoggerFactory.getLogger(MusicRESTService.class);
24 |
25 | public List getMusicCategories() {
26 | List result = webClient.get()
27 | .uri("/musiccategories")
28 | .retrieve()
29 | .bodyToFlux(MusicCategory.class)
30 | .collectList()
31 | .block();
32 | result.forEach(mc -> log.info(mc.toString()));
33 | return result;
34 | }
35 |
36 | public MusicCategory getMusicCategory(Integer id) {
37 | MusicCategory mc = webClient.get().uri("/{id}/", id)
38 | .retrieve()
39 | .bodyToMono(MusicCategory.class)
40 | .block();
41 | log.info(mc + " read.");
42 | return mc;
43 | }
44 |
45 | public MusicCategory createMusicCategory(String category) {
46 | MusicCategory mc = new MusicCategory();
47 | mc.setMusicCategory(category);
48 | mc = webClient.post()
49 | .uri("/musiccategories")
50 | .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
51 | .body(Mono.just(mc), MusicCategory.class)
52 | .retrieve()
53 | .bodyToMono(MusicCategory.class)
54 | .block();
55 | log.info(mc + " created.");
56 | return mc;
57 | }
58 |
59 | public MusicCategory updateMusicCategory(MusicCategory mc) {
60 | MusicCategory musicCategory = webClient.put()
61 | .uri("/musiccategories/" + mc.getMusicCategoryId())
62 | .body(Mono.just(mc), MusicCategory.class)
63 | .retrieve()
64 | .bodyToMono(MusicCategory.class)
65 | .block();
66 | log.info(musicCategory + " updated.");
67 | return musicCategory;
68 | }
69 |
70 | public void deleteMusicCategory(MusicCategory mc) {
71 | webClient.delete()
72 | .uri("/musiccategories/" + mc.getMusicCategoryId())
73 | .retrieve()
74 | .bodyToMono(Void.class)
75 | .block();
76 | log.info(mc + " deleted.");
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/SpringBootClientFXMultiThread/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=8081
2 |
--------------------------------------------------------------------------------
/SpringBootClientFXMultiThread/src/main/resources/com/asgteach/springboot/view.fxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
19 |
20 |
24 |
25 |
26 |
27 |
32 |
33 |
36 |
39 |
40 |
41 |
43 |
44 |
45 |
46 |
47 |
49 |
50 |
55 |
56 |
57 |
58 |
59 |
62 |
63 |
64 |
65 |
66 |
70 |
74 |
78 |
79 |
80 |
81 |
82 |
90 |
91 |
92 |
93 |
94 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
--------------------------------------------------------------------------------
/SpringBootClientFXMultiThread/src/test/java/com/asgteach/springbootrestjfx/SpringbootrestjfxApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.asgteach.springbootrestjfx;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class SpringbootrestjfxApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/SpringBootRest/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/SpringBootRest/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gailasgteach/JavaFX-SpringBoot-Samples/91efd37a37c5560541a25ade6b0932d8e2606cff/SpringBootRest/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/SpringBootRest/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.3/apache-maven-3.8.3-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/SpringBootRest/mvnw.cmd:
--------------------------------------------------------------------------------
1 | @REM ----------------------------------------------------------------------------
2 | @REM Licensed to the Apache Software Foundation (ASF) under one
3 | @REM or more contributor license agreements. See the NOTICE file
4 | @REM distributed with this work for additional information
5 | @REM regarding copyright ownership. The ASF licenses this file
6 | @REM to you under the Apache License, Version 2.0 (the
7 | @REM "License"); you may not use this file except in compliance
8 | @REM with the License. You may obtain a copy of the License at
9 | @REM
10 | @REM https://www.apache.org/licenses/LICENSE-2.0
11 | @REM
12 | @REM Unless required by applicable law or agreed to in writing,
13 | @REM software distributed under the License is distributed on an
14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | @REM KIND, either express or implied. See the License for the
16 | @REM specific language governing permissions and limitations
17 | @REM under the License.
18 | @REM ----------------------------------------------------------------------------
19 |
20 | @REM ----------------------------------------------------------------------------
21 | @REM Maven Start Up Batch script
22 | @REM
23 | @REM Required ENV vars:
24 | @REM JAVA_HOME - location of a JDK home dir
25 | @REM
26 | @REM Optional ENV vars
27 | @REM M2_HOME - location of maven2's installed home dir
28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
31 | @REM e.g. to debug Maven itself, use
32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
34 | @REM ----------------------------------------------------------------------------
35 |
36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
37 | @echo off
38 | @REM set title of command window
39 | title %0
40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
42 |
43 | @REM set %HOME% to equivalent of $HOME
44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
45 |
46 | @REM Execute a user defined script before this one
47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending
49 | if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
50 | if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
51 | :skipRcPre
52 |
53 | @setlocal
54 |
55 | set ERROR_CODE=0
56 |
57 | @REM To isolate internal variables from possible post scripts, we use another setlocal
58 | @setlocal
59 |
60 | @REM ==== START VALIDATION ====
61 | if not "%JAVA_HOME%" == "" goto OkJHome
62 |
63 | echo.
64 | echo Error: JAVA_HOME not found in your environment. >&2
65 | echo Please set the JAVA_HOME variable in your environment to match the >&2
66 | echo location of your Java installation. >&2
67 | echo.
68 | goto error
69 |
70 | :OkJHome
71 | if exist "%JAVA_HOME%\bin\java.exe" goto init
72 |
73 | echo.
74 | echo Error: JAVA_HOME is set to an invalid directory. >&2
75 | echo JAVA_HOME = "%JAVA_HOME%" >&2
76 | echo Please set the JAVA_HOME variable in your environment to match the >&2
77 | echo location of your Java installation. >&2
78 | echo.
79 | goto error
80 |
81 | @REM ==== END VALIDATION ====
82 |
83 | :init
84 |
85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
86 | @REM Fallback to current working directory if not found.
87 |
88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
90 |
91 | set EXEC_DIR=%CD%
92 | set WDIR=%EXEC_DIR%
93 | :findBaseDir
94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound
95 | cd ..
96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound
97 | set WDIR=%CD%
98 | goto findBaseDir
99 |
100 | :baseDirFound
101 | set MAVEN_PROJECTBASEDIR=%WDIR%
102 | cd "%EXEC_DIR%"
103 | goto endDetectBaseDir
104 |
105 | :baseDirNotFound
106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
107 | cd "%EXEC_DIR%"
108 |
109 | :endDetectBaseDir
110 |
111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
112 |
113 | @setlocal EnableExtensions EnableDelayedExpansion
114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
116 |
117 | :endReadAdditionalConfig
118 |
119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
122 |
123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
124 |
125 | FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
127 | )
128 |
129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data.
131 | if exist %WRAPPER_JAR% (
132 | if "%MVNW_VERBOSE%" == "true" (
133 | echo Found %WRAPPER_JAR%
134 | )
135 | ) else (
136 | if not "%MVNW_REPOURL%" == "" (
137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
138 | )
139 | if "%MVNW_VERBOSE%" == "true" (
140 | echo Couldn't find %WRAPPER_JAR%, downloading it ...
141 | echo Downloading from: %DOWNLOAD_URL%
142 | )
143 |
144 | powershell -Command "&{"^
145 | "$webclient = new-object System.Net.WebClient;"^
146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
148 | "}"^
149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
150 | "}"
151 | if "%MVNW_VERBOSE%" == "true" (
152 | echo Finished downloading %WRAPPER_JAR%
153 | )
154 | )
155 | @REM End of extension
156 |
157 | @REM Provide a "standardized" way to retrieve the CLI args that will
158 | @REM work with both Windows and non-Windows executions.
159 | set MAVEN_CMD_LINE_ARGS=%*
160 |
161 | %MAVEN_JAVA_EXE% ^
162 | %JVM_CONFIG_MAVEN_PROPS% ^
163 | %MAVEN_OPTS% ^
164 | %MAVEN_DEBUG_OPTS% ^
165 | -classpath %WRAPPER_JAR% ^
166 | "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
167 | %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
168 | if ERRORLEVEL 1 goto error
169 | goto end
170 |
171 | :error
172 | set ERROR_CODE=1
173 |
174 | :end
175 | @endlocal & set ERROR_CODE=%ERROR_CODE%
176 |
177 | if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
178 | @REM check for post script, once with legacy .bat ending and once with .cmd ending
179 | if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
180 | if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
181 | :skipRcPost
182 |
183 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
184 | if "%MAVEN_BATCH_PAUSE%"=="on" pause
185 |
186 | if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
187 |
188 | cmd /C exit /B %ERROR_CODE%
189 |
--------------------------------------------------------------------------------
/SpringBootRest/nb-configuration.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 | jdbc
11 | sa
12 | testdb
13 |
14 |
15 |
--------------------------------------------------------------------------------
/SpringBootRest/nbactions.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | run
5 |
6 | jar
7 |
8 |
9 | spring-boot:run
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | debug
22 |
23 | jar
24 |
25 |
26 | process-classes
27 | org.codehaus.mojo:exec-maven-plugin:3.0.0:exec
28 |
29 |
30 | -agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address}
31 | ${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs}
32 |
33 | com.asgteach.springbootrest.SpringbootrestApplication
34 | java
35 | true
36 |
37 |
38 |
39 | profile
40 |
41 | jar
42 |
43 |
44 | process-classes
45 | org.codehaus.mojo:exec-maven-plugin:3.0.0:exec
46 |
47 |
48 |
49 | ${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs}
50 | com.asgteach.springbootrest.SpringbootrestApplication
51 | java
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/SpringBootRest/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 | 4.0.0
7 |
8 | org.springframework.boot
9 | spring-boot-starter-parent
10 | 2.6.2
11 |
12 |
13 | com.asgteach
14 | springbootrest
15 | 0.0.1-SNAPSHOT
16 | SpringBootRest
17 | REST project for Spring Boot
18 |
19 | 17
20 |
21 |
22 |
23 | org.springframework.boot
24 | spring-boot-starter-data-jpa
25 |
26 |
27 | org.springframework.boot
28 | spring-boot-starter-web
29 |
30 |
31 | org.springframework.boot
32 | spring-boot-devtools
33 | runtime
34 | true
35 |
36 |
37 | com.h2database
38 | h2
39 | runtime
40 |
41 |
42 | org.springframework.boot
43 | spring-boot-starter-test
44 | test
45 |
46 |
47 |
48 |
49 |
50 |
51 | org.springframework.boot
52 | spring-boot-maven-plugin
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/SpringBootRest/src/main/java/com/asgteach/springbootrest/SpringbootrestApplication.java:
--------------------------------------------------------------------------------
1 | // SpringbootrestApplication.java - Main application
2 | package com.asgteach.springbootrest;
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class SpringbootrestApplication {
8 | public static void main(String[] args) {
9 | SpringApplication.run(SpringbootrestApplication.class, args);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/SpringBootRest/src/main/java/com/asgteach/springbootrest/domain/MusicCategory.java:
--------------------------------------------------------------------------------
1 | // MusicCategory.java - MusicCategory Entity
2 | package com.asgteach.springbootrest.domain;
3 | import java.io.Serializable;
4 | import javax.persistence.Basic;
5 | import javax.persistence.Column;
6 | import javax.persistence.Entity;
7 | import javax.persistence.GeneratedValue;
8 | import javax.persistence.GenerationType;
9 | import javax.persistence.Id;
10 | import javax.persistence.Table;
11 |
12 | @Entity
13 | @Table(name = "musiccategories")
14 | public class MusicCategory implements Serializable {
15 | @Id
16 | @GeneratedValue(strategy = GenerationType.IDENTITY)
17 | @Basic(optional = false)
18 | @Column(name = "musiccategoryid")
19 | private Integer musicCategoryId;
20 | @Column(name = "musiccategory")
21 | private String musicCategory;
22 |
23 | public MusicCategory() { }
24 |
25 | public Integer getMusicCategoryId() {
26 | return musicCategoryId;
27 | }
28 |
29 | public void setMusicCategoryId(Integer musicCategoryId) {
30 | this.musicCategoryId = musicCategoryId;
31 | }
32 |
33 | public String getMusicCategory() {
34 | return musicCategory;
35 | }
36 |
37 | public void setMusicCategory(String musicCategory) {
38 | this.musicCategory = musicCategory;
39 | }
40 |
41 | @Override
42 | public String toString() {
43 | return musicCategoryId + ": " + musicCategory;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/SpringBootRest/src/main/java/com/asgteach/springbootrest/service/MusicCategoryNotFoundException.java:
--------------------------------------------------------------------------------
1 | // MusicCategoryNotFoundException.java - Exception class
2 | package com.asgteach.springbootrest.service;
3 |
4 | public class MusicCategoryNotFoundException extends RuntimeException {
5 | public MusicCategoryNotFoundException(String exception) {
6 | super(exception);
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/SpringBootRest/src/main/java/com/asgteach/springbootrest/service/MusicCategoryResource.java:
--------------------------------------------------------------------------------
1 | // MusicCategoryResource.java - Music Category REST resource
2 | package com.asgteach.springbootrest.service;
3 | import com.asgteach.springbootrest.domain.MusicCategory;
4 | import java.util.List;
5 | import java.util.Optional;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.http.HttpStatus;
8 | import org.springframework.http.ResponseEntity;
9 | import org.springframework.web.bind.annotation.DeleteMapping;
10 | import org.springframework.web.bind.annotation.GetMapping;
11 | import org.springframework.web.bind.annotation.PathVariable;
12 | import org.springframework.web.bind.annotation.PostMapping;
13 | import org.springframework.web.bind.annotation.PutMapping;
14 | import org.springframework.web.bind.annotation.RequestBody;
15 | import org.springframework.web.bind.annotation.RestController;
16 |
17 | @RestController
18 | public class MusicCategoryResource {
19 |
20 | @Autowired
21 | private MusicRepository musicRepository;
22 |
23 | @GetMapping("/musiccategories")
24 | public List retrieveAllMusicCategories() {
25 | return musicRepository.findAll();
26 | }
27 |
28 | @GetMapping("/musiccategories/{id}")
29 | public MusicCategory retrieveMusicCategory(@PathVariable Integer id) {
30 | Optional musicCategory = musicRepository.findById(id);
31 | if (!musicCategory.isPresent()) {
32 | throw new MusicCategoryNotFoundException("id: " + id);
33 | }
34 | return musicCategory.get();
35 | }
36 |
37 | @DeleteMapping("/musiccategories/{id}")
38 | public void deleteMusicCategory(@PathVariable Integer id) {
39 | musicRepository.deleteById(id);
40 | }
41 |
42 | @PostMapping("/musiccategories")
43 | public ResponseEntity