Skip to content

API Changes in 1.0

Joe DiPol edited this page Feb 7, 2019 · 31 revisions

Config

Config API was refactored and there are a lot of changes. The main differences:

  1. Method Config.value() is gone, please use Config.asString() instead (returns ConfigValue that has all the methods of Optional<String>, and it also has a method ConfigValue.asOptional() if actual Optional instance is required)
  2. Methods directly accessing a typed value that threw MissingValueException are gone as they promoted usage that lead to unexpected problems in runtime. Config is by nature optional - each node may or may not be present. The new API is returning ConfigValue that is in fact an Optional with a few additional methods. If original behavior is needed (e.g. in case a missing configuration node should really fail the program), the method ConfigValue.get() has the same semantics as the original methods.
  3. All typed methods except for a few shortcuts (asString, asInt etc.) are gone - the (correctly typed) equal methods can be found on ConfigValue - config node with default, supplier of config node, optional value, supplier of optional etc.
  4. Config now supports generics - you can use GenericType to convert a config node, as long as appropriate converter is configured with config.
  5. Support for object mapping that searched for static methods, constructors etc. when using method Config.as(Class) is now in a separate module helidon-config-object-mapping, as it violated our "No Magic" principle for helidon SE. You can use custom mappers as before, or use the magic by adding the new module to your dependencies. In addition there is a method Config.as(Function<Config, T>) that can be used with similar semantics for cases that have a static method/constructor with a single Config parameter.

Examples:

// original
config.value().ifPresent(this::setValue);
// new
config.asString().ifPresent(this::setValue);

// original
String failIfMissing = config.asString();
// new
String failIfMissing = config.asString().get();

// original
String withDefault = config.asString("defaultValue");
// new
String withDefault = config.asString().orElse("defaultValue");

// original
Supplier<Optional<String>> sup = config.asOptionalStringSupplier();
Supplier<Optional<Integer>> sup2 = config.asOptionalIntSupplier();
// new
Supplier<Optional<String>> sup = config.asString().optionalSupplier();
Supplier<Optional<Integer>> sup2 = config.asInt().optionalSupplier();

// original
config.as(FooBar.class).ifPresent(Foo::bar); // FooBar has static factory method create(Config)
// new
config.as(FooBar::create).ifPresent(Foo::bar);

// original
config.as(Parsable.class).ifPresent(this::parsable); // Parsable has static factory method parse(String)
// new
config.asString().as(Parsable::parse).ifPresent(this::parsable);

WebServer

  1. Removal of helidon-webserver-netty module

    The module io.helidon.webserver:helidon-webserver-netty has been combined into io.helidon.webserver:helidon-webserver. Projects no longer need to declare 2 dependencies for the WebServer, a single dependency on io.helidon.webserver:helidon-webserver is sufficient.

  2. JsonSupport has moved to a top level module. This has resulted in a change to the Maven coordinates and Java package for JsonSupport.

    New Java package: io.helidon.media.jsonp.server.JsonSupport New coordinates:

        <groupId>io.helidon.media.jsonp</groupId>
        <artifactId>helidon-media-jsonp-server</artifactId>
    
  3. JsonSupport.get() now JsonSupport.create()

    As part of aligning factory methods the get() method on JsonSupport has been renamed create()

Tracing

The tracing module (helidon-webserver-zipkin) is removed. See description in https://github.com/oracle/helidon/blob/master/tracing/README.md

  • tracer is abstracted through a TracerBuilder API and TracerProvider SPI
  • integration is separated into modules
    • integration with Zipkin tracer - helidon-tracing-zipkin - can be used standalone (to have a hard dependency on zipkin in sources) or with helidon-tracing to abstract the implementation away
    • integration with webserver - the helidon-tracing module is used to abstract the tracer + manual registration with webserver
    • integration with Jersey client - helidon-tracing-jersey-client
    • integration with Jersey server - helidon-tracing-jersey
    • integration with Helidon MP - helidon-microprofile-tracing

Bundles

Bundles are moved to a bundles module and have a new group id and artifact id.

GroupId: io.helidon.bundles

ArtifactId: helidon-bundles-${component} - e.g. helidon-bundles-config

Old bundles are removed from the project.

Security bundle

Google login provider and Expression Language Policy ABAC support were removed, as they introduce too many dependencies. Please if you need these, add them separately.

Factory Methods

Static factory methods that create a new instance were mostly renamed to create, including the ones that accept config as a parameter.

Example: ServerConfiguration.create()

Getters and Setters

API methods do not use the verb set and get. Some methods were renamed to have a consistent approach across all modules. Old approach: void setPort(int) and int getPort() New approach: void port(int) and int port()

Security

  1. ABAC modules renamed according to directory structure (groupId is io.helidon.security.abac, artifactIds remain the same)
  2. Integrations have a different group id (io.helidon.security.integration), artifactIds remain the same
  3. Security providers:
    1. modules renamed according to directory structure (group id is io.helidon.security.providers
    2. artifactIds modified to have plural of providers (used to be helidon-security-provider-abac, now helidon-security-providers-abac)
    3. package is now io.helidon.security.providers.${module-name}
    4. jigsaw (java9/jpms) module name is now io.helidon.security.providers.${module-name}
    5. Google login button support is now io.helidon.security.providers.google.login (to align with module name and aritfact id)
    6. HTTP Signatures, HTTP Basic/Digest - artifact id, directory and java module renamed to be aligned
  4. Secured config moved to config module (as it has no dependencies outside of common). New coordinates: io.helidon.config:helidon-config-secure, package io.helidon.config.secure
  5. Integration modules (WebServer and Jersey) now have integration package to align with directory structure, module names (jigsaw) changed - instead of adapter now uses integration
  6. Security annotations moved to root of security, package renamed to io.helidon.security.annotations to align with directory structure.

Metrics

Prometheus support and helidon-metrics-se are moved to a root level module metrics, including group ids, artifact ids and packages. Metrics module: io.helidon.metrics:helidon-metrics Prometheus module: io.helidon.metrics:helidon-metrics-prometheus

Microprofile implementation is now formed by a single module: io.helidon.microprofile.metrics:helidon-microprofile-metrics

Health Checks

Module with built-in health checks was moved to io.helidon.health:helidon-health-checks. This may have been used to exclude built-ins when using Helidon MicroProfile 1.2.

There is a new module io.helidon.health:helidon-health with support for health checks in helidon SE. See examples/health/basics for an example on how to use these.

Microprofile

Microprofile jigsaw modules now use microprofile instead of mp in module name.