Skip to content

Commit 5a32437

Browse files
committed
JsonSuport with correctly named factory method.
HeatlhSupport with new factory methods. Signed-off-by: Tomas Langer <tomas.langer@oracle.com>
1 parent 977b53f commit 5a32437

13 files changed

Lines changed: 60 additions & 38 deletions

File tree

docs/src/main/docs/webserver/08_json-support.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
///////////////////////////////////////////////////////////////////////////////
22

3-
Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
3+
Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
44

55
Licensed under the Apache License, Version 2.0 (the "License");
66
you may not use this file except in compliance with the License.
@@ -46,7 +46,7 @@ Then you can add routes that handle and return JSON.
4646
.Configure JsonSupport and use it for reading and writing of entities
4747
----
4848
Routing.builder()
49-
.register(JsonSupport.get()) // <1>
49+
.register(JsonSupport.create()) // <1>
5050
.post("/sayhello", Handler.of(JsonObject.class, this::sayHello)) // <2>
5151
.build();
5252
----

examples/guides/se-restful-webservice/src/main/docs/index.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
///////////////////////////////////////////////////////////////////////////////
22

3-
Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
3+
Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
44

55
Licensed under the Apache License, Version 2.0 (the "License");
66
you may not use this file except in compliance with the License.
@@ -491,7 +491,7 @@ include::{main-class}[tag=initMetrics]
491491
----
492492
<1> Initializes the metrics infrastructure in Helidon.
493493
494-
... Just after the invocation of `register(JsonSupport.get())`
494+
... Just after the invocation of `register(JsonSupport.create())`
495495
add this
496496
+
497497
[source,java]

examples/guides/se-restful-webservice/src/main/java-start/io/helidon/guides/se/restfulwebservice/Main.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -42,7 +42,7 @@ private Main() { }
4242
*/
4343
private static Routing createRouting() {
4444
return Routing.builder()
45-
.register(JsonSupport.get())
45+
.register(JsonSupport.create())
4646
.register("/greet", new GreetService())
4747
.build();
4848
}

examples/guides/se-restful-webservice/src/main/java/io/helidon/guides/se/restfulwebservice/Main.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -74,7 +74,7 @@ private static Routing createRouting() {
7474
// tag::createRoutingBasic[]
7575
greetService = new GreetService(); // <1>
7676
return Routing.builder()
77-
.register(JsonSupport.get()) // <2>
77+
.register(JsonSupport.create()) // <2>
7878
// end::createRoutingBasic[]
7979
// tag::registerMetrics[]
8080
.register(metrics) // <1>

examples/quickstarts/helidon-quickstart-se/src/main/java/io/helidon/examples/quickstart/se/Main.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -85,7 +85,7 @@ static WebServer startServer() throws IOException {
8585
*/
8686
private static Routing createRouting(Config config) {
8787
return Routing.builder()
88-
.register(JsonSupport.get())
88+
.register(JsonSupport.create())
8989
.register("/greet", new GreetService(config))
9090
.build();
9191
}

examples/todo-app/demo-frontend/src/main/java/io/helidon/demo/todos/frontend/TodosHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -100,7 +100,7 @@ private Metadata counterMetadata(String name, String description) {
100100
@Override
101101
public void update(final Routing.Rules rules) {
102102
rules
103-
.any(JsonSupport.get())
103+
.any(JsonSupport.create())
104104
.get("/todo/{id}", this::getSingle)
105105
.delete("/todo/{id}", this::delete)
106106
.put("/todo/{id}", this::update)

examples/webserver/basics/src/main/java/io/helidon/webserver/examples/basics/Main.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -268,7 +268,7 @@ public void filterAndProcessEntity() {
268268
public void supports() {
269269
Routing routing = Routing.builder()
270270
.register(StaticContentSupport.create("/static"))
271-
.register("/hello", JsonSupport.get())
271+
.register("/hello", JsonSupport.create())
272272
.get("/hello/{what}", (req, res) -> res.send(Json.createObjectBuilder()
273273
.add("message",
274274
"Hello " + req.path()

examples/webserver/static-content/src/main/java/io/helidon/webserver/examples/staticcontent/CounterService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -39,7 +39,7 @@ public class CounterService implements Service {
3939
@Override
4040
public void update(Routing.Rules routingRules) {
4141
routingRules.any(this::handleAny)
42-
.register("/api", JsonSupport.get())
42+
.register("/api", JsonSupport.create())
4343
.get("/api/counter", this::handleGet);
4444
}
4545

health/health/src/main/java/io/helidon/health/HealthSupport.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -71,7 +71,7 @@ private HealthSupport(Builder builder) {
7171

7272
@Override
7373
public void update(Routing.Rules rules) {
74-
rules.get(webContext, JsonSupport.get())
74+
rules.get(webContext, JsonSupport.create())
7575
.get(webContext, (req, res) -> {
7676
HealthResponse hres = callHealthChecks();
7777

@@ -158,6 +158,28 @@ public static Builder builder() {
158158
return new Builder();
159159
}
160160

161+
/**
162+
* Create a new HealthSupport with no health checks configured.
163+
* The endpoint will always return {@code UP}.
164+
*
165+
* @return health support configured with no health checks
166+
*/
167+
public static HealthSupport create(){
168+
return builder().build();
169+
}
170+
171+
/**
172+
* Create a new HealthSupport with no health checks, configured from provided config.
173+
* The endpoint will always return {@code UP}.
174+
*
175+
* @param config configuration of this health check, used only to get {@code web-context} property to configure
176+
* {@link Builder#webContext(String)}
177+
* @return health support configured with no health checks
178+
*/
179+
public static HealthSupport create(Config config) {
180+
return builder().config(config).build();
181+
}
182+
161183
/**
162184
* Fluent API builder for {@link io.helidon.health.HealthSupport}.
163185
*/

metrics/metrics/src/main/java/io/helidon/metrics/MetricsSupport.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -285,7 +285,7 @@ public void update(Routing.Rules rules) {
285285
});
286286

287287
rules.anyOf(CollectionsHelper.listOf(Http.Method.GET, Http.Method.OPTIONS),
288-
JsonSupport.get());
288+
JsonSupport.create());
289289

290290
// routing to root of metrics
291291
rules.get(context, (req, res) -> getMultiple(req, res, base, app, vendor))

0 commit comments

Comments
 (0)