forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
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 quarkusio#44212 from geoand/quarkusio#44180
Add a cleanup SPI for the REST Client
- Loading branch information
Showing
6 changed files
with
68 additions
and
1 deletion.
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
17 changes: 17 additions & 0 deletions
17
...rest/client/reactive/jackson/runtime/serialisers/JacksonCleanupRestClientClosingTask.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,17 @@ | ||
package io.quarkus.rest.client.reactive.jackson.runtime.serialisers; | ||
|
||
import org.jboss.resteasy.reactive.client.impl.RestClientClosingTask; | ||
|
||
import io.quarkus.rest.client.reactive.jackson.ClientObjectMapper; | ||
|
||
/** | ||
* Cleans up the mappings that is needed to support {@link ClientObjectMapper} | ||
*/ | ||
public class JacksonCleanupRestClientClosingTask implements RestClientClosingTask { | ||
|
||
@Override | ||
public void close(Context context) { | ||
JacksonUtil.contextResolverMap | ||
.remove(new ResolverMapKey(context.baseTarget().getConfiguration(), context.restApiClass())); | ||
} | ||
} |
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
1 change: 1 addition & 0 deletions
1
...resources/META-INF/services/org.jboss.resteasy.reactive.client.impl.RestClientClosingTask
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 @@ | ||
io.quarkus.rest.client.reactive.jackson.runtime.serialisers.JacksonCleanupRestClientClosingTask |
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
30 changes: 30 additions & 0 deletions
30
.../runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/RestClientClosingTask.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,30 @@ | ||
package org.jboss.resteasy.reactive.client.impl; | ||
|
||
import java.util.ServiceLoader; | ||
|
||
import org.jboss.logging.Logger; | ||
|
||
/** | ||
* This represents a task that will be called by the implementation class of the REST Client when the {@code close} | ||
* method is called. | ||
*/ | ||
public interface RestClientClosingTask { | ||
|
||
Logger log = Logger.getLogger(RestClientClosingTask.class); | ||
|
||
void close(Context context); | ||
|
||
record Context(Class<?> restApiClass, WebTargetImpl baseTarget) { | ||
} | ||
|
||
@SuppressWarnings("unused") // this is called by the implementation class of the REST Client when the {@code close} method is called | ||
static void invokeAll(Context context) { | ||
for (RestClientClosingTask restClientClosingTask : ServiceLoader.load(RestClientClosingTask.class)) { | ||
try { | ||
restClientClosingTask.close(context); | ||
} catch (Exception e) { | ||
log.warn("Error running RestClientClosingTask", e); | ||
} | ||
} | ||
} | ||
} |