com.nepxion.discovery.plugin.strategy.gateway.wrapper.DefaultGatewayStrategyCallableWrapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of discovery-plugin-strategy-starter-gateway Show documentation
Show all versions of discovery-plugin-strategy-starter-gateway Show documentation
Nepxion Discovery is an enhancement for Spring Cloud Discovery
The newest version!
package com.nepxion.discovery.plugin.strategy.gateway.wrapper;
/**
* Title: Nepxion Discovery
* Description: Nepxion Discovery
* Copyright: Copyright (c) 2017-2050
* Company: Nepxion
* @author Haojun Ren
* @author Hao Huang
* @version 1.0
*/
import java.util.concurrent.Callable;
import org.springframework.web.server.ServerWebExchange;
import com.nepxion.discovery.plugin.strategy.gateway.context.GatewayStrategyContext;
import com.nepxion.discovery.plugin.strategy.monitor.StrategyTracerContext;
public class DefaultGatewayStrategyCallableWrapper implements GatewayStrategyCallableWrapper {
@Override
public Callable wrapCallable(Callable callable) {
ServerWebExchange exchange = GatewayStrategyContext.getCurrentContext().getExchange();
Object span = StrategyTracerContext.getCurrentContext().getSpan();
return new Callable() {
@Override
public T call() throws Exception {
try {
GatewayStrategyContext.getCurrentContext().setExchange(exchange);
StrategyTracerContext.getCurrentContext().setSpan(span);
return callable.call();
} finally {
GatewayStrategyContext.clearCurrentContext();
StrategyTracerContext.clearCurrentContext();
}
}
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy