com.nepxion.discovery.plugin.strategy.extension.gateway.context.GatewayStrategyContext Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of discovery-plugin-strategy-extension-gateway Show documentation
Show all versions of discovery-plugin-strategy-extension-gateway Show documentation
Nepxion Discovery is an enhancement for Spring Cloud Discovery
package com.nepxion.discovery.plugin.strategy.extension.gateway.context;
/**
* Title: Nepxion Discovery
* Description: Nepxion Discovery
* Copyright: Copyright (c) 2017-2050
* Company: Nepxion
* @author Haojun Ren
* @version 1.0
*/
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.springframework.web.server.ServerWebExchange;
public class GatewayStrategyContext {
private static final ThreadLocal THREAD_LOCAL = new InheritableThreadLocal() {
@Override
protected GatewayStrategyContext initialValue() {
return new GatewayStrategyContext();
}
};
public static GatewayStrategyContext getCurrentContext() {
return THREAD_LOCAL.get();
}
public static void clearCurrentContext() {
THREAD_LOCAL.remove();
}
private ServerWebExchange exchange;
public ServerWebExchange getExchange() {
return exchange;
}
public void setExchange(ServerWebExchange exchange) {
this.exchange = exchange;
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}