protected JsonReference createProxyRef(LibraryRequest request, Endpoint endpoint, String logicalName)
throws LibraryException {
// If a proxy config has been defined explicitly for the endpoint use it
if(endpoint.getProxyConfig()!=null){
Proxy proxy;
try {
proxy = ProxyFactory.getProxyConfig(endpoint.getProxyConfig());
String proxyUrl = proxy.getProxyUrl();
if(!(UrlUtil.isAbsoluteUrl(proxyUrl))){ // if proxy url specified in proxy config is relative, assume server same as of SBT
// Url is relative, append server to it
proxyUrl = UrlUtil.makeUrlAbsolute(request.getHttpRequest(),proxyUrl);
}
proxyUrl = addMakeAbsoluteUrl(proxyUrl).getRef();
String proxyClass = proxy.getProxyModule();
return new JsonReference("new "+proxyClass+"({proxyUrl:" + proxyUrl + "})");
} catch (ProxyConfigException e) {
if (logger.isLoggable(Level.SEVERE)) {
logger.entering(sourceClass, "createProxyRef failed", e.getMessage());
}