### Simple WebServer Setup Source: https://helidon.io/docs/v4/se/guides/upgrade.html A basic example of setting up a WebServer with a specified port, host, and routing. This replaces the older ServerConfiguration. ```java WebServer.builder() .port(8001) .host("localhost") .routing(createRouting()) .build() ``` -------------------------------- ### Set Up Routing in Main.java Source: https://helidon.io/docs/v4/se/guides/dbclient.html Configures the HTTP routing for the application. This example registers the GreetService and LibraryService, and sets up a simple GET endpoint for '/simple-greet'. ```java static void routing(HttpRouting.Builder routing) { routing .register("/greet", new GreetService()) .register("/library", new LibraryService()) .get("/simple-greet", (req, res) -> res.send("Hello World!")); } ``` -------------------------------- ### Advanced Configuration Example Source: https://helidon.io/docs/v4/se/guides/upgrade.html Demonstrates advanced configuration setup using various config sources like system properties with polling, environment variables, optional file sources with change watchers, classpath sources, and map sources. ```java Config.builder() // system properties with a polling strategy of 10 seconds .addSource(ConfigSources.systemProperties() .pollingStrategy(PollingStrategies.regular(Duration.ofSeconds(10)))) // environment variables .addSource(ConfigSources.environmentVariables()) // optional file config source with change watcher .addSource(ConfigSources.file(Paths.get("/conf/app.yaml")) .optional() .changeWatcher(FileSystemWatcher.create())) // classpath config source .addSource(ConfigSources.classpath("application.yaml")) // map config source (also supports polling strategy) .addSource(ConfigSources.create(Map.of("key", "value"))) .build(); ``` -------------------------------- ### Properties Configuration Source Example Source: https://helidon.io/docs/v4/se/config/introduction.html An example of a simple properties file format for configuration. ```properties web.page-size=25 ``` -------------------------------- ### Generate Helidon SE Quickstart Project with CLI Source: https://helidon.io/docs/v4/se/guides/quickstart.html Use the Helidon CLI to create a Maven project for the Quickstart application. ```bash helidon init --batch -Dflavor=se -Dapp-type=quickstart ``` -------------------------------- ### Install Keycloak with Docker Source: https://helidon.io/docs/v4/mp/guides/security-oidc.html Start a Keycloak instance using Docker on local port 8080. Ensure the port is free before running. ```bash docker run -p 8080:8080 -e KEYCLOAK_ADMIN=admin -e KEYCLOAK_ADMIN_PASSWORD=admin quay.io/keycloak/keycloak:24.0.5 start-dev ``` -------------------------------- ### YAML Configuration Source Example Source: https://helidon.io/docs/v4/se/config/introduction.html An example of a YAML format for configuration, demonstrating a nested structure. ```yaml web: page-size: 25 ``` -------------------------------- ### Example Tracing Configuration in application.yaml Source: https://helidon.io/docs/v4/mp/tracing.html An example of how tracing can be configured in the application.yaml file, including path-specific settings and component configurations. ```yaml tracing: paths: - path: "/favicon.ico" enabled: false - path: "/metrics" enabled: false - path: "/health" enabled: false components: web-server: spans: - name: "HTTP Request" logs: - name: "content-write" enabled: false ``` -------------------------------- ### OpenApiUi Service Setup Source: https://helidon.io/docs/v4/apidocs/io.helidon.integrations.openapi.ui/io/helidon/integrations/openapi/ui/OpenApiUi.html Details on the setup method used to configure routing and content for the OpenAPI UI service. ```APIDOC ## setup ### Description Sets up the OpenAPI UI service with the provided routing rules, document path, and content provider. ### Parameters #### Path Parameters - **rules** (HttpRules) - Required - The routing rules for the service. - **docPath** (String) - Required - The document context path. - **content** (Function) - Required - The function to provide content. ``` -------------------------------- ### void start(String[] arguments) Source: https://helidon.io/docs/v4/apidocs/io.helidon/io/helidon/spi/HelidonStartupProvider.html Starts the Helidon runtime using the provided command line arguments. ```APIDOC ## start ### Description Starts the runtime. This method is invoked by the ServiceLoader provider mechanism. ### Parameters #### Request Body - **arguments** (String[]) - Required - Command line arguments to be passed to the runtime. ``` -------------------------------- ### Configure Security Gate for User Routes Source: https://helidon.io/docs/v4/apidocs/io.helidon.webserver.security/io/helidon/webserver/security/SecurityHttpFeature.html Configure a security gate for specific routes, such as GET requests under '/user/*', to authenticate all users and require the 'user' role for authorization. This example continues from the previous routing setup. ```java // continue from example above... // create a gate for method GET: authenticate all paths under /user and require role "user" for authorization .get("/user/*", WebSecurity.rolesAllowed("user")) ``` -------------------------------- ### HTTP Signatures Configuration Example Source: https://helidon.io/docs/v4/mp/security/providers.html Example configuration for inbound and outbound HTTP signatures, including HMAC and RSA key setups. ```yaml security: providers: - http-signatures: inbound: keys: - key-id: "service1-hmac" principal-name: "Service1 - HMAC signature" hmac.secret: "${CLEAR=changeit}" - key-id: "service1-rsa" principal-name: "Service1 - RSA signature" public-key: keystore: resource.path: "src/main/resources/keystore.p12" passphrase: "changeit" cert.alias: "service_cert" outbound: - name: "service2-hmac" hosts: ["localhost"] paths: ["/service2"] signature: key-id: "service1-hmac" hmac.secret: "${CLEAR=changeit}" - name: "service2-rsa" hosts: ["localhost"] paths: ["/service2-rsa.*"] signature: key-id: "service1-rsa" private-key: keystore: resource.path: "src/main/resources/keystore.p12" passphrase: "changeit" key.alias: "myPrivateKey" ``` -------------------------------- ### GET /io.helidon.microprofile.cdi/HelidonContainer/instance Source: https://helidon.io/docs/v4/apidocs/io.helidon.microprofile.cdi/io/helidon/microprofile/cdi/class-use/HelidonContainer.html Retrieves the initialized or started HelidonContainer instance. ```APIDOC ## GET /io.helidon.microprofile.cdi/HelidonContainer/instance ### Description Retrieves the (initialized or started) container instance for the Helidon MicroProfile CDI environment. ### Method GET ### Endpoint io.helidon.microprofile.cdi.HelidonContainer.instance() ### Response #### Success Response (200) - **HelidonContainer** (object) - The initialized or started container instance. ``` -------------------------------- ### Get Generic Type Example Source: https://helidon.io/docs/v4/apidocs/io.helidon.microprofile.grpc.core/io/helidon/microprofile/grpc/core/UnaryMethodHandlerSupplier.UnaryFuture.html Example illustrating how to obtain the generic type of a Type, particularly for StreamObservers. If the type is a Class, it returns Object. ```java StreamObserver observer ``` ```java StreamObserver observer ``` -------------------------------- ### Run Client Application Source: https://helidon.io/docs/v4/se/guides/webclient.html Executes the WebClient example application from the command line. ```bash java -cp target/helidon-quickstart-se.jar io.helidon.examples.quickstart.se.ClientExample ``` -------------------------------- ### Interact with Helidon SE Greeting Service (GET) Source: https://helidon.io/docs/v4/se/guides/quickstart.html Example cURL commands to test the GET endpoints of the Helidon SE greeting service. ```bash curl -X GET http://localhost:8080/greet ``` ```bash curl -X GET http://localhost:8080/greet/Joe ``` -------------------------------- ### postSetup Method Source: https://helidon.io/docs/v4/apidocs/io.helidon.servicecommon/io/helidon/webserver/servicecommon/HelidonFeatureSupport.html Allows for registering services, filters, etc., on either the default or feature routing rules after the initial setup. ```APIDOC ## Method postSetup ### Signature protected void postSetup(HttpRouting.Builder defaultRouting, HttpRouting.Builder featureRouting) ### Description Deprecated, for removal: This API element is subject to removal in a future version. This can be used to register services, filters etc. on either the default rules (usually the main routing of the web server) and the feature routing (may be the same instance). If `FeatureSupport.service()` provides an instance, that instance will be correctly registered with the context root on feature routing. ### Parameters * `defaultRouting` - default `HttpRules` to be updated * `featureRouting` - actual rules (if different from the default ones) to be updated for the service endpoint ``` -------------------------------- ### Example API Call and Response Source: https://helidon.io/docs/v4/mp/guides/config.html Demonstrates how to invoke the application's greet endpoint and the expected JSON response containing the configuration-injected message. ```bash curl http://localhost:8080/greet ``` ```json { "message": "HelloFromMPConfig World!" } ``` -------------------------------- ### GET /io.helidon.codegen/JavadocTree.EltStart/attributes Source: https://helidon.io/docs/v4/apidocs/io.helidon.codegen/io/helidon/codegen/class-use/JavadocTree.AttrValue.html Retrieves the attributes associated with a Javadoc element start tag. ```APIDOC ## GET /io.helidon.codegen/JavadocTree.EltStart/attributes ### Description Retrieves a map of attributes for a given Javadoc element start tag. ### Method GET ### Response #### Success Response (200) - **attributes** (Map) - A map where keys are attribute names and values are JavadocTree.AttrValue objects. ``` -------------------------------- ### HttpService Implementation Example Source: https://helidon.io/docs/v4/se/webserver/webserver.html An example implementation of the HttpService interface. The routing method defines a GET handler for the '/subpath' relative to the service's registered path prefix. ```java class HelloService implements HttpService { @Override public void routing(HttpRules rules) { rules.get("/subpath", (req, res) -> { // Some logic }); } } ``` -------------------------------- ### Get Configuration Value Programmatically Source: https://helidon.io/docs/v4/mp/config/introduction.html Use the Config API to retrieve configuration properties. This example shows how to get an optional string value, providing a default if it's not found. ```java Config config = ConfigProvider.getConfig(); config.getOptionalValue("app.greeting", String.class).orElse("Hello"); ``` -------------------------------- ### Example of Restored Application Output Source: https://helidon.io/docs/v4/se/guides/crac.html This output demonstrates a successful restoration from a snapshot, highlighting the significantly reduced startup time. ```text warp: Restore successful! [0x21a39da4] http://0.0.0.0:8080 bound for socket '@default' Restored all channels in 2 milliseconds. 20 milliseconds since JVM snapshot restore. Java 23.0.1 ``` -------------------------------- ### Create OpenApiUi and OpenAPISupport Instances Source: https://helidon.io/docs/v4/se/openapi/openapi-ui.html This example demonstrates customizing the UI behavior by programmatically setting UI configurations and then applying general OpenAPI configuration. It's recommended to apply configuration after setting values programmatically to allow external configuration to override. ```java Config openApiConfig = config.get("openapi"); WebServer server = WebServer.builder() .config(config.get("server")) .addFeature(OpenApiFeature.builder() .addService(OpenApiUi.builder() .webContext("my-ui") .config(openApiConfig.get("ui")) .build()) .config(openApiConfig) .build()) .routing(Main::routing) .build() .start(); ``` -------------------------------- ### New Helidon LangChain4j Configuration Example (4.4+) Source: https://helidon.io/docs/v4/se/ai/langchain4j/langchain4j.html This example demonstrates the updated Helidon LangChain4j configuration format starting from version 4.4, where models are named entries under `langchain4j.models`. ```yaml langchain4j: models: # Custom model names are required, to be referencable, in this case 'cheaper-model' cheaper-model: provider: open-ai api-key: "${OPEN_AI_TOKEN}" model-name: "gpt-4o-mini" ``` -------------------------------- ### HTTP Server Endpoint Example Source: https://helidon.io/docs/v4/se/injection/declarative.html This example demonstrates how to create a simple HTTP server endpoint that responds to GET requests with a JSON message. It showcases the use of `@RestServer.Endpoint`, `@Http.Path`, `@Http.GET`, and `@Http.Produces` annotations. ```APIDOC ## GET /greet ### Description This endpoint provides a greeting message in JSON format. It is configured to respond to HTTP GET requests. ### Method GET ### Endpoint /greet ### Parameters #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **message** (string) - The greeting message. #### Response Example ```json { "message": "Hello World!" } ``` ``` -------------------------------- ### Config Creation and Loading Source: https://helidon.io/docs/v4/apidocs/io.helidon.config/io/helidon/config/Config.html Demonstrates how to create and load configuration instances using various methods, including default loading, from specified sources, and from string content. ```APIDOC ## Config Creation and Loading ### Description This section covers the static methods available for creating `Config` instances. These methods allow for loading configuration from default locations, custom sources, or directly from string content. ### Static Methods #### `static Config create()` **Description:** Returns a new default `Config` loaded using configuration files available on the classpath and/or the runtime environment. #### `static Config create(Supplier... configSources)` **Description:** Creates a new `Config` loaded from environment variables, system properties, and the specified `ConfigSource` instances. #### `static Config just(String configContent, MediaType mediaType)` **Description:** Creates configuration directly from a string with a specified media type. #### `static Config just(Supplier... configSources)` **Description:** Creates a new `Config` loaded solely from the specified `ConfigSource` instances. #### `static Config empty()` **Description:** Returns an empty instance of `Config`. #### `static Config.Builder builder()` **Description:** Provides a `Config.Builder` for creating a `Config` instance. #### `static Config.Builder builder(Supplier... configSources)` **Description:** Provides a `Config.Builder` for creating a `Config` based on the specified `ConfigSource` instances. ``` -------------------------------- ### Build, Run, and Test Application Source: https://helidon.io/docs/v4/se/guides/tracing.html Package the application, run the JAR, and send a request to the '/outbound' endpoint to verify the integration and tracing. ```bash mvn clean package java -jar target/helidon-quickstart-se.jar curl -i http://localhost:8080/greet/outbound ``` -------------------------------- ### Interact with Helidon SE Greeting Service (GET after PUT) Source: https://helidon.io/docs/v4/se/guides/quickstart.html Example cURL command to verify the greeting message after a PUT request. ```bash curl -X GET http://localhost:8080/greet/Jose ``` -------------------------------- ### Get Generic Type Example Source: https://helidon.io/docs/v4/apidocs/io.helidon.microprofile.grpc.core/io/helidon/microprofile/grpc/core/UnaryMethodHandlerSupplier.ResponseOnly.html Illustrates obtaining the generic type from a Type, such as a StreamObserver. If the type is a simple Class, it returns Object.class. ```java StreamObserver observer ``` ```java StreamObserver observer ``` -------------------------------- ### Using the Context Builder Source: https://helidon.io/docs/v4/apidocs/io.helidon.common.context/io/helidon/common/context/Context.html Illustrates how to obtain a builder for advanced configuration of the Context. ```java Context.Builder builder = Context.builder(); ``` -------------------------------- ### Start Application from Custom Image Source: https://helidon.io/docs/v4/mp/guides/jlink-image.html Run the application using the start script provided within the generated custom runtime image directory. ```bash ./target/helidon-quickstart-mp-jri/bin/start ``` -------------------------------- ### Private Key Configuration from Keystore Source: https://helidon.io/docs/v4/se/guides/upgrade.html Example of configuring a private key from a keystore. Includes key alias, keystore resource path, and passphrase details. ```yaml keystore: key: alias: "myPrivateKey" passphrase: "password" resource.resource-path: "keystore/keystore.p12" passphrase: "password" ``` -------------------------------- ### ConfigObserver Creation API Source: https://helidon.io/docs/v4/apidocs/io.helidon.webserver.observe.config/io/helidon/webserver/observe/config/ConfigObserver.html Demonstrates different ways to create ConfigObserver instances. ```APIDOC ## POST /api/config/observer/create ### Description Creates a new ConfigObserver instance. This endpoint supports creation with default configuration, specific configuration objects, or through a configuration consumer. ### Method POST ### Endpoint `/api/config/observer/create` ### Parameters #### Request Body - **config** (ConfigObserverConfig) - Optional - The specific configuration to use for the observer. - **consumer** (Consumer) - Optional - A consumer function to customize the observer's configuration. ### Request Example (Default) ```json { "action": "create_default" } ``` ### Request Example (With Config) ```json { "config": { "some_setting": "enabled" } } ``` ### Response #### Success Response (200) - **observer** (ConfigObserver) - The created ConfigObserver instance. #### Response Example ```json { "observer": { "type": "config-observer", "config": { "some_setting": "enabled" } } } ``` ``` -------------------------------- ### Create and Start a Simple Channel Source: https://helidon.io/docs/v4/se/reactive-messaging.html Example of creating a simple channel and configuring a publisher and a listener using Helidon SE Reactive Messaging. ```java Channel channel1 = Channel.create("channel1"); Messaging.builder() .publisher(channel1, Multi.just("message 1", "message 2") .map(Message::of)) .listener(channel1, s -> System.out.println("Intecepted message " + s)) .build() .start(); ``` -------------------------------- ### Configure UniversalConnectionPool via MicroProfile Config Source: https://helidon.io/docs/v4/apidocs/io.helidon.integrations.datasource.ucp.cdi/io/helidon/integrations/datasource/ucp/cdi/UniversalConnectionPoolExtension.html Example system properties to configure a UniversalConnectionPool named 'test' for injection. This setup is required before injecting the pool itself. ```properties oracle.ucp.jdbc.PoolDataSource.test.connectionFactoryClassName=oracle.jdbc.pool.OracleDataSource oracle.ucp.jdbc.PoolDataSource.test.URL=jdbc:oracle:thin://@localhost:1521/XE oracle.ucp.jdbc.PoolDataSource.test.user=scott oracle.ucp.jdbc.PoolDataSource.test.password=tiger ``` -------------------------------- ### HttpFeature Setup Source: https://helidon.io/docs/v4/apidocs/io.helidon.webserver/io/helidon/webserver/http/HttpFeature.html The `setup` method is used to configure the routing for an HttpFeature. This method is called during the server startup process to integrate the feature's services and filters into the overall routing. ```APIDOC ## setup ### Description Method to set up a feature. This method is invoked to configure the routing builder with the feature's specific endpoints, services, or filters. ### Method void ### Parameters #### Request Body - **routing** (HttpRouting.Builder) - Required - The routing builder to which the feature's configuration will be applied. ``` -------------------------------- ### Example Server Routing Configuration Source: https://helidon.io/docs/v4/mp/server.html A comprehensive YAML configuration example demonstrating server port settings, management socket configuration, and routing for a specific application. ```yaml server: port: 8080 sockets: management: port: 8090 io.helidon.examples.AdminApplication: routing-name: name: "management" required: true routing-path: path: "/management" ``` -------------------------------- ### Generate Helidon SE Project with Maven Source: https://helidon.io/docs/v4/se/guides/graalnative.html Use the Helidon SE Quickstart Maven archetype to generate a new project. Ensure you have Maven installed. ```bash mvn -U archetype:generate -DinteractiveMode=false \ -DarchetypeGroupId=io.helidon.archetypes \ -DarchetypeArtifactId=helidon-quickstart-se \ -DarchetypeVersion=4.5.0 \ -DgroupId=io.helidon.examples \ -DartifactId=helidon-quickstart-se \ -Dpackage=io.helidon.examples.quickstart.se ``` -------------------------------- ### Example Application Properties Configuration Source: https://helidon.io/docs/v4/se/builder.html Illustrates how to configure the 'service.name' and 'service.page-size' properties in an 'application.properties' file for the ServiceConfig blueprint. ```properties service.name=My Service service.page-size=10 ``` -------------------------------- ### EurekaRegistrationServerFeature creation example Source: https://helidon.io/docs/v4/apidocs/io.helidon.integrations.eureka/io/helidon/integrations/eureka/EurekaRegistrationServerFeatureProvider.html Illustrates how a EurekaRegistrationServerFeature is created using a builder pattern, configured via a Config object and a name. This is the programmatic equivalent of configuration-based setup. ```java return EurekaRegistrationConfig.builder() .config(config) .name(name) .build(); ``` -------------------------------- ### AsyncConfig Creation and Configuration Source: https://helidon.io/docs/v4/apidocs/io.helidon.faulttolerance/io/helidon/faulttolerance/class-use/AsyncConfig.html Demonstrates how to create and configure AsyncConfig instances. ```APIDOC ## AsyncConfig Creation and Configuration ### Description This section covers the static methods available for creating and configuring `AsyncConfig` instances. ### Methods #### `static AsyncConfig create()` ##### Description Creates a new `AsyncConfig` instance with default values. ##### Method GET ##### Endpoint N/A (Static method) #### `static AsyncConfig create(Config config)` ##### Description Creates a new `AsyncConfig` instance from a given `Config` object. ##### Method GET ##### Endpoint N/A (Static method) #### `static AsyncConfig.Builder builder(AsyncConfig instance)` ##### Description Creates a fluent API builder initialized with an existing `AsyncConfig` instance. ##### Method GET ##### Endpoint N/A (Static method) #### `AsyncConfig.BuilderBase from(AsyncConfig prototype)` ##### Description Updates the current builder instance with values from a provided `AsyncConfig` prototype. ##### Method PUT ##### Endpoint N/A (Instance method on BuilderBase) ### Request Body (Not applicable for static creation methods. For `from` method, it's the `prototype` object.) ### Response #### Success Response (200) - **AsyncConfig** (object) - An instance of `AsyncConfig` or its builder. #### Response Example ```json { "example": "AsyncConfig instance or builder" } ``` ``` -------------------------------- ### Generate Helidon MP Project with LangChain4j Source: https://helidon.io/docs/v4/mp/guides/langchain4j.html Use the Helidon MP Quickstart Maven archetype to generate a new project. Ensure you have Maven installed and configured. ```bash mvn -U archetype:generate -DinteractiveMode=false \ -DarchetypeGroupId=io.helidon.archetypes \ -DarchetypeArtifactId=helidon-quickstart-mp \ -DarchetypeVersion=4.5.0 \ -DgroupId=io.helidon.examples \ -DartifactId=helidon-quickstart-lc4j-mp \ -Dpackage=io.helidon.examples.quickstart.lc4j ``` -------------------------------- ### Create ClientExample Class Source: https://helidon.io/docs/v4/se/guides/webclient.html This snippet shows the basic structure of a Java class that will be used to demonstrate WebClient functionality. ```java public class ClientExample { public static void main(String[] args) { } } ``` -------------------------------- ### Get Boolean Value using Supplier Source: https://helidon.io/docs/v4/se/config/property-mapping.html Demonstrates retrieving a boolean configuration value using a Supplier, which can be useful for lazy evaluation. Includes an example with a default value. ```java Boolean b = value.supplier().get(); boolean defaultedB = value.supplier(true).get(); ``` -------------------------------- ### Example Configuration Structure Source: https://helidon.io/docs/v4/apidocs/io.helidon.common.config/io/helidon/common/config/Config.html A sample YAML-like configuration structure used to demonstrate node detachment. ```yaml app: name: Example 1 page-size: 20 logging: app.level = INFO level = WARNING ``` -------------------------------- ### Method-Level Meta-Annotation Example Source: https://helidon.io/docs/v4/mp/testing/testing.html Shows how to define and apply a custom meta-annotation to test methods. This is useful for applying common test configurations or setups to specific test methods. ```java @Test @AddBean(FirstBean.class) @AddBean(SecondBean.class) @DisableDiscovery @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface MyTestMethod { } @HelidonTest class AnnotationOnMethod { @MyTestMethod void testOne() { } @MyTestMethod void testTwo() { } } ``` -------------------------------- ### WsConfig create Source: https://helidon.io/docs/v4/apidocs/io.helidon.config/io/helidon/config/class-use/Config.html Create a new instance from configuration. ```APIDOC ## WsConfig.create(Config config) ### Description Create a new instance from configuration. ### Method static ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) `WsConfig` instance #### Response Example None ``` -------------------------------- ### Generate Helidon SE Project with Maven Archetype Source: https://helidon.io/docs/v4/se/guides/langchain4j.html Use the Helidon SE Quickstart Maven archetype to generate a new project. Ensure you have Maven installed and configured. ```bash mvn -U archetype:generate -DinteractiveMode=false \ -DarchetypeGroupId=io.helidon.archetypes \ -DarchetypeArtifactId=helidon-quickstart-se \ -DarchetypeVersion=4.5.0 \ -DgroupId=io.helidon.examples \ -DartifactId=helidon-quickstart-lc4j-se \ -Dpackage=io.helidon.examples.quickstart.lc4j ``` -------------------------------- ### Simple LRA Participant Example Source: https://helidon.io/docs/v4/mp/lra.html A JAX-RS resource demonstrating an LRA participant. It starts a new LRA, processes data, and handles completion or compensation based on execution outcome. ```java @PUT @LRA(LRA.Type.REQUIRES_NEW) @Path("start-example") public Response startExample(@HeaderParam(LRA_HTTP_CONTEXT_HEADER) URI lraId, String data) { if (data.contains("BOOM")) { throw new RuntimeException("BOOM 💥"); } LOGGER.info("Data " + data + " processed 🏭"); return Response.ok().build(); } @PUT @Complete @Path("complete-example") public Response completeExample(@HeaderParam(LRA_HTTP_CONTEXT_HEADER) URI lraId) { LOGGER.log(Level.INFO, "LRA ID: {0} completed 🎉", lraId); return LRAResponse.completed(); } @PUT @Compensate @Path("compensate-example") public Response compensateExample(@HeaderParam(LRA_HTTP_CONTEXT_HEADER) URI lraId) { LOGGER.log(Level.SEVERE, "LRA ID: {0} compensated 🦺", lraId); return LRAResponse.compensated(); } ``` -------------------------------- ### Navigate to Project Directory Source: https://helidon.io/docs/v4/mp/guides/langchain4j.html After generating the project, change into the newly created project directory to proceed with building. ```bash cd helidon-quickstart-lc4j-mp ``` -------------------------------- ### HTTP Server Endpoint Example Source: https://helidon.io/docs/v4/se/injection/declarative.html Defines a simple HTTP GET endpoint that produces JSON. It demonstrates endpoint and method annotations, dependency injection for configuration, and JSON object creation. ```java @RestServer.Endpoint // identifies this class as a server endpoint @Http.Path("/greet") // serve this endpoint on /greet context root (path) @Service.Singleton // a singleton service (single instance within a service registry) static class GreetEndpoint { private static final JsonBuilderFactory JSON = Json.createBuilderFactory(Map.of()); private final String greeting; // inject app.greeting configuration value, use "Hello" if not configured GreetEndpoint(@Configuration.Value("${app.greeting:Hello}") String greeting) { this.greeting = greeting; } @Http.GET // HTTP GET endpoint @Http.Produces(MediaTypes.APPLICATION_JSON_VALUE) // produces entity of application/json media type public JsonObject getDefaultMessageHandler() { // build the JSON object (requires `helidon-http-media-jsonp` on classpath) return JSON.createObjectBuilder() .add("message", greeting + " World!") .build(); } } ``` -------------------------------- ### CdiStartupProvider.start Method Source: https://helidon.io/docs/v4/apidocs/io.helidon.microprofile.cdi/io/helidon/microprofile/cdi/CdiStartupProvider.html Starts the Helidon runtime, accepting command line arguments. ```APIDOC ## start(String[] arguments) ### Description Start the runtime. ### Method `void start(String[] arguments)` ### Parameters #### Path Parameters - **arguments** (String[]) - command line arguments ``` -------------------------------- ### YAML Configuration Example for Configured Providers Source: https://helidon.io/docs/v4/apidocs/io.helidon.common.config/io/helidon/common/config/ConfiguredProvider.html This example demonstrates how to configure services that implement ConfiguredProvider using YAML. It shows how to enable service discovery and define configurations for individual providers. ```yaml configured-option: discover-services: true # this is the default providers: provider1-config-key: provider1-config: value provider2-config-key: provider2-config: value ``` -------------------------------- ### Run Jaeger Tracer with Docker Source: https://helidon.io/docs/v4/mp/guides/tracing.html Start a Jaeger tracer instance using Docker. This command exposes Jaeger's collector and UI ports. Ensure Docker is installed and running. ```bash docker run -d --name jaeger \ -e COLLECTOR_OTLP_ENABLED=true \ -p 6831:6831/udp \ -p 6832:6832/udp \ -p 5778:5778 \ -p 16686:16686 \ -p 4317:4317 \ -p 4318:4318 \ -p 14250:14250 \ -p 14268:14268 \ -p 14269:14269 \ -p 9411:9411 \ jaegertracing/all-in-one:1.50 ``` -------------------------------- ### JAX-RS Client Call within a Resource Source: https://helidon.io/docs/v4/apidocs/io.helidon.tracing.jersey.client/io/helidon/tracing/jersey/client/ClientTracingFilter.html Example of making a JAX-RS client call from within a resource method when tracing is configured on the server. No explicit tracing setup is needed in this client code. ```java public String someMethod(@Uri(BACKEND) WebTarget target) { Response response = target.request().get(); // process the response } ``` -------------------------------- ### Web Server Role Validator Configuration Source: https://helidon.io/docs/v4/mp/security/providers.html Example configuration for the `role-validator` in Helidon's WebServer, specifying allowed roles for a particular path. This setup is used to restrict access based on user roles. ```yaml security: web-server.paths: - path: "/user/*" roles-allowed: ["user"] ``` -------------------------------- ### Using References in Configuration Source: https://helidon.io/docs/v4/mp/config/introduction.html Demonstrates how to use `${reference}` syntax to reference other configuration keys, allowing for reuse of configuration values. ```properties uri: "http://localhost:8080" service-1: "${uri}/service1" service-2: "${uri}/service2" ``` -------------------------------- ### Build and Run Second Service Source: https://helidon.io/docs/v4/mp/guides/tracing.html Package the second service application, skipping tests, and then run the JAR file. This starts the service on port 8081. ```bash mvn package -DskipTests=true java -jar target/helidon-quickstart-mp-2.jar ``` -------------------------------- ### Basic HTTP Request Routing Source: https://helidon.io/docs/v4/se/webserver/webserver.html Configure HTTP request routing using HttpRouting.Builder to specify how HTTP requests are handled. This example handles all GET requests to the /hello path and sends a 'Hello World!' response. ```java WebServer.builder() .routing(it -> it .get("/hello", (req, res) -> res.send("Hello World!"))) .build(); ``` -------------------------------- ### setup Method Source: https://helidon.io/docs/v4/apidocs/io.helidon.servicecommon/io/helidon/webserver/servicecommon/HelidonFeatureSupport.html Configures the service endpoint on the provided routing rules. This method is exclusive to FeatureSupport.setup(HttpRouting.Builder) and should not be used concurrently. ```APIDOC ## Method setup ### Signature public final void setup(HttpRouting.Builder defaultRouting, HttpRouting.Builder featureRouting) ### Description Deprecated, for removal: This API element is subject to removal in a future version. Configures service endpoint on the provided routing rules. This method just adds the endpoint path (as defaulted or configured). This method is exclusive to `FeatureSupport.setup(io.helidon.webserver.http.HttpRouting.Builder)` (e.g. you should not use both, as otherwise you would register the endpoint twice) Specified by: `setup` in interface `FeatureSupport` ### Parameters * `defaultRouting` - default routing rules (also accepts `HttpRouting.Builder` * `featureRouting` - actual rules (if different from default) for the service endpoint ``` -------------------------------- ### Interact with Helidon MP Greeting Service Source: https://helidon.io/docs/v4/mp/guides/quickstart.html Examples of interacting with the default Helidon MP greeting service using curl. Demonstrates GET requests to retrieve greetings and a PUT request to change the greeting message. ```bash curl -X GET http://localhost:8080/greet {"message":"Hello World!"} curl -X GET http://localhost:8080/greet/Joe {"message":"Hello Joe!"} curl -X PUT -H "Content-Type: application/json" -d '{"greeting" : "Hola"}' http://localhost:8080/greet/greeting curl -X GET http://localhost:8080/greet/Jose {"message":"Hola Jose!"} ``` -------------------------------- ### Basic Fixed Rate Scheduling Source: https://helidon.io/docs/v4/mp/scheduling.html Example of scheduling a method to run at a fixed rate with a specified delay before the first invocation. The method will execute every 10 minutes, with the first execution 5 minutes after the application starts. ```java @Scheduling.FixedRate(delayBy = "PT5M", value = "PT10M") public void methodName() { System.out.println("Every 10 minutes, first invocation 5 minutes after start"); } ``` -------------------------------- ### Configure Helidon Serialization Programmatically Source: https://helidon.io/docs/v4/mp/security/jep-290.html Register a custom SerializationConfig before the Helidon server starts. This example configures basic tracing, allows deserialization of a specific class, ignores configuration files, and ignores existing global filters. ```java SerializationConfig.builder() .traceSerialization(SerializationConfig.TraceOption.BASIC) .filterPattern(MyType.class.getName()) .ignoreFiles(true) .onWrongConfig(SerializationConfig.Action.IGNORE) .build() .configure(); ``` -------------------------------- ### Generate Helidon MP Quickstart Project with CLI Source: https://helidon.io/docs/v4/mp/guides/quickstart.html Use the Helidon CLI to quickly generate a Maven project for a Helidon MP quickstart application in the current directory. ```bash helidon init --batch -Dflavor=mp -Dapp-type=quickstart ``` -------------------------------- ### Configuration Examples for Encrypted Passwords Source: https://helidon.io/docs/v4/apidocs/io.helidon.config.mp/io/helidon/config/mp/MpEncryptionFilter.html Demonstrates how to define encrypted passwords in configuration files using different encryption schemes like ENC, GCM, RSA, and also shows how to reference other properties or use clear-text values. ```properties new_google_client_secret=${ENC=mYRkg+4Q4hua1kvpCCI2hg==} google_client_secret=${GCM=mYRkg+4Q4hua1kvpCCI2hg==} service_password=${RSA-P=mYRkg+4Q4hua1kvpCCI2hg==} another_password=${service_password} cleartext_password=${CLEAR=known_password} ``` -------------------------------- ### Helidon Test with Mock Connector Configuration Source: https://helidon.io/docs/v4/mp/reactivemessaging/mock.html Example of configuring and using the Mock Connector within a Helidon test class using JUnit 5 annotations. This setup allows for direct injection of the MockConnector and configuration of messaging channels. ```java @HelidonTest @DisableDiscovery @AddBean(MockConnector.class) @AddExtension(MessagingCdiExtension.class) @AddConfig(key = "mp.messaging.incoming.test-channel-in.connector", value = MockConnector.CONNECTOR_NAME) @AddConfig(key = "mp.messaging.incoming.test-channel-in.mock-data-type", value = "java.lang.Integer") @AddConfig(key = "mp.messaging.incoming.test-channel-in.mock-data", value = "6,7,8") @AddConfig(key = "mp.messaging.outgoing.test-channel-out.connector", value = MockConnector.CONNECTOR_NAME) public class MessagingTest { private static final Duration TIMEOUT = Duration.ofSeconds(15); @Inject @TestConnector private MockConnector mockConnector; @Incoming("test-channel-in") @Outgoing("test-channel-out") int multiply(int payload) { return payload * 10; } @Test void testMultiplyChannel() { mockConnector.outgoing("test-channel-out", Integer.TYPE) .awaitPayloads(TIMEOUT, 60, 70, 80); } } ``` -------------------------------- ### Programmatic Configuration of Helidon Serialization Source: https://helidon.io/docs/v4/se/security/jep-290.html Configure custom Helidon serialization settings programmatically before the Helidon server starts. This example sets tracing to basic, filters for a specific class, ignores configuration files, and ignores existing global configurations. ```java SerializationConfig.builder() .traceSerialization(SerializationConfig.TraceOption.BASIC) .filterPattern(MyType.class.getName()) .ignoreFiles(true) .onWrongConfig(SerializationConfig.Action.IGNORE) .build() .configure(); ``` -------------------------------- ### Run Application from Docker Image Source: https://helidon.io/docs/v4/se/guides/crac.html Start a container from the built Docker image. The application will launch directly from the pre-warmed snapshot, resulting in a very fast startup. ```bash docker run --rm -p 8080:8080 helidon-quickstart-se-crac:latest ``` -------------------------------- ### WebClient Discovery Configuration Example Source: https://helidon.io/docs/v4/apidocs/io.helidon.webclient.discovery/io/helidon/webclient/discovery/WebClientDiscovery.html A minimal YAML configuration example for setting up service discovery with custom URI prefixes in Helidon's WebClient. ```APIDOC ## Configuration Examples A minimal example of (YAML) configuration follows: ```yaml client: services: discovery: prefix-uris: S1: http://service1.example.com ``` In this example, original `ClientUri`s beginning with `http://service1.example.com:80/` (note the added/explicit port and path) will be subject to discovery, using `S1` as the discovery name; all others will be passed through with no discovery-related action being taken. ``` -------------------------------- ### GET Route Source: https://helidon.io/docs/v4/apidocs/io.helidon.webserver/io/helidon/webserver/http/HttpRules.html Adds a GET route. ```APIDOC ## GET /websites/helidon_io_v4/get ### Description Adds a get route. ### Method GET ### Endpoint /websites/helidon_io_v4/get ### Parameters #### Query Parameters - **pathPattern** (String) - Required - URI path pattern - **handlers** (Handler...) - Required - handlers to process HTTP request ### Response #### Success Response (200) - **updated rules** (Object) - Description of updated rules ``` ```APIDOC ## GET /websites/helidon_io_v4/get ### Description Adds a get route. ### Method GET ### Endpoint /websites/helidon_io_v4/get ### Parameters #### Query Parameters - **handlers** (Handler...) - Required - handlers to process HTTP request ### Response #### Success Response (200) - **updated rules** (Object) - Description of updated rules ``` -------------------------------- ### SchemaString Creation and Building Source: https://helidon.io/docs/v4/apidocs/io.helidon.json.schema/io/helidon/json/schema/class-use/SchemaString.html Demonstrates how to create and build SchemaString instances. ```APIDOC ## SchemaString Creation and Building ### Description Provides methods for creating new SchemaString instances and building them using a fluent API. ### Methods #### `static SchemaString create()` * **Description**: Creates a new instance of SchemaString with default values. * **Returns**: A new `SchemaString` instance. #### `static SchemaString.Builder builder(SchemaString instance)` * **Description**: Creates a fluent API builder initialized with an existing `SchemaString` instance. * **Parameters**: * `instance` (SchemaString) - The existing `SchemaString` to initialize the builder with. * **Returns**: A new `SchemaString.Builder`. #### `SchemaString.BuilderBase.build()` * **Description**: Builds the `SchemaString` object from the builder. * **Returns**: The constructed `SchemaString` object. #### `SchemaString.BuilderBase.buildPrototype()` * **Description**: Builds a prototype `SchemaString` object. * **Returns**: The constructed prototype `SchemaString` object. #### `SchemaString.BuilderBase.from(SchemaString prototype)` * **Description**: Updates the current builder instance with values from a given prototype `SchemaString`. * **Parameters**: * `prototype` (SchemaString) - The prototype `SchemaString` to copy values from. * **Returns**: The updated builder instance. ``` -------------------------------- ### OtlpPublisherConfigImpl Get Method Source: https://helidon.io/docs/v4/apidocs/io.helidon.metrics.providers.micrometer/io/helidon/metrics/providers/micrometer/OtlpPublisherConfig.BuilderBase.OtlpPublisherConfigImpl.html Gets the OtlpPublisher instance. ```APIDOC ## get ### Description Gets the OtlpPublisher instance. ### Method `public OtlpPublisher get()` ### Endpoint N/A (Method within a class) ### Parameters None ### Request Example None ### Response #### Success Response (200) - **OtlpPublisher** - The OtlpPublisher instance. #### Response Example None ``` -------------------------------- ### SecurityHandlerConfigImpl Get Method Source: https://helidon.io/docs/v4/apidocs/io.helidon.webserver.security/io/helidon/webserver/security/SecurityHandlerConfig.BuilderBase.SecurityHandlerConfigImpl.html Method to get a SecurityHandler instance. ```APIDOC ## get ### Description Get a SecurityHandler instance. ### Method public SecurityHandler get() ### Endpoint N/A (Instance method) ### Returns - **SecurityHandler** - A SecurityHandler instance. ``` -------------------------------- ### Build and Run Application Source: https://helidon.io/docs/v4/se/guides/health.html Commands to stop the current application, package the project, and run the new JAR file. ```bash ^C mvn package java -jar target/helidon-quickstart-se.jar ```