Skip to content

Commit ee86250

Browse files
VerKWerKay Werndli
andauthored
4.x: Make HttpRouting an interface (helidon-io#8523)
* 4.x: Make HttpRouting an interface --------- Co-authored-by: Kay Werndli <kay@spinque.com>
1 parent 8372bbc commit ee86250

7 files changed

Lines changed: 431 additions & 353 deletions

File tree

microprofile/websocket/src/main/java/io/helidon/microprofile/tyrus/TyrusRouting.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
2+
* Copyright (c) 2022, 2024 Oracle and/or its affiliates.
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,6 +42,11 @@ private TyrusRouting(Builder builder) {
4242
this.extensions = builder.extensions;
4343
}
4444

45+
@Override
46+
public Class<? extends Routing> routingType() {
47+
return TyrusRouting.class;
48+
}
49+
4550
/**
4651
* Builder for WebSocket routing.
4752
*

webserver/grpc/src/main/java/io/helidon/webserver/grpc/GrpcRouting.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
2+
* Copyright (c) 2022, 2024 Oracle and/or its affiliates.
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,6 +42,11 @@ private GrpcRouting(Builder builder) {
4242
this.routes = new ArrayList<>(builder.routes);
4343
}
4444

45+
@Override
46+
public Class<? extends Routing> routingType() {
47+
return GrpcRouting.class;
48+
}
49+
4550
/**
4651
* New routing builder.
4752
*

webserver/webserver/src/main/java/io/helidon/webserver/RouterImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
2+
* Copyright (c) 2022, 2024 Oracle and/or its affiliates.
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.
@@ -30,7 +30,7 @@ private RouterImpl(Builder builder) {
3030
builder.routings.values()
3131
.forEach(it -> {
3232
Routing routing = it.build();
33-
routings.put(routing.getClass(), routing);
33+
routings.put(routing.routingType(), routing);
3434
});
3535
}
3636

webserver/webserver/src/main/java/io/helidon/webserver/Routing.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
2+
* Copyright (c) 2022, 2024 Oracle and/or its affiliates.
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.
@@ -20,4 +20,14 @@
2020
* Routing abstraction.
2121
*/
2222
public interface Routing extends ServerLifecycle {
23+
24+
/**
25+
* The class used by a {@link Router} to identify this {@link Routing} type and associate a connection with it.
26+
*
27+
* @return this routing type
28+
*/
29+
default Class<? extends Routing> routingType() {
30+
return getClass();
31+
}
32+
2333
}

0 commit comments

Comments
 (0)