Skip to content

API Changes in 1.0

Tomas Langer edited this page Dec 27, 2018 · 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);

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()