Run Designer previews with application-owned DI adapters

This commit is contained in:
2026-11-26 16:01:19 +01:00
parent e49d586916
commit 6126967fdc
56 changed files with 2131 additions and 50 deletions
+79
View File
@@ -0,0 +1,79 @@
# Spring contact book
This Maven fixture runs as a JavaFX application and as a NeitzelFXDesigner
preview. It uses Spring Framework 6.2.11, the separated NeitzelLib `1.0.7-SNAPSHOT`,
JavaFX 27.0.1 in the target and JDK 25. Views use the same FXML and adapter
in both environments. Spring owns the application services. Each Controller
and Component is a prototype.
## Run it
Set `JAVA_HOME` to JDK 25 and use a separate local Maven repository to stage
the development artifacts. From the Designer checkout:
```sh
export DI_MAVEN_REPOSITORY="/absolute/path/to/di-repository"
export MAVEN_OPTS="-Dmaven.repo.local=$DI_MAVEN_REPOSITORY"
(cd ../NeitzelLib && ./mvnw -pl fx-test -am clean install)
./mvnw -B -ntp install
./mvnw -f integration-fixtures/spring-di/app/pom.xml javafx:run
```
Edit the book name to see the Spring-supplied Converter update the caption.
Closing the window first destroys its prototypes, then stops the shared
service. The [application bootstrap](app/src/main/java/fixture/spring/app/SpringBook.java)
uses the managed `ViewLoader`. The [Spring registration](app/src/main/java/fixture/spring/app/SpringBookContext.java)
assigns separate scopes to the view types and services.
## Open the previews
From the Designer checkout, set up the ignored local paths once:
```sh
python3 scripts/configure-library-example.py \
--project integration-fixtures/spring-di --target-java-home "$JAVA_HOME"
```
Use the same local Maven repository when starting the Designer or IntelliJ.
Open `app/src/main/resources/fixture/spring/ui/Book.fxml`, select
**Build and Refresh** and then **Form preview** or **Interactive preview**.
The preview starts with `Preview contact book`; changes to it belong to
that preview. **Stop preview** closes the session. Open `EntryCard.fxml`
and start its separate example to see that Component as a standalone root.
The [Book provider](preview/src/main/java/fixture/spring/preview/BookExamples.java)
creates a fresh Model and Spring context. The [Component provider](preview/src/main/java/fixture/spring/preview/CardExamples.java)
returns its own Model and context. Both provide the application
[adapter](app/src/main/java/fixture/spring/app/SpringViews.java).
FXML resources and fields in `fixture.spring.ui` are accessible in the
[application module](app/src/main/java/module-info.java). The
[preview module](preview/src/main/java/module-info.java) exposes its providers.
The package named by `componentPackage` stays closed to demonstrate that
the Spring worker uses FXML resource access and the registered Spring beans.
## Run the checks
From the Designer checkout, using the same JDK and local Maven repository:
```sh
python3 scripts/check-preview-fixtures.py --spring-di --target-java-home "$JAVA_HOME"
./designer-intellij/gradlew -p designer-intellij -PideaHome="$IDEA_HOME" \
-Dmaven.repo.local="$DI_MAVEN_REPOSITORY" buildPlugin
./mvnw -pl designer-standalone \
org.apache.maven.plugins:maven-dependency-plugin:3.6.1:build-classpath \
-DincludeScope=test -Dmdep.outputFile=target/smoke-classpath.txt
python3 scripts/check-spring-hosts.py --java-home "$JAVA_HOME" \
--target-java-home "$JAVA_HOME" --idea-home "$IDEA_HOME"
```
The worker checks include two simultaneous Views, separate scopes, nested
Components, Repeat and Table release, cleanup after load/readiness failure
and cancellation, module resource diagnostics, and the required runtime
diagnostic against FX 1.0.6. The host checks use disposably copied project
files and exercise the canvas, form preview and interactive preview.
Each Spring context verifies that the running application or preview
cannot load Neitzel's `ApplicationContext` or Reflections and that
their JARs are absent from its classpath and module path. The test
runner separately verifies the normal Maven dependency trees. Its
missing-API check resolves FX 1.0.6 from a separate POM.