@@ -28,6 +28,36 @@ will help you migrate a Helidon SE 1.x application to 2.x.
2828
2929include::../../common/guides/migration.adoc[]
3030
31+ == Getters
32+
33+ Some methods that act as getters of type `T` have been modified to return `Optional<T>`. You will
34+ need to change your code to handle the `Optional` return type. For example `ServerRequest.spanContext()`
35+ in 1.x had a return type of `SpanContext`. In 2.x it has a return type of `Optional<SpanContext>`.
36+ So if you had code like:
37+
38+ [source,java]
39+ .Helidon 1.x Code
40+ ----
41+ Span myNewSpan = GlobalTracer.get()
42+ .buildSpan(“my-operation”)
43+ .asChildOf(serverRequest.spanContext())
44+ .start();
45+ ----
46+
47+ you will need to change it to something like:
48+
49+ [source,java]
50+ .Helidon 2.x Code
51+ ----
52+ Tracer.SpanBuilder spanBuilder = serverRequest.tracer()
53+ .buildSpan("my-operation");
54+ serverRequest.spanContext().ifPresent(spanBuilder::asChildOf);
55+ Span myNewSpan = spanBuilder.start();
56+ ----
57+
58+ Note the use of `ifPresent()` on the returned `Optional<SpanContext>`.
59+
60+
3161== Configuration
3262
33631. File watching is now done through a `ChangeWatcher` - use of `PollingStrategies.watch()` needs to be refactored to
@@ -51,7 +81,8 @@ include::../../common/guides/migration.adoc[]
5181 `Config` `Builder`
5282
5383Example of advanced configuration of config:
54- ```java
84+ [source,java]
85+ ----
5586Config.builder()
5687 // system properties with a polling strategy of 10 seconds
5788 .addSource(ConfigSources.systemProperties()
@@ -67,7 +98,7 @@ Config.builder()
6798 // map config source (also supports polling strategy)
6899 .addSource(ConfigSources.create(Map.of("key", "value")))
69100 .build();
70- ```
101+ ----
71102
72103
73104== Resource class when loaded from Config
@@ -86,11 +117,12 @@ In Helidon 1.x support for JSON and other media types was configured when constr
86117refactored so that it can be shared between the Helidon `WebServer` and `WebClient`.
87118You now specify media support as part of the WebServer build:
88119
89- ```java
120+ [source,java]
121+ ----
90122WebServer.builder()
91123 .addMediaSupport(JsonpSupport.create()) //registers reader and writer for Json-P
92124 .build()
93- ```
125+ ----
94126
95127This replaces `Routing.builder().register(JsonSupport.create())...`
96128
@@ -128,33 +160,36 @@ Configuration has been updated to use the new `Resource` approach:
128160The configuration has been updated to have a nicer tree structure:
129161
130162Example of a public key from keystore:
131- ```yaml
163+ [source,yaml]
164+ ----
132165keystore:
133166 cert.alias: "service_cert"
134167 resource.path: "/conf/keystore.p12"
135168 type: "PKCS12"
136169 passphrase: "password"
137- ```
170+ ----
138171
139172Example of a private key from keystore:
140- ```yaml
173+ [source,yaml]
174+ ----
141175keystore:
142176 key:
143177 alias: "myPrivateKey"
144178 passphrase: "password"
145179 resource.resource-path: "keystore/keystore.p12"
146180 passphrase: "password"
147- ```
181+ ----
148182
149183Example of a pem resource with private key and certificate chain:
150- ```yaml
184+ [source,yaml]
185+ ----
151186pem:
152187 key:
153188 passphrase: "password"
154189 resource.resource-path: "keystore/id_rsa.p8"
155190 cert-chain:
156191 resource.resource-path: "keystore/public_key_cert.pem"
157- ```
192+ ----
158193
159194
160195== GrpcTlsDescriptor
@@ -174,29 +209,32 @@ Class `io.helidon.webserver.SSLContextBuilder` has been deprecated and will
174209be removed.
175210
176211The class uses a `Builder` pattern:
177- ```java
212+ [source,java]
213+ ----
178214TlsConfig.builder()
179215 .privateKey(KeyConfig.keystoreBuilder()
180216 .keystore(Resource.create("certificate.p12"))
181217 .keystorePassphrase("helidon")
182- ```
218+ ----
183219
184220The builder or built instance can be registered with a socket configuration builder
185221including the `WebServer.Builder` itself:
186222
187- ```java
223+ [source,java]
224+ ----
188225WebServer.builder(routing())
189226 .tls(tlsConfig)
190227 .build();
191- ```
228+ ----
192229
193230=== Additional Sockets
194231
195232Additional socket configuration has changed both in config
196233and in API.
197234
198235The configuration now accepts following structure:
199- ```yaml
236+ [source,yaml]
237+ ----
200238server:
201239 port: 8000
202240 sockets:
@@ -205,7 +243,7 @@ server:
205243 - name: "static"
206244 port: 8002
207245 enabled: false
208- ```
246+ ----
209247
210248Socket name is now a value of a property, allowing more freedom in naming.
211249The default socket name is implicit (and set to `@default`).
@@ -214,12 +252,13 @@ We have added the `enabled` flag to support disabling sockets through configurat
214252
215253To add socket using a builder, you can use:
216254
217- ```java
255+ [source,java]
256+ ----
218257WebServer.builder()
219258 .addSocket(SocketConfigurationBuidler.builder()
220259 .port(8001)
221260 .name("admin")));
222- ```
261+ ----
223262
224263There is also a specialized method to add a socket and routing
225264together, to remove mapping through a name.
@@ -233,13 +272,14 @@ Most methods from this class have been moved to `WebServer.Builder` or deprecate
233272
234273Example of a simple WebServer setup:
235274
236- ```java
275+ [source,java]
276+ ----
237277WebServer.builder()
238278 .port(8001)
239279 .host("localhost")
240280 .routing(createRouting())
241281 .build();
242- ```
282+ ----
243283
244284=== Other significant WebServer deprecations
245285
0 commit comments