org.cattleframework.cloud.discovery.enhancement.plugin.PluginContext Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cattle-cloud-discovery-common Show documentation
Show all versions of cattle-cloud-discovery-common Show documentation
Cattle framework cloud discovery common component pom
/*
* Copyright (C) 2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.cattleframework.cloud.discovery.enhancement.plugin;
import java.net.URI;
import java.util.Objects;
import org.springframework.cloud.client.DefaultServiceInstance;
import org.springframework.cloud.client.ServiceInstance;
/**
* 插件上下文
*
* @author orange
*
*/
public class PluginContext {
private RequestContext requestContext;
private ResponseContext responseContext;
private Throwable throwable;
private ServiceInstance localServiceInstance;
private long delay;
private ServiceInstance targetServiceInstance;
public RequestContext getRequest() {
return requestContext;
}
public void setRequest(RequestContext requestContext) {
this.requestContext = requestContext;
}
public ResponseContext getResponse() {
return responseContext;
}
public void setResponse(ResponseContext responseContext) {
this.responseContext = responseContext;
}
public Throwable getThrowable() {
return throwable;
}
public void setThrowable(Throwable throwable) {
this.throwable = throwable;
}
public ServiceInstance getLocalServiceInstance() {
return localServiceInstance;
}
public void setLocalServiceInstance(ServiceInstance localServiceInstance) {
this.localServiceInstance = localServiceInstance;
}
public long getDelay() {
return delay;
}
public void setDelay(long delay) {
this.delay = delay;
}
public ServiceInstance getTargetServiceInstance() {
return targetServiceInstance;
}
public void setTargetServiceInstance(ServiceInstance targetServiceInstance, URI url) {
if (Objects.nonNull(targetServiceInstance)) {
this.targetServiceInstance = targetServiceInstance;
} else if (Objects.nonNull(url)) {
DefaultServiceInstance defaultServiceInstance = new DefaultServiceInstance();
defaultServiceInstance.setUri(url);
if (defaultServiceInstance.isSecure()) {
defaultServiceInstance.setPort(443);
} else {
defaultServiceInstance.setPort(80);
}
this.targetServiceInstance = defaultServiceInstance;
} else {
this.targetServiceInstance = new DefaultServiceInstance();
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy