Skip to content

Commit

Permalink
4.x: Make HttpRouting an interface (#8523)
Browse files Browse the repository at this point in the history
* 4.x: Make HttpRouting an interface
---------

Co-authored-by: Kay Werndli <kay@spinque.com>
  • Loading branch information
VerKWer and Kay Werndli authored Apr 3, 2024
1 parent 8372bbc commit ee86250
Show file tree
Hide file tree
Showing 7 changed files with 431 additions and 353 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
* Copyright (c) 2022, 2024 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -42,6 +42,11 @@ private TyrusRouting(Builder builder) {
this.extensions = builder.extensions;
}

@Override
public Class<? extends Routing> routingType() {
return TyrusRouting.class;
}

/**
* Builder for WebSocket routing.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
* Copyright (c) 2022, 2024 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -42,6 +42,11 @@ private GrpcRouting(Builder builder) {
this.routes = new ArrayList<>(builder.routes);
}

@Override
public Class<? extends Routing> routingType() {
return GrpcRouting.class;
}

/**
* New routing builder.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
* Copyright (c) 2022, 2024 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,7 +30,7 @@ private RouterImpl(Builder builder) {
builder.routings.values()
.forEach(it -> {
Routing routing = it.build();
routings.put(routing.getClass(), routing);
routings.put(routing.routingType(), routing);
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
* Copyright (c) 2022, 2024 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,4 +20,14 @@
* Routing abstraction.
*/
public interface Routing extends ServerLifecycle {

/**
* The class used by a {@link Router} to identify this {@link Routing} type and associate a connection with it.
*
* @return this routing type
*/
default Class<? extends Routing> routingType() {
return getClass();
}

}
Loading

0 comments on commit ee86250

Please sign in to comment.