package com.ard.work.component.forest; import com.ard.work.domain.entity.ArdServerInfo; import com.ard.work.service.IArdServerService; import com.dtflys.forest.callback.AddressSource; import com.dtflys.forest.http.ForestAddress; import com.dtflys.forest.http.ForestRequest; import org.springframework.stereotype.Component; import javax.annotation.Resource; @Component public class MyAddressSource implements AddressSource { @Resource private IArdServerService ardServerService; @Override public ForestAddress getAddress(ForestRequest request) { String serverKey = (String) request.getVariableValue("serverId"); ArdServerInfo serverInfo = ardServerService.selectArdServerManagementById(serverKey); // 返回 Forest 地址对象 return new ForestAddress(serverInfo.getHost(), serverInfo.getHttpPort()); } }