-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29352 from geoand/rr-runtime-handlers
Introduce way to customize ServerHandler with runtime config
- Loading branch information
Showing
9 changed files
with
134 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...n/java/io/quarkus/resteasy/reactive/server/spi/HandlerConfigurationProviderBuildItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package io.quarkus.resteasy.reactive.server.spi; | ||
|
||
import java.util.function.Supplier; | ||
|
||
import io.quarkus.builder.item.MultiBuildItem; | ||
|
||
/** | ||
* Build time that allows extensions to register a way to provide a value | ||
* for configuration that is provided at runtime and that is needed by | ||
* implementations of {@link org.jboss.resteasy.reactive.server.spi.GenericRuntimeConfigurableServerRestHandler}. | ||
* | ||
* Extensions are meant to create these build items by passing the configuration class as the first constructor | ||
* argument, and using a recorder to return a {@link Supplier} that will provide a value of that class as the | ||
* second argument constructor. | ||
* | ||
* Ideally we would have used generic to make things more type safe, but generics cannot be used in build items. | ||
*/ | ||
@SuppressWarnings("rawtypes") | ||
public final class HandlerConfigurationProviderBuildItem extends MultiBuildItem { | ||
|
||
/** | ||
* The runtime configuration class | ||
*/ | ||
private final Class configClass; | ||
|
||
/** | ||
* A supplier of the runtime value of the configuration class. | ||
* This supplier is meant to be provided by a recorder | ||
*/ | ||
private final Supplier valueSupplier; | ||
|
||
public HandlerConfigurationProviderBuildItem(Class configClass, Supplier valueSupplier) { | ||
this.configClass = configClass; | ||
this.valueSupplier = valueSupplier; | ||
} | ||
|
||
public Class getConfigClass() { | ||
return configClass; | ||
} | ||
|
||
public Supplier getValueSupplier() { | ||
return valueSupplier; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...a/org/jboss/resteasy/reactive/server/spi/GenericRuntimeConfigurableServerRestHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.jboss.resteasy.reactive.server.spi; | ||
|
||
public interface GenericRuntimeConfigurableServerRestHandler<T> extends ServerRestHandler { | ||
|
||
Class<T> getConfigurationClass(); | ||
|
||
void configure(T configuration); | ||
} |
9 changes: 8 additions & 1 deletion
9
...ain/java/org/jboss/resteasy/reactive/server/spi/RuntimeConfigurableServerRestHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
package org.jboss.resteasy.reactive.server.spi; | ||
|
||
public interface RuntimeConfigurableServerRestHandler extends ServerRestHandler { | ||
@Deprecated | ||
public interface RuntimeConfigurableServerRestHandler | ||
extends GenericRuntimeConfigurableServerRestHandler<RuntimeConfiguration> { | ||
|
||
@Override | ||
default Class<RuntimeConfiguration> getConfigurationClass() { | ||
return RuntimeConfiguration.class; | ||
} | ||
|
||
void configure(RuntimeConfiguration configuration); | ||
} |