Skip to content
GuicedEEPublic

About

A collection of examples that can be used to develop projects

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

GuicedEE Examples

Comprehensive examples demonstrating all GuicedEE functionality. Each example includes:

  • JPMS module-info.java — proper requires, exports, opens, and provides declarations
  • Moditect JLink — runtime image creation via moditect-maven-plugin (create-runtime-image)
  • Maven JLink — classic maven-jlink-plugin packaging (in BasicJLink/ submodules where available)

Prerequisites

  • JDK 25+
  • Maven 4 (or use the Maven wrapper)
  • GuicedEE BOM must be installed locally or available from your configured Maven repository

Startup and discovery

Executable GuicedEE examples use com.guicedee.guicedinjection.GuiceApplication.run(Runnable):

GuiceApplication.run(() -> {
    IGuiceContext.registerModule("your.jpms.module");
    IGuiceContext.getContext().getConfig().setServiceLoadWithClassPath(true);
});

The module name matches module-info.java. Preparation enables annotation, method, and field discovery before injection. The runner waits for asynchronous startup to complete; failed startup runs cleanup and exits the process unsuccessfully. Service lookup and demonstration code run after the runner returns. The JWT bridge demonstration creates and closes its own Vert.x instance.

The Java 25 baseline uses ClassGraph 6.0.0 from the GuicedEE BOM. Scanner sources are explicit; the runtime enables classpath and non-system modules. Consumers use ClassLoading for runtime classes and getAll... / getDirect... metadata queries as appropriate. Live scan JSON caching is no longer available. The examples do not pin an older ClassGraph artifact.

The CDI example declares com.guicedee:cdi and requires com.guicedee.cdi for Jakarta injection and scopes. The other Guice examples use com.google.inject injection annotations so their fields do not depend on an undeclared CDI bridge.

SPIs are registered in both module-info.java and META-INF/services so discovery works on the module path and classpath. Programmatic configuration uses Environment.getSystemPropertyOrEnvironment, including .env.local / .env precedence and placeholder resolution.

In-process tests bootstrap the context directly, enable scanning, await getLoadingFinished(), and destroy it after the test. They do not invoke the process-owning main() entry point.

Building

All modules inherit the examples parent, which aligns Java 25 compilation and ClassGraph 6 through the GuicedEE BOM. It also manages the current CDI, Kafka, IBM MQ, and mail-client coordinates and copies runtime dependencies into target/libs/${guicedee.version} for the Moditect images.

Compile the whole reactor and run the REST integration tests:

mvn -B -ntp test

Install example JARs without recreating their Moditect images:

mvn -B -ntp install -Dmoditect.skip=true

To build an individual example:

cd Rest/Basic
mvn -B -ntp package

Moditect creates a new runtime image during package; use -Dmoditect.skip=true for incremental JAR builds when an image already exists.

To validate all runtime images without replacing existing Moditect images, choose a fresh suffix:

mvn -B -ntp -fae package '-Dexamples.runtimeImageDirectory=${project.build.directory}/jlink-validation-<suffix>' '-Dexamples.runtimeDependencyDirectory=${project.build.directory}/libs-validation-<suffix>'

The moditect jlink image is output to target/jlink-image/. Run with:

target/jlink-image/bin/<launcher-name>

Examples

Module Description Key Dependencies
Inject Core DI bootstrap, lifecycle hooks (IGuiceModule, IGuicePostStartup), Guice bindings inject
CDI Jakarta CDI annotation bridge (@ApplicationScoped, @Inject via CDI) inject, cdi
Config MicroProfile Config with @ConfigProperty injection inject, config
Health MicroProfile Health with @Liveness and @Readiness checks inject, health
Metrics MicroProfile Metrics with @Counted, @Timed, Prometheus endpoint inject, metrics
Telemetry OpenTelemetry tracing with @Trace and @SpanAttribute inject, guiced-telemetry
Vertx Vert.x event bus consumers and publishers with @VertxEventDefinition inject, vertx
Web Vert.x Web server with custom routes via VertxRouterConfigurator SPI inject, web
Rest Jakarta REST (JAX-RS) resources with @Path, @GET, @POST inject, rest
RestClient Annotation-driven REST client with @Endpoint and RestClient inject, rest-client
OpenAPI Automatic OpenAPI 3.1 spec generation + Swagger UI inject, rest, openapi, guiced-swagger-ui
WebServices SOAP web services with JAX-WS annotations inject, guiced-web-services
WebSockets WebSocket messaging with action-based routing (IWebSocketMessageReceiver) inject, websockets
Persistence Reactive JPA with Hibernate Reactive 7 and Mutiny sessions inject, persistence, hibernate-reactive
RabbitMQ Annotation-driven RabbitMQ with @QueueExchange, QueueConsumer/Publisher inject, rabbitmq
Kafka Kafka messaging integration inject, kafka
Cerial Serial port connectivity with @Named CerialPortConnection inject, cerial
Hazelcast Hazelcast-clustered Vert.x (Server, Client, Queues) inject, vertx, hazelcast
MailClient Annotation-driven SMTP mail client with @MailConnectionOptions inject, mail-client

The Web/WebSocketClient and Web/WebSocketServer directories retain module skeletons; use WebSockets/Basic for the complete runnable WebSocket example.

JLink / Moditect Runtime Image

Every Basic/ example includes the moditect-maven-plugin configured to produce a minimal runtime image.

The Rest/BasicJLink/ submodule also demonstrates the alternative maven-jlink-plugin approach with <packaging>jlink</packaging>.

About

A collection of examples that can be used to develop projects

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages